8000 Initial preparation to add support for poetry · dhvcc/setup-python@18c67b4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 18c67b4

Browse files
committed
Initial preparation to add support for poetry
1 parent 6c048c7 commit 18c67b4

File tree

3 files changed

+41
-6
lines changed

3 files changed

+41
-6
lines changed

.github/workflows/e2e-cache.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,26 @@ jobs:
5252
- name: Install dependencies
5353
run: pipenv install numpy
5454

55+
python-poetry-dependencies-caching:
56+
name: Test poetry (Python ${{ matrix.python-version}}, ${{ matrix.os }})
57+
runs-on: ${{ matrix.os }}
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
os: [ubuntu-latest, windows-latest, macos-latest]
62+
python-version: ['3.7', '3.8', '3.9', 'pypy-3.7-v7.3.5', 'pypy-3.7-v7.x']
63+
steps:
64+
- uses: actions/checkout@v2
65+
- name: Install poetry
66+
run: pipx install poetry
67+
- name: Setup Python
68+
uses: ./
69+
with:
70+
python-version: ${{ matrix.python-version }}
71+
cache: 'poetry'
72+
- name: Install dependencies
73+
run: poetry add flake8
74+
5575
python-pip-dependencies-caching-path:
5676
name: Test pip (Python ${{ matrix.python-version}}, ${{ matrix.os }})
5777
runs-on: ${{ matrix.os }}

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This action sets up a Python environment for use in actions by:
99
- optionally installing and adding to PATH a version of Python that is already installed in the tools cache.
1010
- downloading, installing and adding to PATH an available version of Python from GitHub Releases ([actions/python-versions](https://github.com/actions/python-versions/releases)) if a specific version is not available in the tools cache.
1111
- failing if a specific version of Python is not preinstalled or available for download.
12-
- optionally caching dependencies for pip and pipenv.
12+
- optionally caching dependencies for pip, pipenv and poetry.
1313
- registering problem matchers for error output.
1414

1515
# What's new
@@ -19,7 +19,7 @@ This action sets up a Python environment for use in actions by:
1919
- Automatic setup and download of Python packages if using a self-hosted runner.
2020
- Support for pre-release versions of Python.
2121
- Support for installing any version of PyPy on-flight
22-
- Support for built-in caching of pip and pipenv dependencies
22+
- Support for built-in caching of pip, pipenv and poetry dependencies
2323

2424
# Usage
2525

@@ -209,18 +209,19 @@ pypy-3.7-nightly # Python 3.7 and nightly PyPy
209209
210210
# Caching packages dependencies
211211
212-
The action has built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip` and `pipenv`. The `cache` input is optional, and caching is turned off by default.
212+
The action has built-in functionality for caching and restoring dependencies. It uses [actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under the hood for caching dependencies but requires less configuration settings. Supported package managers are `pip`, `pipenv` and `poetry`. The `cache` input is optional, and caching is turned off by default.
213213
214-
The action defaults to searching for a dependency file (`requirements.txt` for pip or `Pipfile.lock` for pipenv) in the repository, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases where multiple dependency files are used, they are located in different subdirectories or different files for the hash want to be used.
214+
The action defaults to searching for a dependency file (`requirements.txt` for pip, `Pipfile.lock` for pipenv or `poetry.lock` for poetry) in the repository, and uses its hash as a part of the cache key. Use `cache-dependency-path` for cases where multiple dependency files are used, they are located in different subdirectories or different files for the hash want to be used.
215215
216216
- For pip, the action will cache global cache directory
217217
- For pipenv, the action will cache virtualenv directory
218+
- For poetry, the action will cache virtualenv directory
218219
219220
**Please Note:** Restored cache will not be used if the requirements.txt file is not updated for a long time and a newer version of the dependency is available that can lead to an increase in total build time.
220221
221222
The requirements file format allows to specify dependency versions using logical operators (for example chardet>=3.0.4) or specify dependencies without any versions. In this case the pip install -r requirements.txt command will always try to install the latest available package version. To be sure that the cache will be used, please stick to a specific dependency version and update it manually if necessary.
222223
223-
**Caching pip dependencies:**
224+
**Caching pip dependencies:**
224225
225226
```yaml
226227
steps:
@@ -245,6 +246,20 @@ steps:
245246
- run: pipenv install
246247
```
247248
249+
**Caching poetry dependencies:**
250+
```yaml
251+
steps:
252+
- uses: actions/checkout@v2
253+
- name: Install poetry
254+
run: pipx install poetry
255+
- uses: actions/setup-python@v2
256+
with:
257+
python-version: '3.9'
258+
cache: 'poetry'
259+
- run: poetry install
260+
- run: poetry run pytest
261+
```
262+
248263
**Using wildcard patterns to cache dependencies**
249264
```yaml
250265
steps:

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ inputs:
77
description: "Version range or exact version of a Python version to use, using SemVer's version range syntax."
88
default: '3.x'
99
cache:
10-
description: 'Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv.'
10+
description: 'Used to specify a package manager for caching in the default directory. Supported values: pip, pipenv, poetry.'
1111
required: false
1212
architecture:
1313
description: 'The target architecture (x86, x64) of the Python interpreter.'

0 commit comments

Comments
 (0)
0