Skip to content

Commit bc205fa

Browse files
authored
Add pyproject.toml, and stop calling setup.py directly (#629)
**Issue:** For a few years now, we've been seen the occasional deprecation warning about setup.py. Including: ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** and ******************************************************************************** Ensure that any custom bdist_wheel implementation is a subclass of setuptools.command.bdist_wheel.bdist_wheel. By 2025-Oct-15, you need to update your project and remove deprecated calls or your builds will no longer be supported. See pypa/wheel#631 for details. ******************************************************************************** 2025-Oct is on its way, so let's finally do something about it... **Description of changes:** Follow advice from ["Is setup.py deprecated?"](https://packaging.python.org/en/latest/discussions/setup-py-deprecated/) page at packaging.python.org tldr; having a setup.py file **is not** deprecated, but directly invoking `python setup.py` **is** deprecated. - Add [pyproject.toml](https://packaging.python.org/en/latest/specifications/pyproject-toml/) file (the modern way to configure your package) - Move data from `setup.py` -> `pyproject.toml` wherever possible (can't move dynamic stuff, like build steps for C extension) - Move dev dependencies from `requirements-dev.txt` -> `pyproject.toml [project.optional-dependencies]` - Now you call `pip install ".[dev]"`, instead of `pip install -r requirements-dev.txt`. The dev dependencies will be installed by the same command that builds and installs our project. - This change isn't 100% necessary, but seemed like the modern way to do things. It's one less step to set things up on your machine. However, you can't install dependencies without ALSO building/installing the package (we can roll this back if we end up hating it) - Use `python3 -m build` instead of `python3 setup.py sdist bdist_wheel` (the modern way to build a wheel for distribution) - Sadly, [build](https://pypi.org/project/build/) is a non-core package, so might need to be pip installed before using. Fortunately it's been [preinstalled on manylinux images since 2021](https://github.com/pypa/manylinux/blob/6b97f150fc9ede1cb4f25de84a939538a1019a58/docker/build_scripts/requirements3.8.txt#L7), so our Linux release process will be OK. - I updated our MacOS and Windows machines to have `build` installed for all python versions, so our release process should be OK. - STOP calling `pip install --upgrade setuptools` before `pip install .` - Modern pip installs the "build dependencies" declared in `pyproject.toml` (setuptools & wheel) in a special isolated environment before it builds our project. We declared `setuptools>=75.3.1`, so we're guaranteed it will get installed, and be a recent version.
1 parent 94811c4 commit bc205fa

26 files changed

Lines changed: 117 additions & 169 deletions

.builder/actions/aws_crt_python.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ def run(self, env):
3131
env.shell.setenv('AWS_TEST_S3', '1')
3232

3333
actions = [
34+
[self.python, '--version'],
3435
[self.python, '-m', 'pip', 'install', '--upgrade', 'pip'],
35-
[self.python, '-m', 'pip', 'install', '--upgrade', '--requirement', 'requirements-dev.txt'],
3636
Builder.SetupCrossCICrtEnvironment(),
37-
[self.python, '-m', 'pip', 'install', '--verbose', '.'],
37+
[self.python, '-m', 'pip', 'install', '--verbose', '.[dev]'],
3838
# "--failfast" because, given how our leak-detection in tests currently works,
3939
# once one test fails all the rest usually fail too.
4040
[self.python, '-m', 'unittest', 'discover', '--verbose', '--failfast'],

.github/workflows/ci.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,7 @@ jobs:
337337
submodules: true
338338
- name: Run tests
339339
run: |
340-
python3 -m pip install --upgrade --requirement requirements-dev.txt
341-
python3 -m pip install . --verbose
340+
python3 -m pip install ".[dev]" --verbose
342341
python3 -m unittest discover --failfast --verbose
343342
344343
package-source:
@@ -356,22 +355,23 @@ jobs:
356355
submodules: true
357356
- name: Package source + install
358357
run: |
359-
python3 setup.py sdist
358+
python3 -m pip install build
359+
python3 -m build --sdist
360360
cd dist
361361
python3 -m pip install -v awscrt-1.0.0.dev0.tar.gz
362362
python3 -c "import awscrt.io"
363363
364364
# check that docs can still build
365365
check-docs:
366-
runs-on: ubuntu-22.04 # latest
366+
runs-on: ubuntu-22.04 # getting errors from sphinx using ubuntu-24.04, so stuck on 22.04 till we diagnose it
367367
steps:
368368
- uses: actions/checkout@v4
369369
with:
370370
submodules: true
371371
- name: Check docs
372372
run: |
373-
python3 -m pip install -r requirements-dev.txt
374-
python3 -m pip install --verbose .
373+
python3 -m pip install --upgrade pip
374+
python3 -m pip install --verbose ".[dev]"
375375
./scripts/make-docs.py
376376
377377
check-submodules:

.github/workflows/docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
jobs:
1111
update-docs-branch:
12-
runs-on: ubuntu-22.04 # latest
12+
runs-on: ubuntu-22.04 # getting errors from sphinx using ubuntu-24.04, so stuck on 22.04 till we diagnose it
1313
permissions:
1414
contents: write # allow push
1515
steps:
@@ -20,8 +20,8 @@ jobs:
2020

2121
- name: Update docs branch
2222
run: |
23-
python3 -m pip install -r requirements-dev.txt
24-
python3 -m pip install --verbose .
23+
python3 -m pip install --upgrade pip
24+
python3 -m pip install --verbose ".[dev]"
2525
./scripts/make-docs.py
2626
2727
- name: Commit

.github/workflows/lint.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,19 @@ on:
77
- 'docs'
88

99
jobs:
10-
clang-format:
11-
12-
runs-on: ubuntu-24.04 # latest
13-
14-
steps:
15-
- name: Checkout Sources
16-
uses: actions/checkout@v4
17-
18-
- name: clang-format lint
19-
run: |
20-
./format-check.py
21-
22-
autopep8:
10+
lint:
2311
runs-on: ubuntu-24.04 # latest
2412

2513
steps:
2614
- name: Checkout Source
2715
uses: actions/checkout@v4
2816

29-
- name: Build and Test
17+
- name: Format and Check Diff
18+
# run formatting script, which edits files in place
19+
# then do `git diff` to show what changed (if anything)
20+
# then do `git diff --quiet` to fail if anything changed
3021
run: |
31-
python3 -m pip install --upgrade setuptools
32-
python3 -m pip install --upgrade wheel
3322
python3 -m pip install --upgrade autopep8
34-
python3 -m autopep8 --exit-code --diff --recursive awscrt test .builder setup.py
23+
python3 scripts/format-all.py
24+
git diff
25+
git diff --quiet

.lgtm.yml

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

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ git submodule update --init
3232
python3 -m pip install .
3333
```
3434

35-
To use from your Python application, declare `awscrt` as a dependency in your `setup.py` file.
35+
To use from your Python application, declare `awscrt` as a dependency.
3636

3737
### OpenSSL and LibCrypto (Unix only)
3838

codebuild/cd/manylinux-x64-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ phases:
1212
build:
1313
commands:
1414
- echo Build started on `date`
15-
- /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel
15+
- /opt/python/cp38-cp38/bin/python -m build
1616
- auditwheel repair --plat manylinux1_x86_64 dist/awscrt-*cp38-cp38-linux_x86_64.whl
17-
- /opt/python/cp39-cp39/bin/python setup.py sdist bdist_wheel
17+
- /opt/python/cp39-cp39/bin/python -m build
1818
- auditwheel repair --plat manylinux1_x86_64 dist/awscrt-*cp39-cp39-linux_x86_64.whl
1919
# python 3.9 is the last version manylinux1 will ever receive
2020
- cp -r wheelhouse ../dist

codebuild/cd/manylinux-x86-build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ phases:
1212
build:
1313
commands:
1414
- echo Build started on `date`
15-
- /opt/python/cp38-cp38/bin/python setup.py sdist bdist_wheel
15+
- /opt/python/cp38-cp38/bin/python -m build
1616
- auditwheel repair --plat manylinux1_i686 dist/awscrt-*cp38-cp38-linux_i686.whl
17-
- /opt/python/cp39-cp39/bin/python setup.py sdist bdist_wheel
17+
- /opt/python/cp39-cp39/bin/python -m build
1818
- auditwheel repair --plat manylinux1_i686 dist/awscrt-*cp39-cp39-linux_i686.whl
1919
# python 3.9 is the last version manylinux1 will ever receive
2020
- cp -r wheelhouse ../dist

codebuild/cd/publish_to_prod_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ phases:
66
- sudo apt-get update -y
77
- sudo apt-get install python3 python3-pip -y
88
- python3 -m pip install --user --upgrade pip
9-
- python3 -m pip install --user --upgrade twine setuptools wheel boto3 PyOpenSSL six
9+
- python3 -m pip install --user --upgrade twine boto3
1010
pre_build:
1111
commands:
1212
- export CC=gcc

codebuild/cd/publish_to_test_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ phases:
66
- sudo apt-get update -y
77
- sudo apt-get install python3 python3-pip -y
88
- python3 -m pip install --user --upgrade pip
9-
- python3 -m pip install --user --upgrade twine setuptools wheel boto3 PyOpenSSL six
9+
- python3 -m pip install --user --upgrade twine boto3
1010
pre_build:
1111
commands:
1212
- export CC=gcc

0 commit comments

Comments
 (0)