-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate this to use slightly more constrainted monkeypatching
The primary benefit of this is that it'll work when you have a single project using both setuptools-rust as well as cffi.
- Loading branch information
Showing
5 changed files
with
52 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from distutils import log | ||
from distutils.command.check import check | ||
from distutils.command.clean import clean | ||
|
||
from setuptools.command.build_ext import build_ext | ||
|
||
|
||
def add_rust_extension(dist, rust_extension): | ||
build_ext_base_class = dist.cmdclass.get('build_ext', build_ext) | ||
|
||
class build_ext_rust_extension(build_ext_base_class): | ||
def run(self): | ||
if self.distribution.rust_extensions: | ||
log.info("running build_rust") | ||
build_rust = self.get_finalized_command("build_rust") | ||
build_rust.inplace = self.inplace | ||
build_rust.run() | ||
|
||
build_ext_base_class.run(self) | ||
dist.cmdclass['build_ext'] = build_ext_rust_extension | ||
|
||
clean_base_class = dist.cmdclass.get('clean', clean) | ||
|
||
class clean_rust_extension(clean_base_class): | ||
def run(self): | ||
clean_base_class.run(self) | ||
if not self.dry_run: | ||
self.run_command("clean_rust") | ||
dist.cmdclass['clean'] = clean_rust_extension | ||
|
||
check_base_class = dist.cmdclass.get('check', check) | ||
|
||
class check_rust_extension(check_base_class): | ||
def run(self): | ||
check_base_class.run(self) | ||
self.run_command("check_rust") | ||
dist.cmdclass["check"] = check_rust_extension | ||
|
||
|
||
def rust_extensions(dist, attr, value): | ||
assert attr == "rust_extensions" | ||
|
||
orig_has_ext_modules = dist.has_ext_modules | ||
dist.has_ext_modules = lambda: ( | ||
orig_has_ext_modules() or bool(dist.rust_extensions) | ||
) | ||
|
||
for rust_extension in value: | ||
add_rust_extension(dist, rust_extension) |