Skip to content

Commit 49b5d3a

Browse files
authored
fix: use pypa/build to create Python sdists and wheels (#4850)
Using wheel directly generates `whl` files that aren't compliant with https://packaging.python.org/en/latest/specifications/binary-distribution-format/#escaping-and-unicode . Specifically, periods in the distribution name aren't converted to underscores like setuptools would do. When uploading such a wheel to PyPi, you get an email notification from them complaining about it and warning that soon it would be denied. However, running setup.py directly to do create a `bdist_wheel` now produces a deprecation warning. The upstream advice is to use the `pypa/build` module to wrap setuptools, so that's what I implemented here. The Python target no longer depends on `wheel` directly, so I removed it.
1 parent 90915fa commit 49b5d3a

File tree

5 files changed

+13
-21
lines changed

5 files changed

+13
-21
lines changed

packages/jsii-pacmak/lib/targets/python.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,11 @@ export default class Python extends Target {
9595
);
9696

9797
// Actually package up our code, both as a sdist and a wheel for publishing.
98-
await shell(python, ['setup.py', 'sdist', '--dist-dir', outDir], {
98+
await shell(python, ['-m', 'build', '--outdir', outDir, sourceDir], {
9999
cwd: sourceDir,
100100
env,
101+
retry: { maxAttempts: 5 },
101102
});
102-
await shell(
103-
python,
104-
['-m', 'pip', 'wheel', '--no-deps', '--wheel-dir', outDir, sourceDir],
105-
{
106-
cwd: sourceDir,
107-
env,
108-
retry: { maxAttempts: 5 },
109-
},
110-
);
111103
await shell(python, ['-m', 'twine', 'check', path.join(outDir, '*')], {
112104
cwd: sourceDir,
113105
env,

packages/jsii-pacmak/lib/targets/python/requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# package (wheel, sdist), but not declared as build-system dependencies.
55

66
setuptools~=75.3.2 # build-system
7-
wheel~=0.42 # build-system
7+
build~=1.2.2.post1 # build-system
88

99
twine~=6.1.0
1010

packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jsii-pacmak/test/generated-code/__snapshots__/target-python.test.js.snap

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)