Skip to content

Commit d6a1f76

Browse files
authored
Merge pull request #258 from blink1073/twine-strict
2 parents 160a886 + 323038a commit d6a1f76

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

jupyter_releaser/cli.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ def main(force):
254254
)
255255
]
256256

257+
pydist_check_options = [
258+
click.option(
259+
"--pydist-check-cmd",
260+
envvar="RH_PYDIST_CHECK_CMD",
261+
default="twine check --strict",
262+
help="The command to use to check a python distribution file",
263+
)
264+
]
265+
257266

258267
def add_options(options):
259268
"""Add extracted common options to a click command"""
@@ -414,15 +423,18 @@ def build_python(dist_dir, python_packages):
414423
@main.command()
415424
@add_options(dist_dir_options)
416425
@add_options(check_imports_options)
426+
@add_options(pydist_check_options)
417427
@use_checkout_dir()
418-
def check_python(dist_dir, check_imports):
428+
def check_python(dist_dir, check_imports, pydist_check_cmd):
419429
"""Check Python dist files"""
420430
for dist_file in glob(f"{dist_dir}/*"):
421431
if Path(dist_file).suffix not in [".gz", ".whl"]:
422432
util.log(f"Skipping non-python dist file {dist_file}")
423433
continue
424434

425-
python.check_dist(dist_file, python_imports=check_imports)
435+
python.check_dist(
436+
dist_file, python_imports=check_imports, check_cmd=pydist_check_cmd
437+
)
426438

427439

428440
@main.command()
@@ -587,10 +599,15 @@ def delete_release(auth, release_url):
587599
@add_options(dist_dir_options)
588600
@add_options(dry_run_options)
589601
@add_options(npm_install_options)
602+
@add_options(pydist_check_options)
590603
@click.argument("release-url", nargs=1)
591-
def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
604+
def extract_release(
605+
auth, dist_dir, dry_run, release_url, npm_install_options, pydist_check_cmd
606+
):
592607
"""Download and verify assets from a draft GitHub release"""
593-
lib.extract_release(auth, dist_dir, dry_run, release_url, npm_install_options)
608+
lib.extract_release(
609+
auth, dist_dir, dry_run, release_url, npm_install_options, pydist_check_cmd
610+
)
594611

595612

596613
@main.command()

jupyter_releaser/lib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,9 @@ def delete_release(auth, release_url):
284284
gh.repos.delete_release(release.id)
285285

286286

287-
def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
287+
def extract_release(
288+
auth, dist_dir, dry_run, release_url, npm_install_options, pydist_check_cmd
289+
):
288290
"""Download and verify assets from a draft GitHub release"""
289291
match = parse_release_url(release_url)
290292
owner, repo = match["owner"], match["repo"]
@@ -329,7 +331,7 @@ def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
329331
for asset in assets:
330332
suffix = Path(asset.name).suffix
331333
if suffix in [".gz", ".whl"]:
332-
python.check_dist(dist / asset.name)
334+
python.check_dist(dist / asset.name, check_cmd=pydist_check_cmd)
333335
elif suffix == ".tgz":
334336
pass # already handled
335337
else:

jupyter_releaser/python.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ def build_dist(dist_dir, clean=True):
3434
util.run(f"python setup.py bdist_wheel --dist-dir {dest}", quiet=True)
3535

3636

37-
def check_dist(dist_file, test_cmd="", python_imports=None):
37+
def check_dist(
38+
dist_file, test_cmd="", python_imports=None, check_cmd="twine check --strict"
39+
):
3840
"""Check a Python package locally (not as a cli)"""
3941
dist_file = util.normalize_path(dist_file)
40-
util.run(f"twine check {dist_file}")
42+
util.run(f"{check_cmd} {dist_file}")
4143

4244
test_commands = []
4345

jupyter_releaser/tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ def test_list_envvars(runner):
163163
output: RH_CHANGELOG_OUTPUT
164164
post-version-message: RH_POST_VERSION_MESSAGE
165165
post-version-spec: RH_POST_VERSION_SPEC
166+
pydist-check-cmd: RH_PYDIST_CHECK_CMD
166167
python-packages: RH_PYTHON_PACKAGES
167168
ref: RH_REF
168169
release-message: RH_RELEASE_MESSAGE

0 commit comments

Comments
 (0)