Skip to content

Commit 5be25fe

Browse files
authored
Merge pull request #273 from jameshilliard/build-nowheel
Fix RustBin build without wheel
2 parents cadefb9 + 60c6511 commit 5be25fe

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44
### Changed
55
- Locate cdylib artifacts by handling messages from cargo instead of searching target dir (fixes build on MSYS2). [#267](https://github.com/PyO3/setuptools-rust/pull/267)
6+
- Fix RustBin build without wheel. [#273](https://github.com/PyO3/setuptools-rust/pull/273)
67

78

89
## 1.4.1 (2022-07-05)

setuptools_rust/build.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import glob
44
import json
55
import os
6+
import pkg_resources
67
import platform
78
import shutil
89
import subprocess
@@ -64,12 +65,15 @@ def initialize_options(self) -> None:
6465
self.qbuild = None
6566
self.build_temp = None
6667
self.plat_name = None
68+
self.build_number = None
6769
self.target = os.getenv("CARGO_BUILD_TARGET")
6870
self.cargo = os.getenv("CARGO", "cargo")
6971

7072
def finalize_options(self) -> None:
7173
super().finalize_options()
7274

75+
self.data_dir = self.get_data_dir()
76+
7377
if self.plat_name is None:
7478
self.plat_name = cast( # type: ignore[no-any-unimported]
7579
CommandBuild, self.get_finalized_command("build")
@@ -84,6 +88,18 @@ def finalize_options(self) -> None:
8488
("inplace", "inplace"),
8589
)
8690

91+
if self.build_number is not None and not self.build_number[:1].isdigit():
92+
raise ValueError("Build tag (build-number) must start with a digit.")
93+
94+
def get_data_dir(self) -> str:
95+
components = (
96+
pkg_resources.safe_name(self.distribution.get_name()).replace("-", "_"), # type: ignore[attr-defined]
97+
pkg_resources.safe_version(self.distribution.get_version()).replace("-", "_"), # type: ignore[attr-defined]
98+
)
99+
if self.build_number:
100+
components += (self.build_number,)
101+
return "-".join(components) + ".data"
102+
87103
def run_for_extension(self, ext: RustExtension) -> None:
88104
assert self.plat_name is not None
89105

@@ -329,9 +345,8 @@ def install_extension(
329345
executable_name = module_name
330346
if exe is not None:
331347
executable_name += exe
332-
wheel = self.get_finalized_command("bdist_wheel")
333348
scripts_dir = os.path.join(
334-
build_ext.build_lib, wheel.data_dir, "scripts" # type: ignore[attr-defined]
349+
build_ext.build_lib, self.data_dir, "scripts"
335350
)
336351
os.makedirs(scripts_dir, exist_ok=True)
337352
ext_path = os.path.join(scripts_dir, executable_name)

0 commit comments

Comments
 (0)