Skip to content

Commit

Permalink
chore(python): ensure virtualenv defaults to Python 3.7 for api and s…
Browse files Browse the repository at this point in the history
…hared-data (#9708)
  • Loading branch information
mcous authored Mar 18, 2022
1 parent 7aa1c7e commit 7edf686
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
5 changes: 4 additions & 1 deletion .github/actions/python/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
project:
description: 'Which project (by subdirectory) to set up'
required: true
python-version:
description: "What Python version to use to create the project's virtual environment"
required: false
runs:
using: 'composite'
steps:
Expand All @@ -18,4 +21,4 @@ runs:
npm install --global [email protected]
pip install pipenv==2021.5.29
- shell: bash
run: 'make -C ${{ inputs.project }} setup'
run: 'make -C ${{ inputs.project }} setup OT_VIRTUALENV_VERSION=${{ inputs.python-version }}'
3 changes: 3 additions & 0 deletions .github/workflows/api-test-lint-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,14 @@ jobs:
- uses: './.github/actions/python/setup'
with:
project: 'api'
python-version: ${{ matrix.python }}
- if: ${{ matrix.with-ot-hardware == 'false' }}
name: Test without opentrons_hardware
run: |
make -C api setup-ot2
make -C api test-ot2
env:
OT_VIRTUALENV_VERSION: ${{ matrix.python }}
- if: ${{ matrix.with-ot-hardware == 'true' }}
name: Test with opentrons_hardware
run: make -C api test
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/shared-data-test-lint-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
- uses: './.github/actions/python/setup'
with:
project: 'shared-data/python'
python-version: ${{ matrix.python }}
- name: 'set complex environment variables'
uses: actions/[email protected]
with:
Expand Down
14 changes: 9 additions & 5 deletions scripts/python.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
# this may be set as an environment variable to select the version of
# python to run if pyenv is not available. it should always be set to
# point to a python3.7
# This environment variable can be used to select a specific
# Python executable to use to run pipenv. Note: pipenv will not
# necessary select this Python to create its virtual environments.
OT_PYTHON ?= python

# This environment variable can be used to tell pipenv which
# Python version to use for a project's virtual environment.
# Defaults to Python 3.7, which is the version that runs on the OT-2.
# https://pipenv.pypa.io/en/latest/basics/#specifying-versions-of-python
OT_VIRTUALENV_VERSION ?= 3.7

pipenv_envvars := $(and $(CI),PIPENV_IGNORE_VIRTUALENVS=1)
pipenv := $(pipenv_envvars) $(OT_PYTHON) -m pipenv
python := $(pipenv) run python
pip := $(pipenv) run pip
pytest := $(pipenv) run py.test


pipenv_opts := --dev
pipenv_opts := --dev $(and $(OT_VIRTUALENV_VERSION),--python $(OT_VIRTUALENV_VERSION))
pipenv_opts += $(and $(CI),--keep-outdated --clear)
wheel_opts := $(if $(and $(or $(CI),$(V),$(VERBOSE)),$(not $(QUIET))),,-q)

Expand Down

0 comments on commit 7edf686

Please sign in to comment.