Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/hello-world/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions examples/hello-world/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "hello-world"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
2 changes: 2 additions & 0 deletions examples/hello-world/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include Cargo.toml
recursive-include src *
Empty file.
12 changes: 12 additions & 0 deletions examples/hello-world/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from setuptools import setup
from setuptools_rust import Binding, RustExtension

setup(
name="hello-world",
version="1.0",
rust_extensions=[
RustExtension("hello_world.hello_world", binding=Binding.Exec, script=True)
],
# rust extensions are not zip safe, just like C-extensions.
zip_safe=False,
)
3 changes: 3 additions & 0 deletions examples/hello-world/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
10 changes: 10 additions & 0 deletions examples/hello-world/tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[tox]
requires =
setuptools-rust @ file://{toxinidir}/../../

[testenv]
description = Run the unit tests under {basepython}
deps =
setuptools-rust @ file://{toxinidir}/../../
commands = hello_world {posargs}
passenv = *
3 changes: 2 additions & 1 deletion setuptools_rust/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,12 @@ def install_extension(self, ext: RustExtension, dylib_paths):
# remove python3 extension (i.e. cpython-36m)
ext_path, _ = os.path.splitext(ext_path)

os.makedirs(os.path.dirname(ext_path), exist_ok=True)
ext.install_script(ext_path)
else:
ext_path = self.get_dylib_ext_path(ext, target_fname)
os.makedirs(os.path.dirname(ext_path), exist_ok=True)

os.makedirs(os.path.dirname(ext_path), exist_ok=True)
shutil.copyfile(dylib_path, ext_path)

if sys.platform != "win32" and not debug_build:
Expand Down
2 changes: 1 addition & 1 deletion setuptools_rust/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def install_script(self, ext_path):
dirname, name = os.path.split(ext_path)
file = os.path.join(dirname, "_gen_%s.py" % name)
with open(file, "w") as f:
f.write(TMPL.format({"name": name}))
f.write(TMPL.format(name=name))


TMPL = """
Expand Down