Skip to content

Commit 09d10dd

Browse files
committed
Add hello-world-script example for testing console_scripts
1 parent 239595b commit 09d10dd

File tree

9 files changed

+65
-0
lines changed

9 files changed

+65
-0
lines changed

examples/hello-world-script/Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "hello-world-script"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
10+
[profile.release-lto]
11+
inherits = "release"
12+
lto = true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include Cargo.toml
2+
recursive-include src *

examples/hello-world-script/hello_world/__init__.py

Whitespace-only changes.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from os.path import dirname
2+
3+
import nox
4+
5+
SETUPTOOLS_RUST = dirname(dirname(dirname(__file__)))
6+
7+
8+
@nox.session()
9+
def test(session: nox.Session):
10+
session.install(SETUPTOOLS_RUST)
11+
session.install("--no-build-isolation", ".")
12+
session.run("hello-world-script", *session.posargs)
13+
14+
15+
@nox.session()
16+
def setuptools_install(session: nox.Session):
17+
session.install("setuptools")
18+
with session.chdir(SETUPTOOLS_RUST):
19+
session.run("python", "setup.py", "install")
20+
session.run("python", "setup.py", "install")
21+
session.run("hello-world-script", *session.posargs)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build-system]
2+
requires = ["setuptools", "wheel", "setuptools-rust"]

examples/hello-world-script/pytest.ini

Whitespace-only changes.

examples/hello-world-script/setup.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from setuptools import setup
2+
3+
from setuptools_rust import RustExtension, Binding
4+
5+
setup(
6+
name="hello-world-script",
7+
version="1.0",
8+
rust_extensions=[
9+
RustExtension(
10+
{"hello-world-script": "hello_world.hello-world-script"},
11+
binding=Binding.Exec,
12+
script=True,
13+
args=["--profile", "release-lto"],
14+
)
15+
],
16+
# rust extensions are not zip safe, just like C-extensions.
17+
zip_safe=False,
18+
)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

0 commit comments

Comments
 (0)