Skip to content

Commit 5919c94

Browse files
committed
Back to same distribution directory
1 parent c122937 commit 5919c94

File tree

8 files changed

+113
-200
lines changed

8 files changed

+113
-200
lines changed

docs/source/get_started/making_first_release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ already uses Jupyter Releaser.
2323
owner2/repo2,token2
2424
```
2525
26-
If you have multiple Python packages in one repository, you can point to them as follows:
26+
If you have multiple Python packages in the same repository, you can point to them as follows:
2727
2828
```text
2929
owner1/repo1/path/to/package1,token1
30-
owner1/repo1/path/to/package2,token1
30+
owner1/repo1/path/to/package2,token2
3131
```
3232
3333
- If the repo generates npm release(s), add access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN` in "Secrets".

docs/source/how_to_guides/convert_repo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ A. Prep the `jupyter_releaser` fork:
2828
owner2/repo2,token2
2929
```
3030

31-
If you have multiple Python packages in one repository, you can point to them as follows:
31+
If you have multiple Python packages in the same repository, you can point to them as follows:
3232

3333
```text
3434
owner1/repo1/path/to/package1,token1
35-
owner1/repo1/path/to/package2,token1
35+
owner1/repo1/path/to/package2,token2
3636
```
3737

3838
- [ ] If needed, add access token for [npm](https://docs.npmjs.com/creating-and-viewing-access-tokens), saved as `NPM_TOKEN`.

jupyter_releaser/actions/publish_release.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
run(f"jupyter-releaser extract-release {release_url}")
1111
run(f"jupyter-releaser forwardport-changelog {release_url}")
1212

13-
run(f"jupyter-releaser publish-assets-py {release_url}")
14-
run(f"jupyter-releaser publish-assets-npm {release_url}")
13+
run(f"jupyter-releaser publish-assets {release_url}")
1514

1615
if release_url:
1716
run(f"jupyter-releaser publish-release {release_url}")

jupyter_releaser/cli.py

Lines changed: 40 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def main(force):
180180
envvar="RH_PYTHON_PACKAGES",
181181
default=["."],
182182
multiple=True,
183-
help="The list of paths to Python packages",
183+
help='The list of strings of the form "path_to_package:name_of_package"',
184184
)
185185
]
186186

@@ -291,7 +291,7 @@ def prep_git(ref, branch, repo, auth, username, git_url):
291291
def bump_version(version_spec, version_cmd, python_packages):
292292
"""Prep git and env variables and bump version"""
293293
prev_dir = os.getcwd()
294-
for python_package in python_packages:
294+
for python_package in [p.split(":")[0] for p in python_packages]:
295295
os.chdir(python_package)
296296
lib.bump_version(version_spec, version_cmd)
297297
os.chdir(prev_dir)
@@ -386,32 +386,31 @@ def check_changelog(
386386
def build_python(dist_dir, python_packages):
387387
"""Build Python dist files"""
388388
prev_dir = os.getcwd()
389-
for python_package in python_packages:
389+
clean = True
390+
for python_package in [p.split(":")[0] for p in python_packages]:
390391
os.chdir(python_package)
391392
if not util.PYPROJECT.exists() and not util.SETUP_PY.exists():
392393
util.log(
393394
f"Skipping build-python in {python_package} since there are no python package files"
394395
)
395396
else:
396-
python.build_dist(dist_dir)
397+
python.build_dist(
398+
Path(os.path.relpath(".", python_package)) / dist_dir, clean=clean
399+
)
400+
clean = False
397401
os.chdir(prev_dir)
398402

399403

400404
@main.command()
401405
@add_options(dist_dir_options)
402-
@add_options(python_packages_options)
403406
@use_checkout_dir()
404-
def check_python(dist_dir, python_packages):
407+
def check_python(dist_dir):
405408
"""Check Python dist files"""
406-
prev_dir = os.getcwd()
407-
for python_package in python_packages:
408-
os.chdir(python_package)
409-
for dist_file in glob(f"{dist_dir}/*"):
410-
if Path(dist_file).suffix not in [".gz", ".whl"]:
411-
util.log(f"Skipping non-python dist file {dist_file}")
412-
continue
413-
python.check_dist(dist_file)
414-
os.chdir(prev_dir)
409+
for dist_file in glob(f"{dist_dir}/*"):
410+
if Path(dist_file).suffix not in [".gz", ".whl"]:
411+
util.log(f"Skipping non-python dist file {dist_file}")
412+
continue
413+
python.check_dist(dist_file)
415414

416415

417416
@main.command()
@@ -480,7 +479,6 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
480479

481480
@main.command()
482481
@add_options(dist_dir_options)
483-
@add_options(python_packages_options)
484482
@click.option(
485483
"--release-message",
486484
envvar="RH_RELEASE_MESSAGE",
@@ -506,21 +504,11 @@ def check_links(ignore_glob, ignore_links, cache_file, links_expire):
506504
)
507505
@use_checkout_dir()
508506
def tag_release(
509-
dist_dir,
510-
python_packages,
511-
release_message,
512-
tag_format,
513-
tag_message,
514-
no_git_tag_workspace,
507+
dist_dir, release_message, tag_format, tag_message, no_git_tag_workspace
515508
):
516509
"""Create release commit and tag"""
517510
lib.tag_release(
518-
dist_dir,
519-
python_packages,
520-
release_message,
521-
tag_format,
522-
tag_message,
523-
no_git_tag_workspace,
511+
dist_dir, release_message, tag_format, tag_message, no_git_tag_workspace
524512
)
525513

526514

@@ -531,7 +519,6 @@ def tag_release(
531519
@add_options(version_cmd_options)
532520
@add_options(dist_dir_options)
533521
@add_options(dry_run_options)
534-
@add_options(python_packages_options)
535522
@click.option(
536523
"--post-version-spec",
537524
envvar="RH_POST_VERSION_SPEC",
@@ -557,7 +544,6 @@ def draft_release(
557544
post_version_spec,
558545
post_version_message,
559546
assets,
560-
python_packages,
561547
):
562548
"""Publish Draft GitHub release"""
563549
lib.draft_release(
@@ -572,7 +558,6 @@ def draft_release(
572558
post_version_spec,
573559
post_version_message,
574560
assets,
575-
python_packages,
576561
)
577562

578563

@@ -588,27 +573,35 @@ def delete_release(auth, release_url):
588573
@main.command()
589574
@add_options(auth_options)
590575
@add_options(dist_dir_options)
591-
@add_options(python_packages_options)
592576
@add_options(dry_run_options)
593577
@add_options(npm_install_options)
594578
@click.argument("release-url", nargs=1)
595-
def extract_release(
596-
auth, dist_dir, python_packages, dry_run, release_url, npm_install_options
597-
):
579+
def extract_release(auth, dist_dir, dry_run, release_url, npm_install_options):
598580
"""Download and verify assets from a draft GitHub release"""
599-
lib.extract_release(
600-
auth, dist_dir, python_packages, dry_run, release_url, npm_install_options
601-
)
581+
lib.extract_release(auth, dist_dir, dry_run, release_url, npm_install_options)
602582

603583

604584
@main.command()
605585
@add_options(dist_dir_options)
586+
@click.option("--npm-token", help="A token for the npm release", envvar="NPM_TOKEN")
587+
@click.option(
588+
"--npm-cmd",
589+
help="The command to run for npm release",
590+
envvar="RH_NPM_COMMAND",
591+
default="npm publish",
592+
)
606593
@click.option(
607594
"--twine-cmd",
608595
help="The twine to run for Python release",
609596
envvar="TWINE_COMMAND",
610597
default="twine upload",
611598
)
599+
@click.option(
600+
"--npm-registry",
601+
help="The npm registry to target for publishing",
602+
envvar="NPM_REGISTRY",
603+
default="https://registry.npmjs.org/",
604+
)
612605
@click.option(
613606
"--twine-registry",
614607
help="The pypi register to target for publishing",
@@ -619,64 +612,30 @@ def extract_release(
619612
@add_options(python_packages_options)
620613
@click.argument("release-url", nargs=1, required=False)
621614
@use_checkout_dir()
622-
def publish_assets_py(
615+
def publish_assets(
623616
dist_dir,
617+
npm_token,
618+
npm_cmd,
624619
twine_cmd,
620+
npm_registry,
625621
twine_registry,
626622
dry_run,
627623
release_url,
628624
python_packages,
629625
):
630-
"""Publish release asset(s) to PyPI"""
631-
prev_dir = os.getcwd()
626+
"""Publish release asset(s)"""
632627
for python_package in python_packages:
633-
os.chdir(python_package)
634-
lib.publish_assets_py(
628+
lib.publish_assets(
635629
dist_dir,
630+
npm_token,
631+
npm_cmd,
636632
twine_cmd,
633+
npm_registry,
637634
twine_registry,
638635
dry_run,
639636
release_url,
640637
python_package,
641638
)
642-
os.chdir(prev_dir)
643-
644-
645-
@main.command()
646-
@add_options(dist_dir_options)
647-
@click.option("--npm-token", help="A token for the npm release", envvar="NPM_TOKEN")
648-
@click.option(
649-
"--npm-cmd",
650-
help="The command to run for npm release",
651-
envvar="RH_NPM_COMMAND",
652-
default="npm publish",
653-
)
654-
@click.option(
655-
"--npm-registry",
656-
help="The npm registry to target for publishing",
657-
envvar="NPM_REGISTRY",
658-
default="https://registry.npmjs.org/",
659-
)
660-
@add_options(dry_run_options)
661-
@click.argument("release-url", nargs=1, required=False)
662-
@use_checkout_dir()
663-
def publish_assets_npm(
664-
dist_dir,
665-
npm_token,
666-
npm_cmd,
667-
npm_registry,
668-
dry_run,
669-
release_url,
670-
):
671-
"""Publish release asset(s) to NPM"""
672-
lib.publish_assets_npm(
673-
dist_dir,
674-
npm_token,
675-
npm_cmd,
676-
npm_registry,
677-
dry_run,
678-
release_url,
679-
)
680639

681640

682641
@main.command()

0 commit comments

Comments
 (0)