Skip to content

Commit 2bf0e6b

Browse files
committed
fixed bdist_egg and bdist_wheel support
1 parent ef8fef1 commit 2bf0e6b

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

CHANGES.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGES
44
0.4 (2017-03-xx)
55
----------------
66

7+
- Fixed bdist_egg and bdist_wheel support
8+
79
- Use absolute path to cargo manifest
810

911
- Enable debug builds for inplace builds, otherwise build release

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ RustExtension
5252

5353
You can define rust extension with `RustExtension` class:
5454

55-
*RustExtension*(name, path, args=None, features=None, rust_version=None, quiet=False, debug=False)
55+
RustExtension(name, path, args=None, features=None, rust_version=None, quiet=False, debug=False)
5656

5757
The class for creating rust extensions.
5858

@@ -70,4 +70,6 @@ You can define rust extension with `RustExtension` class:
7070

7171
:param bool quiet: Does not echo cargo's output. default is False
7272

73-
:param bool debug: Controls whether --debug or --release is passed to cargo.
73+
:param bool debug: Controls whether --debug or --release is passed to cargo. If set to
74+
None then build type is auto-detect. Inplace build is debug build
75+
otherwise release. Default: None

setuptools_rust/patch.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from distutils.command.install import install
2+
from distutils.dist import Distribution as DistDistribution
13
from setuptools.dist import Distribution
24

35

@@ -18,10 +20,33 @@ def get_command_class(self, command):
1820
Distribution.get_command_class = get_command_class
1921

2022
# use custom has_ext_modules
21-
Distribution.orig_has_ext_modules = Distribution.has_ext_modules
23+
DistDistribution.orig_has_ext_modules = DistDistribution.has_ext_modules
2224

2325
def has_ext_modules(self):
2426
return (self.ext_modules and len(self.ext_modules) > 0 or
2527
self.rust_extensions and len(self.rust_extensions) > 0)
2628

27-
Distribution.has_ext_modules = has_ext_modules
29+
DistDistribution.has_ext_modules = has_ext_modules
30+
31+
# this is required because, install directly access distribution's
32+
# ext_modules attr to check if dist has ext modules
33+
install.orig_finalize_options = install.finalize_options
34+
35+
def finalize_options(self):
36+
ext_modules = self.distribution.ext_modules
37+
38+
# all ext modules
39+
mods = []
40+
if self.distribution.ext_modules:
41+
mods.extend(self.distribution.ext_modules)
42+
if self.distribution.rust_extensions:
43+
mods.extend(self.distribution.rust_extensions)
44+
45+
self.distribution.ext_modules = mods
46+
47+
self.orig_finalize_options()
48+
49+
# restore ext_modules
50+
self.distribution.ext_modules = ext_modules
51+
52+
install.finalize_options = finalize_options

0 commit comments

Comments
 (0)