File tree Expand file tree Collapse file tree 4 files changed +16
-29
lines changed Expand file tree Collapse file tree 4 files changed +16
-29
lines changed Original file line number Diff line number Diff line change 8080 - name : Install Python dependencies
8181 run : |
8282 pipx install --python ${{ matrix.python-version }} poetry
83+ # This forces poetry to use specific Python version when installing a project.
84+ # Raises error, if this Python version does not match project specific Python constraints.
85+ poetry config virtualenvs.use-poetry-python true
86+ poetry env use ${{ matrix.python-version }}
8387 make install-dev
8488
8589 - name : Run integration tests
Original file line number Diff line number Diff line change 2323 - name : Install Python dependencies
2424 run : |
2525 pipx install --python ${{ matrix.python-version }} poetry
26+ # This forces poetry to use specific Python version when installing a project.
27+ # Raises error, if this Python version does not match project specific Python constraints.
28+ poetry config virtualenvs.use-poetry-python true
29+ poetry env use ${{ matrix.python-version }}
2630 make install-dev
2731
2832 - name : Run lint check
Original file line number Diff line number Diff line change 2323 - name : Install Python dependencies
2424 run : |
2525 pipx install --python ${{ matrix.python-version }} poetry
26+ # This forces poetry to use specific Python version when installing a project.
27+ # Raises error, if this Python version does not match project specific Python constraints.
28+ poetry config virtualenvs.use-poetry-python true
29+ poetry env use ${{ matrix.python-version }}
2630 make install-dev
2731
2832 - name : Run type check
Original file line number Diff line number Diff line change @@ -32,38 +32,13 @@ jobs:
3232 run : |
3333 pip install poetry
3434
35- - name : Check Python version against project requirements
36- shell : python
37- run : |
38- import sys
39- from contextlib import suppress
40- from poetry.core.constraints.version import parse_constraint
41-
42- try:
43- import tomllib
44- except ImportError:
45- import tomli as tomllib
46-
47- config = tomllib.load(open('pyproject.toml', 'rb'))
48- constraints = []
49-
50- with suppress(KeyError):
51- constraints.append(parse_constraint(config['tool']['poetry']['dependencies']['python']))
52- with suppress(KeyError):
53- constraints.append(parse_constraint(config['project']['requires-python']))
54-
55- python_version = parse_constraint('${{ matrix.python-version }}')
56- if not all(con.allows(python_version) for con in constraints):
57- print(f'Python version {str(python_version)} is not allowed by project settings', file=sys.stderr)
58- sys.exit(1)
59-
60- - name : Uninstall global poetry again
61- run : |
62- pip uninstall -y poetry
63-
6435 - name : Install Python dependencies
6536 run : |
6637 pipx install --python ${{ matrix.python-version }} poetry
38+ # This forces poetry to use specific Python version when installing a project.
39+ # Raises error, if this Python version does not match project specific Python constraints.
40+ poetry config virtualenvs.use-poetry-python true
41+ poetry env use ${{ matrix.python-version }}
6742 make install-dev
6843
6944 - name : Run unit tests
You can’t perform that action at this time.
0 commit comments