Skip to content

Commit b801118

Browse files
authored
Merge pull request #367 from sisp/use-poetry
Use Poetry for dependency management and packaging
2 parents bf2f13d + 9939ce3 commit b801118

15 files changed

+1495
-207
lines changed

.bumpversion.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ serialize =
1010

1111
[bumpversion:file:openapi_core/__init__.py]
1212

13+
[bumpversion:file:pyproject.toml]
14+
search = version = "{current_version}"
15+
replace = version = "{new_version}"

.github/workflows/build-docs.yml

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,46 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
13-
- name: Set up Python 3.9
14-
uses: actions/setup-python@v2
15-
with:
16-
python-version: 3.9
17-
- name: Install dependencies
18-
run: |
19-
python -m pip install --upgrade pip
20-
pip install -r requirements.txt
21-
pip install -r requirements_dev.txt
22-
pip install -e .
23-
- name: Build documentation
24-
run: |
25-
python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs docs/_build/html -n -W
26-
- uses: actions/upload-artifact@v2
27-
name: Upload docs as artifact
28-
with:
29-
name: docs-html
30-
path: './docs/_build/html'
31-
if-no-files-found: error
12+
- uses: actions/checkout@v2
13+
14+
- name: Set up Python 3.9
15+
uses: actions/setup-python@v2
16+
with:
17+
python-version: 3.9
18+
19+
- name: Get full Python version
20+
id: full-python-version
21+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
22+
23+
- name: Bootstrap poetry
24+
run: |
25+
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y
26+
echo "$HOME/.local/bin" >> $GITHUB_PATH
27+
28+
- name: Configure poetry
29+
run: poetry config virtualenvs.in-project true
30+
31+
- name: Set up cache
32+
uses: actions/cache@v2
33+
id: cache
34+
with:
35+
path: .venv
36+
key: venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
37+
38+
- name: Ensure cache is healthy
39+
if: steps.cache.outputs.cache-hit == 'true'
40+
run: timeout 10s poetry run pip --version || rm -rf .venv
41+
42+
- name: Install dependencies
43+
run: poetry install
44+
45+
- name: Build documentation
46+
run: |
47+
poetry run python -m sphinx -T -b html -d docs/_build/doctrees -D language=en docs docs/_build/html -n -W
48+
49+
- uses: actions/upload-artifact@v2
50+
name: Upload docs as artifact
51+
with:
52+
name: docs-html
53+
path: './docs/_build/html'
54+
if-no-files-found: error

.github/workflows/python-publish.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,29 @@ on:
77
workflow_dispatch:
88
release:
99
types:
10-
- created
10+
- created
1111

