From addb116eda13cf34cd8d5b06f787f413e1b7d073 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Fri, 2 Dec 2022 07:54:31 +0100 Subject: [PATCH] Use virtualenv --- .github/workflows/workflow.yml | 820 +++++++++++++++++---------------- openfisca_tasks/install.mk | 6 +- openfisca_tasks/publish.mk | 6 +- openfisca_tasks/test_code.mk | 8 +- 4 files changed, 421 insertions(+), 419 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b6dd7a5617..409e745443 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -21,13 +21,9 @@ jobs: python: [3.8.10, 3.7.9] include: - os: ubuntu-20.04 - python: 3.8.10 - site-packages: /lib/python3.8/site-packages/ - - os: ubuntu-20.04 - python: 3.7.9 - site-packages: /lib/python3.7/site-packages/ + activate: source venv/bin/activate - os: windows-latest - site-packages: \lib\site-packages\ + activate: .\venv\Scripts\activate runs-on: ${{ matrix.os }} name: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} env: @@ -42,8 +38,8 @@ jobs: with: python-version: ${{ matrix.python }} - - name: Use zstd for faster cache restore - if: ${{ matrix.os == 'windows-latest' }} + - name: Use zstd for faster cache restore (windows) + if: ${{ startsWith(matrix.os, 'windows') }} shell: cmd run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" @@ -51,14 +47,19 @@ jobs: id: restore-deps uses: actions/cache@v3 with: - path: ${{ env.pythonLocation }}${{ matrix.site-packages }} + path: venv key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} - restore-keys: | # in case of a cache miss (systematically unless the same commit is built repeatedly), the keys below will be used to restore dependencies from previous builds, and the cache will be stored at the end of the job, making up-to-date dependencies available for all jobs of the workflow; see more at https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action - deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}- + restore-keys: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}- + + - name: Create virtualenv + if: steps.restore-deps.outputs.cache-hit != 'true' + run: python -m venv venv - name: Install dependencies if: steps.restore-deps.outputs.cache-hit != 'true' - run: make install-deps install-dist + run: | + ${{ matrix.activate }} + make install-deps install-dist build: strategy: @@ -69,16 +70,18 @@ jobs: python: [3.8.10, 3.7.9] include: - os: ubuntu-20.04 - bin: /bin/ + bin: venv/bin/openfisca + activate: source venv/bin/activate - os: ubuntu-20.04 python: 3.8.10 - site-packages: /lib/python3.8/site-packages/ + lib: venv/lib/python3.8/openfisca - os: ubuntu-20.04 python: 3.7.9 - site-packages: /lib/python3.7/site-packages/ + lib: venv/lib/python3.7/openfisca - os: windows-latest - bin: \scripts\ - site-packages: \lib\site-packages\ + bin: venv\Scripts\openfisca + lib: venv\lib\openfisca + activate: .\venv\Scripts\activate runs-on: ${{ matrix.os }} name: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} needs: [ deps ] @@ -95,416 +98,415 @@ jobs: python-version: ${{ matrix.python }} - name: Use zstd for faster cache restore - if: ${{ matrix.os == 'windows-latest' }} + if: ${{ startsWith(matrix.os, 'windows') }} shell: cmd run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - name: Cache deps - id: restore-deps uses: actions/cache@v3 with: - path: ${{ env.pythonLocation }}${{ matrix.site-packages }} + path: venv key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} - name: Cache build - id: restore-build uses: actions/cache@v3 with: - path: | - ${{ env.PKG_CONFIG_PATH }} - ${{ env.pythonLocation }}${{ matrix.bin }}openfisca - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api + path: ${{ matrix.bin }} ${{ matrix.lib }}_core ${{ matrix.lib }}_web_api ${{ matrix.lib }}_country_template ${{ matrix.lib }}_extension_template key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - restore-keys: | # in case of a cache miss (systematically unless the same commit is built repeatedly), the keys below will be used to restore dependencies from previous builds, and the cache will be stored at the end of the job, making up-to-date dependencies available for all jobs of the workflow; see more at https://docs.github.com/en/actions/advanced-guides/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action - deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}- - deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}- + restore-keys: | + build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}- + build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}- - name: Cache release - id: restore-release uses: actions/cache@v3 with: path: dist key: release-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - name: Build package - run: make clean build - - test-core: - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04, windows-latest] - numpy: [1.20.3] - python: [3.8.10, 3.7.9] - include: - - os: ubuntu-20.04 - bin: /bin/ - - os: ubuntu-20.04 - python: 3.8.10 - site-packages: /lib/python3.8/site-packages/ - - os: ubuntu-20.04 - python: 3.7.9 - site-packages: /lib/python3.7/site-packages/ - - os: windows-latest - bin: \scripts\ - site-packages: \lib\site-packages\ - runs-on: ${{ matrix.os }} - name: test-core-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - needs: [ build ] - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TERM: xterm-256color # To colorize output of make tasks. - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: Use zstd for faster cache restore - if: ${{ matrix.os == 'windows-latest' }} - shell: cmd - run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - - - name: Cache deps - id: restore-deps - uses: actions/cache@v3 - with: - path: ${{ env.pythonLocation }}${{ matrix.site-packages }} - key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} - - - name: Cache build - id: restore-build - uses: actions/cache@v3 - with: - path: | - ${{ env.PKG_CONFIG_PATH }} - ${{ env.pythonLocation }}${{ matrix.bin }}openfisca - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api - key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - - - name: Run openfisca-core tests - run: make install-test test-core - - - name: Submit coverage to Coveralls - run: python -m coveralls --service=github - - test-country-template: - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04, windows-latest] - numpy: [1.20.3] - python: [3.8.10, 3.7.9] - include: - - os: ubuntu-20.04 - bin: /bin/ - - os: ubuntu-20.04 - python: 3.8.10 - site-packages: /lib/python3.8/site-packages/ - - os: ubuntu-20.04 - python: 3.7.9 - site-packages: /lib/python3.7/site-packages/ - - os: windows-latest - bin: \scripts\ - site-packages: \lib\site-packages\ - runs-on: ${{ matrix.os }} - name: test-country-template-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - needs: [ build ] - env: - TERM: xterm-256color - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: Cache deps - id: restore-deps - uses: actions/cache@v3 - with: - path: ${{ env.pythonLocation }}${{ matrix.site-packages }} - key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} - - - name: Cache build - id: restore-build - uses: actions/cache@v3 - with: - path: | - ${{ env.PKG_CONFIG_PATH }} - ${{ env.pythonLocation }}${{ matrix.bin }}openfisca - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api - key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - - - name: Run Country Template tests - run: make install-test test-country - - test-extension-template: - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04, windows-latest] - numpy: [1.20.3] - python: [3.8.10, 3.7.9] - include: - - os: ubuntu-20.04 - bin: /bin/ - - os: ubuntu-20.04 - python: 3.8.10 - site-packages: /lib/python3.8/site-packages/ - - os: ubuntu-20.04 - python: 3.7.9 - site-packages: /lib/python3.7/site-packages/ - - os: windows-latest - bin: \scripts\ - site-packages: \lib\site-packages\ - runs-on: ${{ matrix.os }} - name: test-extension-template-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - needs: [ build ] - env: - TERM: xterm-256color - - steps: - - uses: actions/checkout@v3 - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: Cache deps - id: restore-deps - uses: actions/cache@v3 - with: - path: ${{ env.pythonLocation }}${{ matrix.site-packages }} - key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} - - - name: Cache build - id: restore-build - uses: actions/cache@v3 - with: - path: | - ${{ env.PKG_CONFIG_PATH }} - ${{ env.pythonLocation }}${{ matrix.bin }}openfisca - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api - key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - - - name: Run Extension Template tests - run: make install-test test-extension - - lint-files: - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04, windows-latest] - numpy: [1.20.3] - python: [3.8.10, 3.7.9] - include: - - os: ubuntu-20.04 - bin: /bin/ - - os: ubuntu-20.04 - python: 3.8.10 - site-packages: /lib/python3.8/site-packages/ - - os: ubuntu-20.04 - python: 3.7.9 - site-packages: /lib/python3.7/site-packages/ - - os: windows-latest - bin: \scripts\ - site-packages: \lib\site-packages\ - runs-on: ${{ matrix.os }} - name: lint-files-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - needs: [ build ] - env: - TERM: xterm-256color - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Fetch all the tags - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: Use zstd for faster cache restore - if: ${{ matrix.os == 'windows-latest' }} - shell: cmd - run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - - - name: Cache deps - id: restore-deps - uses: actions/cache@v3 - with: - path: ${{ env.pythonLocation }}${{ matrix.site-packages }} - key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} - - - name: Cache build - id: restore-build - uses: actions/cache@v3 - with: - path: | - ${{ env.PKG_CONFIG_PATH }} - ${{ env.pythonLocation }}${{ matrix.bin }}openfisca - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core - ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api - key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - - - name: Run linters - run: make clean lint - - check-version: - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04] - numpy: [1.20.3] - python: [3.8.10] - runs-on: ${{ matrix.os }} - name: check-version-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - needs: [ build ] # Last job to run - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Fetch all the tags - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: Check version number has been properly updated - run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" - - # GitHub Actions does not have a halt job option, to stop from deploying if no functional changes were found. - # We build a separate job to substitute the halt option. - # The `deploy` job is dependent on the output of the `check-for-functional-changes`job. - check-for-functional-changes: - strategy: - fail-fast: true - matrix: - os: [ubuntu-20.04] - numpy: [1.20.3] - python: [3.8.10] - runs-on: ${{ matrix.os }} - name: check-for-functional-changes-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch - needs: [ check-version ] - outputs: - status: ${{ steps.stop-early.outputs.status }} - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Fetch all the tags - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - id: stop-early - run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi # The `check-for-functional-changes` job should always succeed regardless of the `has-functional-changes` script's exit code. Consequently, we do not use that exit code to trigger deploy, but rather a dedicated output variable `status`, to avoid a job failure if the exit code is different from 0. Conversely, if the job fails the entire workflow would be marked as `failed` which is disturbing for contributors. - - deploy: - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04] - numpy: [1.20.3] - python: [3.8.10] - include: - - os: ubuntu-20.04 - python: 3.8.10 - site-packages: /lib/python3.8/site-packages/ - runs-on: ${{ matrix.os }} - name: deploy-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - needs: [ check-for-functional-changes ] - if: needs.check-for-functional-changes.outputs.status == 'success' - env: - PYPI_USERNAME: openfisca-bot - PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - CIRCLE_TOKEN: ${{ secrets.CIRCLECI_V1_OPENFISCADOC_TOKEN }} # Personal API token created in CircleCI to grant full read and write permissions - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Fetch all the tags - - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - - name: Cache deps - id: restore-deps - uses: actions/cache@v3 - with: - path: ${{ env.pythonLocation }}${{ matrix.site-packages }} - key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} - - - name: Cache release - id: restore-release - uses: actions/cache@v3 - with: - path: dist - key: release-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} - - - name: Upload a Python package to PyPi - run: make publish - - - name: Publish a git tag - run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" - - - name: Update doc run: | - curl -X POST --header "Content-Type: application/json" -d '{"branch":"master"}' https://circleci.com/api/v1.1/project/github/openfisca/openfisca-doc/build?circle-token=${{ secrets.CIRCLECI_V1_OPENFISCADOC_TOKEN }} - - publish-to-conda: - strategy: - fail-fast: false - matrix: - os: [ubuntu-20.04] - numpy: [1.20.3] - python: [3.7.9] - runs-on: ${{ matrix.os }} - name: publish-to-conda-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} - needs: [ deploy ] - - steps: - - uses: conda-incubator/setup-miniconda@v2 - with: - auto-update-conda: true - python-version: ${{ matrix.python }} - channels: conda-forge - activate-environment: true - - - uses: actions/checkout@v3 - with: - fetch-depth: 0 # Fetch all the tags - - - name: Update meta.yaml - run: | - python3 -m pip install requests argparse - # Sleep to allow PyPi to update its API - sleep 60 - python3 .github/get_pypi_info.py -p OpenFisca-Core - - - name: Conda Config - run: | - conda install conda-build anaconda-client - conda info - conda config --set anaconda_upload yes - - - name: Conda build - run: conda build -c conda-forge --token ${{ secrets.ANACONDA_TOKEN }} --user openfisca .conda + ${{ matrix.activate }} + make install-test clean build +# ls -al venv/bin + ls -al venv/lib/python3.8/ +# ls -al venv\Scripts +# ls -al venv\lib +# +# test-core: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-20.04, windows-latest] +# numpy: [1.20.3] +# python: [3.8.10, 3.7.9] +# include: +# - os: ubuntu-20.04 +# bin: /bin/ +# - os: ubuntu-20.04 +# python: 3.8.10 +# site-packages: /lib/python3.8/site-packages/ +# - os: ubuntu-20.04 +# python: 3.7.9 +# site-packages: /lib/python3.7/site-packages/ +# - os: windows-latest +# bin: \scripts\ +# site-packages: \lib\site-packages\ +# runs-on: ${{ matrix.os }} +# name: test-core-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# needs: [ build ] +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# TERM: xterm-256color # To colorize output of make tasks. +# +# steps: +# - uses: actions/checkout@v3 +# +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python }} +# +# - name: Use zstd for faster cache restore +# if: ${{ matrix.os == 'windows-latest' }} +# shell: cmd +# run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" +# +# - name: Cache deps +# id: restore-deps +# uses: actions/cache@v3 +# with: +# path: ${{ env.pythonLocation }}${{ matrix.site-packages }} +# key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} +# +# - name: Cache build +# id: restore-build +# uses: actions/cache@v3 +# with: +# path: | +# ${{ env.PKG_CONFIG_PATH }} +# ${{ env.pythonLocation }}${{ matrix.bin }}openfisca +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api +# key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} +# +# - name: Run openfisca-core tests +# run: make install-test test-core +# +# - name: Submit coverage to Coveralls +# run: python -m coveralls --service=github +# +# test-country-template: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-20.04, windows-latest] +# numpy: [1.20.3] +# python: [3.8.10, 3.7.9] +# include: +# - os: ubuntu-20.04 +# bin: /bin/ +# - os: ubuntu-20.04 +# python: 3.8.10 +# site-packages: /lib/python3.8/site-packages/ +# - os: ubuntu-20.04 +# python: 3.7.9 +# site-packages: /lib/python3.7/site-packages/ +# - os: windows-latest +# bin: \scripts\ +# site-packages: \lib\site-packages\ +# runs-on: ${{ matrix.os }} +# name: test-country-template-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# needs: [ build ] +# env: +# TERM: xterm-256color +# +# steps: +# - uses: actions/checkout@v3 +# +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python }} +# +# - name: Cache deps +# id: restore-deps +# uses: actions/cache@v3 +# with: +# path: ${{ env.pythonLocation }}${{ matrix.site-packages }} +# key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} +# +# - name: Cache build +# id: restore-build +# uses: actions/cache@v3 +# with: +# path: | +# ${{ env.PKG_CONFIG_PATH }} +# ${{ env.pythonLocation }}${{ matrix.bin }}openfisca +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api +# key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} +# +# - name: Run Country Template tests +# run: make install-test test-country +# +# test-extension-template: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-20.04, windows-latest] +# numpy: [1.20.3] +# python: [3.8.10, 3.7.9] +# include: +# - os: ubuntu-20.04 +# bin: /bin/ +# - os: ubuntu-20.04 +# python: 3.8.10 +# site-packages: /lib/python3.8/site-packages/ +# - os: ubuntu-20.04 +# python: 3.7.9 +# site-packages: /lib/python3.7/site-packages/ +# - os: windows-latest +# bin: \scripts\ +# site-packages: \lib\site-packages\ +# runs-on: ${{ matrix.os }} +# name: test-extension-template-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# needs: [ build ] +# env: +# TERM: xterm-256color +# +# steps: +# - uses: actions/checkout@v3 +# +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python }} +# +# - name: Cache deps +# id: restore-deps +# uses: actions/cache@v3 +# with: +# path: ${{ env.pythonLocation }}${{ matrix.site-packages }} +# key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} +# +# - name: Cache build +# id: restore-build +# uses: actions/cache@v3 +# with: +# path: | +# ${{ env.PKG_CONFIG_PATH }} +# ${{ env.pythonLocation }}${{ matrix.bin }}openfisca +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api +# key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} +# +# - name: Run Extension Template tests +# run: make install-test test-extension +# +# lint-files: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-20.04, windows-latest] +# numpy: [1.20.3] +# python: [3.8.10, 3.7.9] +# include: +# - os: ubuntu-20.04 +# bin: /bin/ +# - os: ubuntu-20.04 +# python: 3.8.10 +# site-packages: /lib/python3.8/site-packages/ +# - os: ubuntu-20.04 +# python: 3.7.9 +# site-packages: /lib/python3.7/site-packages/ +# - os: windows-latest +# bin: \scripts\ +# site-packages: \lib\site-packages\ +# runs-on: ${{ matrix.os }} +# name: lint-files-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# needs: [ build ] +# env: +# TERM: xterm-256color +# +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 # Fetch all the tags +# +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python }} +# +# - name: Use zstd for faster cache restore +# if: ${{ matrix.os == 'windows-latest' }} +# shell: cmd +# run: echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" +# +# - name: Cache deps +# id: restore-deps +# uses: actions/cache@v3 +# with: +# path: ${{ env.pythonLocation }}${{ matrix.site-packages }} +# key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} +# +# - name: Cache build +# id: restore-build +# uses: actions/cache@v3 +# with: +# path: | +# ${{ env.PKG_CONFIG_PATH }} +# ${{ env.pythonLocation }}${{ matrix.bin }}openfisca +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_core +# ${{ env.pythonLocation }}${{ matrix.site-packages }}openfisca_web_api +# key: build-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} +# +# - name: Run linters +# run: make clean lint +# +# check-version: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-20.04] +# numpy: [1.20.3] +# python: [3.8.10] +# runs-on: ${{ matrix.os }} +# name: check-version-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# needs: [ build ] # Last job to run +# +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 # Fetch all the tags +# +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python }} +# +# - name: Check version number has been properly updated +# run: "${GITHUB_WORKSPACE}/.github/is-version-number-acceptable.sh" +# +# # GitHub Actions does not have a halt job option, to stop from deploying if no functional changes were found. +# # We build a separate job to substitute the halt option. +# # The `deploy` job is dependent on the output of the `check-for-functional-changes`job. +# check-for-functional-changes: +# strategy: +# fail-fast: true +# matrix: +# os: [ubuntu-20.04] +# numpy: [1.20.3] +# python: [3.8.10] +# runs-on: ${{ matrix.os }} +# name: check-for-functional-changes-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# if: github.ref == 'refs/heads/master' # Only triggered for the `master` branch +# needs: [ check-version ] +# outputs: +# status: ${{ steps.stop-early.outputs.status }} +# +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 # Fetch all the tags +# +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python }} +# +# - id: stop-early +# run: if "${GITHUB_WORKSPACE}/.github/has-functional-changes.sh" ; then echo "::set-output name=status::success" ; fi # The `check-for-functional-changes` job should always succeed regardless of the `has-functional-changes` script's exit code. Consequently, we do not use that exit code to trigger deploy, but rather a dedicated output variable `status`, to avoid a job failure if the exit code is different from 0. Conversely, if the job fails the entire workflow would be marked as `failed` which is disturbing for contributors. +# +# deploy: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-20.04] +# numpy: [1.20.3] +# python: [3.8.10] +# include: +# - os: ubuntu-20.04 +# python: 3.8.10 +# site-packages: /lib/python3.8/site-packages/ +# runs-on: ${{ matrix.os }} +# name: deploy-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# needs: [ check-for-functional-changes ] +# if: needs.check-for-functional-changes.outputs.status == 'success' +# env: +# PYPI_USERNAME: openfisca-bot +# PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} +# CIRCLE_TOKEN: ${{ secrets.CIRCLECI_V1_OPENFISCADOC_TOKEN }} # Personal API token created in CircleCI to grant full read and write permissions +# +# steps: +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 # Fetch all the tags +# +# - name: Set up Python +# uses: actions/setup-python@v4 +# with: +# python-version: ${{ matrix.python }} +# +# - name: Cache deps +# id: restore-deps +# uses: actions/cache@v3 +# with: +# path: ${{ env.pythonLocation }}${{ matrix.site-packages }} +# key: deps-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }} +# +# - name: Cache release +# id: restore-release +# uses: actions/cache@v3 +# with: +# path: dist +# key: release-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }}-${{ hashFiles('setup.py') }}-${{ github.sha }} +# +# - name: Upload a Python package to PyPi +# run: make publish +# +# - name: Publish a git tag +# run: "${GITHUB_WORKSPACE}/.github/publish-git-tag.sh" +# +# - name: Update doc +# run: | +# curl -X POST --header "Content-Type: application/json" -d '{"branch":"master"}' https://circleci.com/api/v1.1/project/github/openfisca/openfisca-doc/build?circle-token=${{ secrets.CIRCLECI_V1_OPENFISCADOC_TOKEN }} +# +# publish-to-conda: +# strategy: +# fail-fast: false +# matrix: +# os: [ubuntu-20.04] +# numpy: [1.20.3] +# python: [3.7.9] +# runs-on: ${{ matrix.os }} +# name: publish-to-conda-${{ matrix.os }}-${{ matrix.numpy }}-${{ matrix.python }} +# needs: [ deploy ] +# +# steps: +# - uses: conda-incubator/setup-miniconda@v2 +# with: +# auto-update-conda: true +# python-version: ${{ matrix.python }} +# channels: conda-forge +# activate-environment: true +# +# - uses: actions/checkout@v3 +# with: +# fetch-depth: 0 # Fetch all the tags +# +# - name: Update meta.yaml +# run: | +# python3 -m pip install requests argparse +# # Sleep to allow PyPi to update its API +# sleep 60 +# python3 .github/get_pypi_info.py -p OpenFisca-Core +# +# - name: Conda Config +# run: | +# conda install conda-build anaconda-client +# conda info +# conda config --set anaconda_upload yes +# +# - name: Conda build +# run: conda build -c conda-forge --token ${{ secrets.ANACONDA_TOKEN }} --user openfisca .conda diff --git a/openfisca_tasks/install.mk b/openfisca_tasks/install.mk index be4399f0da..24357e43ab 100644 --- a/openfisca_tasks/install.mk +++ b/openfisca_tasks/install.mk @@ -1,19 +1,19 @@ ## Uninstall project's dependencies. uninstall: @$(call print_help,$@:) - pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs pip uninstall -y + @python -m pip freeze | grep -v "^-e" | sed "s/@.*//" | xargs python -m pip uninstall -y @$(call print_pass,$@:) ## Install project's overall dependencies install-deps: @$(call print_help,$@:) - pip install --upgrade pip build wheel + @python -m pip install --upgrade pip build wheel @$(call print_pass,$@:) ## Install project's development dependencies. install-edit: @$(call print_help,$@:) - pip install --upgrade --editable ".[dev]" + @python -m pip install --upgrade --editable ".[dev]" @$(call print_pass,$@:) ## Delete builds and compiled python files. diff --git a/openfisca_tasks/publish.mk b/openfisca_tasks/publish.mk index 8fa8869fde..b0741b9549 100644 --- a/openfisca_tasks/publish.mk +++ b/openfisca_tasks/publish.mk @@ -4,7 +4,7 @@ install-dist: @$(call print_help,$@:) @python setup.py egg_info - pip install $$(grep -v "^\[" *.egg-info/requires.txt) + @python -m pip install $$(grep -v "^\[" *.egg-info/requires.txt) @$(call print_pass,$@:) ## Build & install openfisca-core for deployment and publishing. @@ -13,8 +13,8 @@ build: @## of openfisca-core, the same we put in the hands of users and reusers. @$(call print_help,$@:) @python -m build - pip uninstall --yes openfisca-core - @find dist -name "*.whl" -exec pip install --no-deps {} \; + @python -m pip uninstall --yes openfisca-core + @find dist -name "*.whl" -exec python -m pip install --no-deps {} \; @$(call print_pass,$@:) ## Upload to PyPi. diff --git a/openfisca_tasks/test_code.mk b/openfisca_tasks/test_code.mk index d85dde29a2..375abbbb18 100644 --- a/openfisca_tasks/test_code.mk +++ b/openfisca_tasks/test_code.mk @@ -19,8 +19,8 @@ install: install-deps install-edit install-test ## Enable regression testing with template repositories. install-test: @$(call print_help,$@:) - pip install --upgrade --no-deps openfisca-country-template - pip install --upgrade --no-deps openfisca-extension-template + @python -m pip install --upgrade --no-deps openfisca-country-template + @python -m pip install --upgrade --no-deps openfisca-extension-template @$(call print_pass,$@:) ## Run openfisca-core & country/extension template tests. @@ -55,7 +55,7 @@ test-core: $(shell git ls-files "*test_*.py") test-country: @$(call print_help,$@:) @PYTEST_ADDOPTS="$${PYTEST_ADDOPTS} ${pytest_args}" \ - openfisca test \ + python -m ${openfisca} test \ ${country_tests} \ --country-package openfisca_country_template \ ${openfisca_args} @@ -65,7 +65,7 @@ test-country: test-extension: @$(call print_help,$@:) @PYTEST_ADDOPTS="$${PYTEST_ADDOPTS} ${pytest_args}" \ - openfisca test \ + python -m ${openfisca} test \ ${extension_tests} \ --country-package openfisca_country_template \ --extensions openfisca_extension_template \