Skip to content

Commit c5d5c64

Browse files
committed
Allow the nox -e build target to also build the examples package
Signed-off-by: Pedro Algarvio <[email protected]>
1 parent ce115bd commit c5d5c64

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

changelog/68.trivial.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Several trivial/internal updates to the project:
2+
3+
* Allow the `nox -e build` target to also build the examples package

noxfile.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ def build(session):
615615
616616
git show -s --format=%at HEAD
617617
"""
618-
shutil.rmtree("dist/", ignore_errors=True)
619618
if SKIP_REQUIREMENTS_INSTALL is False:
620619
requirements_file = REPO_ROOT / "requirements" / "build.txt"
621620
session.install(
@@ -624,6 +623,22 @@ def build(session):
624623
str(requirements_file.relative_to(REPO_ROOT)),
625624
silent=PIP_INSTALL_SILENT,
626625
)
626+
627+
if not session.posargs:
628+
build_path = REPO_ROOT
629+
elif len(session.posargs) > 1:
630+
session.error("Only one argument supported, which is `examples`")
631+
elif session.posargs[0] in ("src", "source"):
632+
build_path = REPO_ROOT
633+
elif session.posargs[0] == "examples":
634+
build_path = REPO_ROOT / "examples"
635+
else:
636+
session.error(
637+
f"Passing '{session.posargs[0]}' is not supported. Only one argument "
638+
"supported, which is `examples`"
639+
)
640+
641+
shutil.rmtree(build_path / "dist", ignore_errors=True)
627642
timestamp = session.run(
628643
"git",
629644
"show",
@@ -641,17 +656,19 @@ def build(session):
641656
"build",
642657
"--sdist",
643658
"--wheel",
644-
str(REPO_ROOT),
659+
str(build_path),
645660
env=env,
646661
)
647662
# Recreate sdist to be reproducible
648663
recompress = Recompress(timestamp)
649-
for targz in REPO_ROOT.joinpath("dist").glob("*.tar.gz"):
664+
for targz in build_path.joinpath("dist").glob("*.tar.gz"):
650665
session.log("Re-compressing %s...", targz.relative_to(REPO_ROOT))
651666
recompress.recompress(targz)
652667

653668
sha256sum = shutil.which("sha256sum")
654669
if sha256sum:
655-
packages = [str(pkg.relative_to(REPO_ROOT)) for pkg in REPO_ROOT.joinpath("dist").iterdir()]
670+
packages = [
671+
str(pkg.relative_to(REPO_ROOT)) for pkg in build_path.joinpath("dist").iterdir()
672+
]
656673
session.run("sha256sum", *packages, external=True)
657-
session.run("python", "-m", "twine", "check", "dist/*")
674+
session.run("python", "-m", "twine", "check", str(build_path / "dist" / "*"))

0 commit comments

Comments
 (0)