1212
jobs:
1313
publish:
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v2
17-
- name: Set up Python
18-
uses: actions/setup-python@v2
19-
with:
20-
python-version: '3.x'
21-
- name: Install dependencies
22-
run: |
23-
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine
25-
- name: Build
26-
run: python setup.py sdist bdist_wheel
27-
- name: Publish wheel
28-
env:
29-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
30-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
31-
run: twine upload dist/*.whl
32-
- name: Publish source
33-
env:
34-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
35-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
36-
run: twine upload dist/*.tar.gz || true
16+
- uses: actions/checkout@v2
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: '3.x'
22+
23+
- name: Bootstrap poetry
24+
run: |
25+
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y
26+
echo "$HOME/.local/bin" >> $GITHUB_PATH
27+
28+
- name: Build
29+
run: poetry build
30+
31+
- name: Publish
32+
env:
33+
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
34+
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
35+
run: poetry publish

.github/workflows/python-test.yml

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,56 @@ jobs:
1717
python-version: [3.6, 3.7, 3.8, 3.9]
1818
fail-fast: false
1919
steps:
20-
- uses: actions/checkout@v2
21-
- name: Set up Python ${{ matrix.python-version }}
22-
uses: actions/setup-python@v2
23-
with:
24-
python-version: ${{ matrix.python-version }}
25-
- name: Install dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install -r requirements.txt
29-
pip install -r requirements_dev.txt
30-
pip install -e .
31-
- name: Test
32-
run: python setup.py test
33-
- name: Upload coverage
34-
uses: codecov/codecov-action@v1
20+
- uses: actions/checkout@v2
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Get full Python version
28+
id: full-python-version
29+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
30+
31+
- name: Bootstrap poetry
32+
run: |
33+
curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y
34+
echo "$HOME/.local/bin" >> $GITHUB_PATH
35+
36+
- name: Configure poetry
37+
run: poetry config virtualenvs.in-project true
38+
39+
- name: Set up cache
40+
uses: actions/cache@v2
41+
id: cache
42+
with:
43+
path: .venv
44+
key: venv-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
45+
46+
- name: Ensure cache is healthy
47+
if: steps.cache.outputs.cache-hit == 'true'
48+
run: timeout 10s poetry run pip --version || rm -rf .venv
49+
50+
- name: Install dependencies
51+
run: poetry install
52+
53+
- name: Test
54+
run: poetry run pytest
55+
56+
- name: Upload coverage
57+
uses: codecov/codecov-action@v1
3558

3659
static-checks:
3760
name: "Static checks"
3861
runs-on: ubuntu-latest
3962
steps:
4063
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
4164
uses: actions/checkout@v2
65+
4266
- name: "Setup Python"
4367
uses: actions/setup-python@v2
4468
with:
4569
python-version: 3.9
70+
4671
- name: "Run static checks"
4772
uses: pre-commit/action@v2.0.3

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,5 @@ ENV/
103103

104104
# Jetbrains project files
105105
.idea/
106+
107+
/reports/

.travis.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ matrix:
1111
allow_failures:
1212
- python: nightly
1313
before_install:
14-
- pip install codecov
15-
- pip install 'py>=1.5.0'
14+
- curl -sL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python - -y
15+
- export PATH=$PATH:$HOME/.local/bin
1616
install:
17-
- pip install -r requirements.txt
18-
- pip install -r requirements_dev.txt
19-
- pip install -e .
17+
- poetry install
2018
script:
21-
- python setup.py test
19+
- poetry run pytest
2220
after_success:
2321
- codecov

CONTRIBUTING.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,45 @@
1+
# Contributor Guide
12

2-
Contributor Guide
3-
=================
3+
## Prerequisites
44

5-
# Static checks
5+
Install [Poetry](https://github.com/python-poetry/poetry) by following the [official installation instructions](https://github.com/python-poetry/poetry#installation). Optionally (but recommended), configure Poetry to create a virtual environment in a folder named `.venv` within the root directory of the project:
66

7-
The project uses static checks using fantastic [pre-commit](https://pre-commit.com/). Every change is checked on CI and if it does not pass the tests it cannot be accepted. If you want to check locally then run following command to install pre-commit:
7+
```bash
8+
poetry config virtualenvs.in-project true
9+
```
10+
11+
## Setup
12+
13+
To create a development environment and install the runtime and development dependencies, run:
814

915
```bash
10-
pip install -r requiremenets_dev.txt
16+
poetry install
1117
```
1218

19+
Then enter the virtual environment created by Poetry:
20+
21+
```bash
22+
poetry shell
23+
```
24+
25+
## Static checks
26+
27+
The project uses static checks using fantastic [pre-commit](https://pre-commit.com/). Every change is checked on CI and if it does not pass the tests it cannot be accepted. If you want to check locally then run following command to install pre-commit.
28+
1329
To turn on pre-commit checks for commit operations in git, enter:
30+
1431
```bash
1532
pre-commit install
1633
```
1734

1835
To run all checks on your staged files, enter:
36+
1937
```bash
2038
pre-commit run
2139
```
2240

2341
To run all checks on all files, enter:
42+
2443
```bash
2544
pre-commit run --all-files
2645
```

MANIFEST.in

Lines changed: 0 additions & 4 deletions
This file was deleted.

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ params:
1212
@echo "Version: ${VERSION}"
1313

1414
dist-build:
15-
@python setup.py bdist_wheel
15+
@poetry build
1616

1717
dist-cleanup:
1818
@rm -rf build dist ${PACKAGE_NAME}.egg-info
1919

2020
dist-upload:
21-
@twine upload dist/*.whl
21+
@poetry publish
2222

2323
test-python:
24-
@python setup.py test
24+
@pytest
2525

2626
test-cache-cleanup:
2727
@rm -rf .pytest_cache

0 commit comments

Comments
 (0)