mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
Merge pull request #9640 from pradyunsg/improve-noxfile
Improve noxfile.py
This commit is contained in:
commit
cbc46fe8bd
2 changed files with 16 additions and 15 deletions
|
@ -46,7 +46,6 @@ repos:
|
||||||
^tests/functional/test_install|
|
^tests/functional/test_install|
|
||||||
# Files in the root of the repository
|
# Files in the root of the repository
|
||||||
^setup.py|
|
^setup.py|
|
||||||
^noxfile.py|
|
|
||||||
# A blank ignore, to avoid merge conflicts later.
|
# A blank ignore, to avoid merge conflicts later.
|
||||||
^$
|
^$
|
||||||
|
|
||||||
|
|
30
noxfile.py
30
noxfile.py
|
@ -10,9 +10,11 @@ from typing import Iterator, List, Tuple
|
||||||
|
|
||||||
import nox
|
import nox
|
||||||
|
|
||||||
|
# fmt: off
|
||||||
sys.path.append(".")
|
sys.path.append(".")
|
||||||
from tools.automation import release # isort:skip # noqa
|
from tools.automation import release # isort:skip # noqa
|
||||||
sys.path.pop()
|
sys.path.pop()
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
nox.options.reuse_existing_virtualenvs = True
|
nox.options.reuse_existing_virtualenvs = True
|
||||||
nox.options.sessions = ["lint"]
|
nox.options.sessions = ["lint"]
|
||||||
|
@ -75,17 +77,16 @@ def test(session):
|
||||||
# type: (nox.Session) -> None
|
# type: (nox.Session) -> None
|
||||||
# Get the common wheels.
|
# Get the common wheels.
|
||||||
if should_update_common_wheels():
|
if should_update_common_wheels():
|
||||||
|
# fmt: off
|
||||||
run_with_protected_pip(
|
run_with_protected_pip(
|
||||||
session,
|
session,
|
||||||
"wheel",
|
"wheel",
|
||||||
"-w", LOCATIONS["common-wheels"],
|
"-w", LOCATIONS["common-wheels"],
|
||||||
"-r", REQUIREMENTS["common-wheels"],
|
"-r", REQUIREMENTS["common-wheels"],
|
||||||
)
|
)
|
||||||
|
# fmt: on
|
||||||
else:
|
else:
|
||||||
msg = (
|
msg = f"Re-using existing common-wheels at {LOCATIONS['common-wheels']}."
|
||||||
"Re-using existing common-wheels at {}."
|
|
||||||
.format(LOCATIONS["common-wheels"])
|
|
||||||
)
|
|
||||||
session.log(msg)
|
session.log(msg)
|
||||||
|
|
||||||
# Build source distribution
|
# Build source distribution
|
||||||
|
@ -93,11 +94,14 @@ def test(session):
|
||||||
sdist_dir = os.path.join(session.virtualenv.location, "sdist") # type: ignore
|
sdist_dir = os.path.join(session.virtualenv.location, "sdist") # type: ignore
|
||||||
if os.path.exists(sdist_dir):
|
if os.path.exists(sdist_dir):
|
||||||
shutil.rmtree(sdist_dir, ignore_errors=True)
|
shutil.rmtree(sdist_dir, ignore_errors=True)
|
||||||
|
|
||||||
|
# fmt: off
|
||||||
session.run(
|
session.run(
|
||||||
"python", "setup.py", "sdist",
|
"python", "setup.py", "sdist", "--formats=zip", "--dist-dir", sdist_dir,
|
||||||
"--formats=zip", "--dist-dir", sdist_dir,
|
|
||||||
silent=True,
|
silent=True,
|
||||||
)
|
)
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
generated_files = os.listdir(sdist_dir)
|
generated_files = os.listdir(sdist_dir)
|
||||||
assert len(generated_files) == 1
|
assert len(generated_files) == 1
|
||||||
generated_sdist = os.path.join(sdist_dir, generated_files[0])
|
generated_sdist = os.path.join(sdist_dir, generated_files[0])
|
||||||
|
@ -129,6 +133,7 @@ def docs(session):
|
||||||
# can not use a different configuration directory vs source directory
|
# can not use a different configuration directory vs source directory
|
||||||
# on RTD currently. So, we'll pass "-c docs/html" here.
|
# on RTD currently. So, we'll pass "-c docs/html" here.
|
||||||
# See https://github.com/rtfd/readthedocs.org/issues/1543.
|
# See https://github.com/rtfd/readthedocs.org/issues/1543.
|
||||||
|
# fmt: off
|
||||||
return [
|
return [
|
||||||
"sphinx-build",
|
"sphinx-build",
|
||||||
"-W",
|
"-W",
|
||||||
|
@ -138,6 +143,7 @@ def docs(session):
|
||||||
"docs/" + kind,
|
"docs/" + kind,
|
||||||
"docs/build/" + kind,
|
"docs/build/" + kind,
|
||||||
]
|
]
|
||||||
|
# fmt: on
|
||||||
|
|
||||||
session.run(*get_sphinx_build_command("html"))
|
session.run(*get_sphinx_build_command("html"))
|
||||||
session.run(*get_sphinx_build_command("man"))
|
session.run(*get_sphinx_build_command("man"))
|
||||||
|
@ -227,9 +233,7 @@ def prepare_release(session):
|
||||||
session.log(f"# Updating {AUTHORS_FILE}")
|
session.log(f"# Updating {AUTHORS_FILE}")
|
||||||
release.generate_authors(AUTHORS_FILE)
|
release.generate_authors(AUTHORS_FILE)
|
||||||
if release.modified_files_in_git():
|
if release.modified_files_in_git():
|
||||||
release.commit_file(
|
release.commit_file(session, AUTHORS_FILE, message=f"Update {AUTHORS_FILE}")
|
||||||
session, AUTHORS_FILE, message=f"Update {AUTHORS_FILE}",
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
session.log(f"# No changes to {AUTHORS_FILE}")
|
session.log(f"# No changes to {AUTHORS_FILE}")
|
||||||
|
|
||||||
|
@ -276,7 +280,7 @@ def build_release(session):
|
||||||
|
|
||||||
tmp_dist_paths = (build_dir / p for p in tmp_dists)
|
tmp_dist_paths = (build_dir / p for p in tmp_dists)
|
||||||
session.log(f"# Copying dists from {build_dir}")
|
session.log(f"# Copying dists from {build_dir}")
|
||||||
os.makedirs('dist', exist_ok=True)
|
os.makedirs("dist", exist_ok=True)
|
||||||
for dist, final in zip(tmp_dist_paths, tmp_dists):
|
for dist, final in zip(tmp_dist_paths, tmp_dists):
|
||||||
session.log(f"# Copying {dist} to {final}")
|
session.log(f"# Copying {dist} to {final}")
|
||||||
shutil.copy(dist, final)
|
shutil.copy(dist, final)
|
||||||
|
@ -291,7 +295,7 @@ def build_dists(session):
|
||||||
|
|
||||||
has_forbidden_git_untracked_files = any(
|
has_forbidden_git_untracked_files = any(
|
||||||
# Don't report the environment this session is running in
|
# Don't report the environment this session is running in
|
||||||
not untracked_file.startswith('.nox/build-release/')
|
not untracked_file.startswith(".nox/build-release/")
|
||||||
for untracked_file in release.get_git_untracked_files()
|
for untracked_file in release.get_git_untracked_files()
|
||||||
)
|
)
|
||||||
if has_forbidden_git_untracked_files:
|
if has_forbidden_git_untracked_files:
|
||||||
|
@ -337,9 +341,7 @@ def upload_release(session):
|
||||||
f"pip-{version}.tar.gz",
|
f"pip-{version}.tar.gz",
|
||||||
]
|
]
|
||||||
if sorted(distfile_names) != sorted(expected_distribution_files):
|
if sorted(distfile_names) != sorted(expected_distribution_files):
|
||||||
session.error(
|
session.error(f"Distribution files do not seem to be for {version} release.")
|
||||||
f"Distribution files do not seem to be for {version} release."
|
|
||||||
)
|
|
||||||
|
|
||||||
session.log("# Upload distributions")
|
session.log("# Upload distributions")
|
||||||
session.run("twine", "upload", *distribution_files)
|
session.run("twine", "upload", *distribution_files)
|
||||||
|
|
Loading…
Reference in a new issue