Skip to content

Commit 37dd294

Browse files
Handle wheel.bdist_wheel deprecation warning (#463)
* Handle wheel.bdist_wheel deprecation warning * Add relevant type ignore annotations * Remove unused type: ignore annotations * Remove wheel dependency and rely on setuptools providing bdist_wheel * Add temporary workaround for issue 117 of cffi * Further changes to avoid CI errors with CFFI * Ensure recent setuptools is installed to avoid CI error * Fallback to importing bdist_wheel from wheel for type-checking * remove pin * remove pins * CHANGELOG entry --------- Co-authored-by: David Hewitt <[email protected]>
1 parent 4e5f25f commit 37dd294

File tree

18 files changed

+41
-35
lines changed

18 files changed

+41
-35
lines changed

.github/workflows/ci.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
rustup target add aarch64-apple-darwin
121121
rustup target add x86_64-apple-darwin
122122
cd examples/namespace_package
123-
pip install build wheel
123+
pip install build 'setuptools>=70.1'
124124
python -m build --no-isolation
125125
ls -l dist/
126126
pip install --force-reinstall dist/namespace_package*_universal2.whl
@@ -163,7 +163,7 @@ jobs:
163163
set -e
164164
cd examples/rust_with_cffi/
165165
python --version
166-
pip install -U build cffi wheel
166+
pip install -U build cffi 'setuptools>=70.1'
167167
echo -e "[bdist_wheel]\npy_limited_api=cp39" > $DIST_EXTRA_CONFIG
168168
python -m build --no-isolation
169169
ls -la dist/
@@ -180,7 +180,6 @@ jobs:
180180
run: |
181181
set -e
182182
cd examples/
183-
pip install -U wheel
184183
python --version
185184
pip install rust_with_cffi/dist/rust_with_cffi*.whl
186185
python -c "from rust_with_cffi import rust; assert rust.rust_func() == 14"
@@ -235,7 +234,7 @@ jobs:
235234
run: |
236235
cd examples/namespace_package
237236
docker build -t cross-pyo3:aarch64-unknown-linux-gnu .
238-
python -m pip install build wheel
237+
python -m pip install build
239238
echo -e "[bdist_wheel]\nplat_name=manylinux2014_aarch64" > $DIST_EXTRA_CONFIG
240239
python -m build --no-isolation
241240
ls -la dist/
@@ -283,7 +282,7 @@ jobs:
283282
mkdir -p $PYO3_CROSS_LIB_DIR
284283
docker cp -L $(docker create --rm quay.io/pypa/manylinux2014_aarch64:latest):/opt/python/cp38-cp38 /opt/python
285284
cd examples/namespace_package
286-
python -m pip install build wheel
285+
python -m pip install build
287286
echo -e "[bdist_wheel]\nplat_name=manylinux2014_aarch64" > $DIST_EXTRA_CONFIG
288287
python -m build --no-isolation
289288
ls -la dist/
@@ -315,7 +314,7 @@ jobs:
315314
env:
316315
CIBW_BUILD: cp39-*
317316
CIBW_BEFORE_BUILD: >
318-
pip install -U 'pip>=23.2.1' 'setuptools>=68.0.0' 'wheel>=0.41.2' 'auditwheel>=5.4.0'
317+
pip install -U 'pip>=23.2.1' 'setuptools>=70.1.0' 'auditwheel>=5.4.0'
319318
&& pip install -e .
320319
&& pip list
321320
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
@@ -354,7 +353,7 @@ jobs:
354353

355354
- name: Install test dependencies
356355
shell: msys2 {0}
357-
run: python -m pip install --upgrade nox pip wheel
356+
run: python -m pip install --upgrade nox pip
358357

359358
- name: Create libpython symlink
360359
shell: msys2 {0}

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.10.2 (2024-10-01)
4+
### Fixed
5+
- Fix deprecation warning from use of `wheel.bdist_wheel`.
6+
37
## 1.10.1 (2024-08-04)
48
### Fixed
59
- Fix regression in 1.10.0 where editable builds would be built in release mode

examples/hello-world-script/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@nox.session()
99
def test(session: nox.Session):
10-
session.install(SETUPTOOLS_RUST, "wheel")
10+
session.install(SETUPTOOLS_RUST)
1111
# Ensure build uses version of setuptools-rust under development
1212
session.install("--no-build-isolation", ".")
1313
# Test Rust binary

examples/hello-world-script/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools-rust"]
2+
requires = ["setuptools", "setuptools-rust"]
33
build-backend = "setuptools.build_meta"
44

55
[project]

examples/hello-world-setuppy/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@nox.session()
99
def test(session: nox.Session):
10-
session.install(SETUPTOOLS_RUST, "wheel")
10+
session.install(SETUPTOOLS_RUST)
1111
# Ensure build uses version of setuptools-rust under development
1212
session.install("--no-build-isolation", ".")
1313
# Test Rust binary
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools-rust"]
2+
requires = ["setuptools", "setuptools-rust"]
33
build-backend = "setuptools.build_meta"

examples/hello-world/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@nox.session()
99
def test(session: nox.Session):
10-
session.install(SETUPTOOLS_RUST, "wheel", "build", "pytest")
10+
session.install(SETUPTOOLS_RUST, "build", "pytest")
1111
# Ensure build works as intended
1212
session.install("--no-build-isolation", ".")
1313
# Test Rust binary

examples/html-py-ever/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ test_bench_selector_python[/home/david/dev/setuptools-rust/examples/html-py-ever
9696

9797
**building and installing**
9898
```
99-
pip install setuptools-rust setuptools wheel
99+
pip install setuptools-rust setuptools
100100
python3 setup.py install --user
101101
```
102102

examples/html-py-ever/build-wheels.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export PATH="$HOME/.cargo/bin:$PATH"
77
# Compile wheels
88
for PYBIN in /opt/python/cp{37,38,39,310}*/bin; do
99
rm -rf /io/build/
10-
"${PYBIN}/pip" install -U setuptools setuptools-rust wheel
10+
"${PYBIN}/pip" install -U setuptools setuptools-rust
1111
"${PYBIN}/pip" wheel /io/ -w /io/dist/ --no-deps
1212
done
1313

examples/html-py-ever/noxfile.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
@nox.session()
99
def test(session: nox.Session):
10-
session.install(
11-
SETUPTOOLS_RUST, "wheel", "pytest", "pytest-benchmark", "beautifulsoup4"
12-
)
10+
session.install(SETUPTOOLS_RUST, "pytest", "pytest-benchmark", "beautifulsoup4")
1311
# Ensure build uses version of setuptools-rust under development
1412
session.install("--no-build-isolation", ".")
1513
# Test Python package

examples/html-py-ever/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools-rust"]
2+
requires = ["setuptools", "setuptools-rust"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
+1-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
setuptools-rust
2-
setuptools
3-
wheel
2+
setuptools>=70.1.0

examples/namespace_package/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@nox.session()
99
def test(session: nox.Session):
10-
session.install(SETUPTOOLS_RUST, "wheel")
10+
session.install(SETUPTOOLS_RUST)
1111
# Ensure build uses version of setuptools-rust under development
1212
session.install("--no-build-isolation", ".[dev]")
1313
# Test Python package

examples/namespace_package/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "setuptools-rust"]
2+
requires = ["setuptools", "setuptools-rust"]
33
build-backend = "setuptools.build_meta"
44

55
[project]

examples/rust_with_cffi/noxfile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@nox.session()
99
def test(session: nox.Session):
10-
session.install(SETUPTOOLS_RUST, "wheel", "pytest")
10+
session.install(SETUPTOOLS_RUST, "pytest")
1111

1212
try:
1313
session.install("cffi", "--only-binary=cffi")

noxfile.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_examples(session: nox.Session):
1616

1717
@nox.session(name="test-sdist-vendor")
1818
def test_sdist_vendor(session: nox.Session):
19-
session.install(".", "build", "wheel")
19+
session.install(".", "build")
2020
namespace_package = Path(__file__).parent / "examples" / "namespace_package"
2121
os.chdir(namespace_package)
2222
tmp = Path(session.create_tmp())
@@ -79,8 +79,8 @@ def test_crossenv(session: nox.Session):
7979
python3.11 -m crossenv "/opt/python/cp311-cp311/bin/python3" --cc $TARGET_CC --cxx $TARGET_CXX --sysroot $TARGET_SYSROOT --env LIBRARY_PATH= --manylinux manylinux1 /venv
8080
. /venv/bin/activate
8181
82-
build-pip install -U 'pip>=23.2.1' 'setuptools>=68.0.0' 'wheel>=0.41.1' 'build>=1'
83-
cross-pip install -U 'pip>=23.2.1' 'setuptools>=68.0.0' 'wheel>=0.41.1' 'build>=1'
82+
build-pip install -U 'pip>=23.2.1' 'setuptools>=70.1' 'build>=1'
83+
cross-pip install -U 'pip>=23.2.1' 'setuptools>=70.1' 'build>=1'
8484
build-pip install cffi
8585
cross-expose cffi
8686
cross-pip install -e ../../
@@ -171,7 +171,7 @@ def newrun(*args, **kwargs):
171171
examples = Path(os.path.dirname(__file__)).absolute() / "examples"
172172

173173
with patch.object(nox.command, "run", newrun):
174-
session.install(".", "wheel")
174+
session.install(".")
175175

176176
session.install("--no-build-isolation", str(examples / "hello-world"))
177177
session.run("print-hello")

setuptools_rust/build.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@
3737

3838

3939
try:
40-
from wheel.bdist_wheel import bdist_wheel as CommandBdistWheel
41-
except ImportError: # wheel installation might be deferred in PEP 517
42-
from setuptools import Command as CommandBdistWheel
40+
from setuptools.command.bdist_wheel import bdist_wheel as CommandBdistWheel
41+
except ImportError: # old version of setuptools
42+
try:
43+
from wheel.bdist_wheel import bdist_wheel as CommandBdistWheel # type: ignore[no-redef]
44+
except ImportError:
45+
from setuptools import Command as CommandBdistWheel # type: ignore[assignment]
4346

4447

4548
def _check_cargo_supports_crate_type_option() -> bool:
@@ -789,12 +792,12 @@ def _replace_cross_target_dir(path: str, ext: RustExtension, *, quiet: bool) ->
789792
return path.replace(cross_target_dir, local_target_dir)
790793

791794

792-
def _get_bdist_wheel_cmd( # type: ignore[no-any-unimported]
795+
def _get_bdist_wheel_cmd(
793796
dist: Distribution, create: Literal[True, False] = True
794797
) -> Optional[CommandBdistWheel]:
795798
try:
796799
cmd_obj = dist.get_command_obj("bdist_wheel", create=create)
797800
cmd_obj.ensure_finalized() # type: ignore[union-attr]
798-
return cast(CommandBdistWheel, cmd_obj) # type: ignore[no-any-unimported]
801+
return cast(CommandBdistWheel, cmd_obj)
799802
except Exception:
800803
return None

setuptools_rust/setuptools_ext.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
from .extension import Binding, RustBin, RustExtension, Strip
2020

2121
try:
22-
from wheel.bdist_wheel import bdist_wheel
22+
from setuptools.command.bdist_wheel import bdist_wheel
2323
except ImportError:
24-
bdist_wheel = None
24+
try: # old version of setuptools
25+
from wheel.bdist_wheel import bdist_wheel # type: ignore[no-redef]
26+
except ImportError:
27+
bdist_wheel = None # type: ignore[assignment,misc]
2528

2629
if sys.version_info[:2] >= (3, 11):
2730
from tomllib import load as toml_load
@@ -251,7 +254,7 @@ def run(self) -> None:
251254
dist.cmdclass["install_scripts"] = install_scripts_rust_extension
252255

253256
if bdist_wheel is not None:
254-
bdist_wheel_base_class = cast( # type: ignore[no-any-unimported]
257+
bdist_wheel_base_class = cast(
255258
Type[bdist_wheel], dist.cmdclass.get("bdist_wheel", bdist_wheel)
256259
)
257260
bdist_wheel_options = bdist_wheel_base_class.user_options.copy()

0 commit comments

Comments
 (0)