Skip to content

Commit 406cf6b

Browse files
authored
build: Convert to poetry (#240)
1 parent 59b8827 commit 406cf6b

30 files changed

+273
-3376
lines changed

.github/actions/build-docs/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Build Documentation
2+
description: 'Build Documentation.'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Build Documentation
8+
shell: bash
9+
run: make docs

.github/actions/build/action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: Build distribution files
2+
description: 'Build distribution files'
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Build distribution files
8+
shell: bash
9+
run: poetry build

.github/actions/publish/action.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,6 @@ inputs:
1111
runs:
1212
using: composite
1313
steps:
14-
- name: Set up Python 3.11
15-
uses: actions/setup-python@v4
16-
with:
17-
python-version: 3.11
18-
19-
- name: Install dependencies
20-
shell: bash
21-
run: |
22-
pip install -r requirements.txt
23-
pip install wheel
24-
25-
- name: Building publishable packages
26-
shell: bash
27-
run: python setup.py sdist bdist_wheel
28-
2914
- name: Publish package distributions to PyPI
3015
uses: pypa/gh-action-pypi-publish@release/v1
3116
if: ${{ inputs.dry_run == 'false' }}

.github/workflows/ci.yml

Lines changed: 26 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -39,54 +39,45 @@ jobs:
3939
with:
4040
python-version: ${{ matrix.python-version }}
4141

42-
- name: Install requirements
43-
run: |
44-
pipx install virtualenv
45-
pip install -r test-requirements.txt
46-
pip install -r test-filesource-optional-requirements.txt
47-
pip install -r consul-requirements.txt
48-
python setup.py install
49-
pip freeze
42+
- name: Install poetry
43+
run: pipx install poetry
5044

51-
- name: Run tests
52-
run: pytest -s testing -W error::SyntaxWarning
45+
- uses: ./.github/actions/build
46+
- uses: ./.github/actions/build-docs
5347

54-
- name: Test packaging
55-
run: |
56-
sudo rm -rf dist *.egg-info
57-
./test-packaging/test-packaging.sh
48+
- name: Run tests
49+
run: make test
5850

5951
- name: Verify typehints
6052
run: make lint
6153

62-
- name: Verify docs can be successfully built
63-
run: make docs
54+
#
55+
# SSE contract tests
56+
#
6457

65-
- name: build SSE contract test service
58+
- name: install sse contract test dependencies
6659
if: ${{ matrix.python-version != 3.7 }}
67-
run: |
68-
cd sse-contract-tests
69-
make build-test-service
60+
run: make install-sse-contract-tests-deps
7061

71-
- name: start SSE contract test service
62+
- name: start sse contract test service
7263
if: ${{ matrix.python-version != 3.7 }}
73-
run: |
74-
cd sse-contract-tests
75-
make start-test-service &
64+
run: make start-sse-contract-test-service-bg
7665

77-
- name: run SSE contract tests
66+
- name: run sse contract tests
7867
if: ${{ matrix.python-version != 3.7 }}
79-
run: |
80-
cd sse-contract-tests
81-
make run-contract-tests
68+
run: make run-sse-contract-tests
69+
70+
#
71+
# SDK contract tests
72+
#
8273

83-
- name: Build contract tests
74+
- name: install contract test dependencies
8475
if: ${{ matrix.python-version != 3.7 }}
85-
run: make build-contract-tests
76+
run: make install-contract-tests-deps
8677

87-
- name: Start contract test service
78+
- name: start contract test service
8879
if: ${{ matrix.python-version != 3.7 }}
89-
run: make start-contract-test-service &
80+
run: make start-contract-test-service-bg
9081

9182
- name: run contract tests
9283
if: ${{ matrix.python-version != 3.7 }}
@@ -143,11 +134,8 @@ jobs:
143134
144135
- name: Install requirements
145136
run: |
146-
pip install -r test-requirements.txt
147-
pip install -r test-filesource-optional-requirements.txt
148-
pip install -r consul-requirements.txt
149-
python setup.py install
150-
pip freeze
137+
pipx install poetry
138+
poetry install --all-extras
151139
152140
- name: Run tests
153-
run: pytest -s testing -W error::SyntaxWarning
141+
run: make test

.github/workflows/manual-publish.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,22 @@ jobs:
1717
steps:
1818
- uses: actions/checkout@v4
1919

20+
- uses: actions/setup-python@v4
21+
with:
22+
python-version: 3.7
23+
24+
- name: Install poetry
25+
run: pipx install poetry
26+
2027
- uses: launchdarkly/gh-actions/actions/[email protected]
2128
name: 'Get PyPI token'
2229
with:
2330
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
2431
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
2532

26-
- id: publish
27-
name: Publish Package
28-
uses: ./.github/actions/publish
33+
- uses: ./.github/actions/build
34+
35+
- uses: ./.github/actions/publish
2936
with:
3037
token: ${{env.PYPI_AUTH_TOKEN}}
3138
dry_run: ${{ inputs.dry_run }}

.github/workflows/release-please.yml

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,29 @@ jobs:
2424
with:
2525
fetch-depth: 0 # If you only need the current version keep this.
2626

27+
- uses: actions/setup-python@v4
28+
if: ${{ steps.release.outputs.releases_created }}
29+
with:
30+
python-version: 3.7
31+
32+
- name: Install poetry
33+
if: ${{ steps.release.outputs.releases_created }}
34+
run: pipx install poetry
35+
2736
- uses: launchdarkly/gh-actions/actions/[email protected]
2837
if: ${{ steps.release.outputs.releases_created }}
2938
name: 'Get PyPI token'
3039
with:
3140
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
3241
ssm_parameter_pairs: '/production/common/releasing/pypi/token = PYPI_AUTH_TOKEN'
3342

34-
- id: publish
35-
name: Publish Package
36-
uses: ./.github/actions/publish
43+
- uses: ./.github/actions/build
44+
if: ${{ steps.release.outputs.releases_created }}
45+
46+
- uses: ./.github/actions/build-docs
47+
if: ${{ steps.release.outputs.releases_created }}
48+
49+
- uses: ./.github/actions/publish
3750
if: ${{ steps.release.outputs.releases_created }}
3851
with:
3952
token: ${{env.PYPI_AUTH_TOKEN}}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ __pycache__/
1010
.Python
1111
env/
1212
build/
13+
!.github/actions/build/
1314
develop-eggs/
1415
dist/
1516
downloads/
@@ -70,3 +71,6 @@ test-packaging-venv
7071

7172
.vscode/
7273
.python-version
74+
75+
# Poetry
76+
poetry.lock

.readthedocs.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ version: 2
33
build:
44
os: "ubuntu-22.04"
55
tools:
6-
python: "3.7"
7-
8-
python:
9-
install:
10-
- requirements: docs/requirements.txt
11-
- requirements: requirements.txt
6+
python: "3.10"
7+
jobs:
8+
post_create_environment:
9+
- pip install poetry
10+
- poetry config virtualenvs.create false
11+
post_install:
12+
- poetry install --with docs
1213

1314
sphinx:
1415
builder: html

CONTRIBUTING.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,23 @@ We encourage pull requests and other contributions from the community. Before su
1414

1515
### Setup
1616

17-
It's advisable to use [`virtualenv`](https://virtualenv.pypa.io/) to create a development environment within the project directory:
17+
This project is built using [poetry](https://python-poetry.org/). To learn more about the basics of working with this tool, read [Poetry's basic usage guide](https://python-poetry.org/docs/basic-usage/).
18+
19+
To begin development, active the poetry shell and ensure your dependencies are installed.
1820

1921
```
20-
mkvirtualenv python-server-sdk
21-
source ~/.virtualenvs/python-server-sdk/bin/activate
22+
poetry shell
23+
poetry install
2224
```
2325

24-
To install the runtime and test requirements:
26+
This library defines several extra dependencies to optionally enhance the SDK's capabilities. Use the following commands to install one or more of the available extras.
2527

2628
```
27-
pip install -r requirements.txt
28-
pip install -r test-requirements.txt
29+
poetry install --extras "redis consul dynamodb test-filesource"
30+
poetry install -E redis -E consul -E dynamodb -E test-filesource
31+
poetry install --all-extras
2932
```
3033

31-
The additional requirements files `consul-requirements.txt`, `dynamodb-requirements.txt`, `redis-requirements.txt`, and `test-filesource-optional-requirements.txt` can also be installed if you need to test the corresponding features.
32-
3334
### Testing
3435

3536
To run all unit tests except for the database integrations:

MANIFEST.in

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

0 commit comments

Comments
 (0)