Skip to content

Commit

Permalink
Add req_check session; build_linux with Docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
drmikehenry committed May 7, 2024
1 parent 4af2577 commit a2dd754
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

nox.options.error_on_external_run = True
nox.options.reuse_existing_virtualenvs = True
nox.options.sessions = ["lint", "type_check", "test"]
nox.options.sessions = ["lint", "type_check", "test", "req_check"]


def get_project_version() -> str:
Expand Down Expand Up @@ -109,6 +109,22 @@ def type_check(s: Session) -> None:
s.run("mypy", "src", "tests", "noxfile.py")


@session(venv_backend="none")
def req_check(s: Session) -> None:
expected = s.run_always(
"poetry",
"export",
external=True,
silent=True,
)
actual = open("requirements.txt").read()
if actual != expected:
s.error(
"`requirements.txt` is out-of-date (run: \n"
"poetry export -o requirements.txt)",
)


# Note: This `reuse_venv` does not yet have effect due to:
# https://github.com/wntrblm/nox/issues/488
@session(reuse_venv=False)
Expand All @@ -117,20 +133,20 @@ def licenses(s: Session) -> None:
# file directly on Windows, so only use the name and allow Poetry to
# re-create it.
with NamedTemporaryFile() as t:
requirements_file = Path(t.name)
requirements_path = Path(t.name)

# Install dependencies without installing the package itself:
# https://github.com/cjolowicz/nox-poetry/issues/680
s.run_always(
"poetry",
"export",
"--without-hashes",
f"--output={requirements_file}",
f"--output={requirements_path}",
external=True,
)
s.install("pip-licenses", "-r", str(requirements_file))
s.install("pip-licenses", "-r", str(requirements_path))
s.run("pip-licenses", *s.posargs)
requirements_file.unlink()
requirements_path.unlink()


@session(venv_backend="none")
Expand Down Expand Up @@ -197,8 +213,9 @@ def release(s: Session) -> None:
rmtree(Path("dist"))
rmtree(Path("build"))
s.log("NOTE: safe to perform Windows steps now...")
build(s)
s.run("poetry", "export", "-o", "requirements.txt")
s.run("poetry", "install")
# Build the `romt` executable for Linux:
build_linux(s)
s.run("poetry", "build")
s.run("twine", "check", str(tar_path), str(whl_path))
print(
Expand All @@ -208,6 +225,8 @@ def release(s: Session) -> None:
On Windows machine:
poetry run nox -s build
Alternatively, unzip from CI:
unzip -d dist/ dist-windows-latest.zip
Tag and push:
git tag -am 'Release v{version}.' v{version}
Expand Down

0 comments on commit a2dd754

Please sign in to comment.