Skip to content

Commit af8a1c2

Browse files
committed
added native parameter
1 parent baa78ad commit af8a1c2

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
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.8.1 (2017-09-08)
55
------------------
66

7+
- Added `native` parameter
8+
79
- Fix script generation for executables
810

911

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ You can define rust extension with `RustExtension` class:
113113
:param bool script: Generate console script for executable
114114
if `Binding.Exec` is used.
115115

116+
:param bool native: Build extension or executable with "-C target-cpu=native"
117+
116118
:param bool optional: if it is true, a build failure in the extension will not abort the build process,
117119
but instead simply not install the failing extension.
118120

setuptools_rust/build.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ def build_extension(self, ext):
105105
if not quiet:
106106
print(" ".join(args), file=sys.stderr)
107107

108+
if ext.native:
109+
env["RUSTFLAGS"] = "-C target-cpu=native"
110+
108111
# Execute cargo
109112
try:
110113
output = subprocess.check_output(args, env=env)

setuptools_rust/extension.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class RustExtension:
4444
* Strip.All - strip all symbols
4545
script : bool
4646
Generate console script for executable if `Binding.Exec` is used.
47+
native : bool
48+
Build extension or executable with "target-cpu=native"
4749
optional : bool
4850
if it is true, a build failure in the extension will not abort the
4951
build process, but instead simply not install the failing extension.
@@ -52,7 +54,7 @@ class RustExtension:
5254
def __init__(self, target, path,
5355
args=None, features=None, rust_version=None,
5456
quiet=False, debug=None, binding=Binding.PyO3,
55-
strip=Strip.No, script=False, optional=False):
57+
strip=Strip.No, script=False, native=False, optional=False):
5658
if isinstance(target, dict):
5759
name = '; '.join('%s=%s' % (key, val)
5860
for key, val in target.items())
@@ -69,6 +71,7 @@ def __init__(self, target, path,
6971
self.debug = debug
7072
self.strip = strip
7173
self.script = script
74+
self.native = native
7275
self.optional = optional
7376

7477
if features is None:

0 commit comments

Comments
 (0)