Skip to content

Commit f018421

Browse files
committed
simplify test-sdist-vendor
1 parent 7e28836 commit f018421

File tree

5 files changed

+25
-12
lines changed

5 files changed

+25
-12
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*.pyo
33
*.so
44
.eggs
5-
.tox
5+
.nox
66
dist
77
build
88
target

examples/namespace_package/noxfile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
@nox.session()
99
def test(session: nox.Session):
10-
session.install(SETUPTOOLS_RUST, "wheel", "pytest")
10+
session.install(SETUPTOOLS_RUST, "wheel")
1111
# Ensure build uses version of setuptools-rust under development
12-
session.install("--no-build-isolation", ".")
12+
session.install("--no-build-isolation", ".[dev]")
1313
# Test Python package
1414
session.run("pytest", *session.posargs)

examples/namespace_package/pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ build-backend = "setuptools.build_meta"
66
name="namespace_package"
77
version="0.1.0"
88

9+
[project.optional-dependencies]
10+
dev = ["pytest"]
11+
12+
[tool.pytest.ini_options]
13+
914
[tool.setuptools.packages]
1015
# Pure Python packages/modules
1116
find = { where = ["python"] }

examples/namespace_package/pytest.ini

Whitespace-only changes.

noxfile.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import tarfile
32
from inspect import cleandoc as heredoc
43
from glob import glob
54
from pathlib import Path
@@ -19,24 +18,33 @@ def test_sdist_vendor(session: nox.Session):
1918
session.install(".", "build", "wheel")
2019
namespace_package = Path(__file__).parent / "examples" / "namespace_package"
2120
os.chdir(namespace_package)
22-
tmp = session.create_tmp()
21+
tmp = Path(session.create_tmp())
22+
extra_config = tmp / "setup.cfg"
2323

2424
build_config = """
2525
[sdist]
2626
vendor_crates = True
2727
"""
28-
Path(tmp, "setup.cfg").write_text(heredoc(build_config), encoding="utf-8")
28+
extra_config.write_text(heredoc(build_config), encoding="utf-8")
2929

3030
env = os.environ.copy()
31-
env.update(DIST_EXTRA_CONFIG=str(Path(tmp, "setup.cfg")))
31+
env.update(DIST_EXTRA_CONFIG=str(extra_config))
3232
cmd = ["python", "-m", "build", "--sdist", "--no-isolation"]
3333
session.run(*cmd, env=env, external=True)
3434

35-
dist = namespace_package / "dist"
36-
with tarfile.open(str(dist / "namespace_package-0.1.0.tar.gz")) as tf:
37-
tf.extractall(str(dist))
38-
os.chdir(dist / "namespace_package-0.1.0")
39-
session.run("cargo", "build", "--offline", external=True)
35+
session.run(
36+
"python",
37+
"-m",
38+
"pip",
39+
"install",
40+
Path("dist") / "namespace_package-0.1.0.tar.gz[dev]",
41+
"--no-build-isolation",
42+
"-v",
43+
# run in offline mode with a blank cargo home to prove the vendored
44+
# dependencies are sufficient to build the package
45+
env={"CARGO_NET_OFFLINE": "true", "CARGO_HOME": str(tmp / ".cargo")},
46+
)
47+
session.run("pytest")
4048

4149

4250
@nox.session(name="test-crossenv", venv_backend=None)

0 commit comments

Comments
 (0)