Skip to content

Commit 1bc9790

Browse files
authored
Merge pull request #201 from davidbrochart/fix_multipy
Fix multi python package publishing
2 parents 78f587f + 2f3c903 commit 1bc9790

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
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/cli.py

Lines changed: 3 additions & 3 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)
@@ -387,7 +387,7 @@ def build_python(dist_dir, python_packages):
387387
"""Build Python dist files"""
388388
prev_dir = os.getcwd()
389389
clean = True
390-
for python_package in python_packages:
390+
for python_package in [p.split(":")[0] for p in python_packages]:
391391
os.chdir(python_package)
392392
if not util.PYPROJECT.exists() and not util.SETUP_PY.exists():
393393
util.log(

jupyter_releaser/lib.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,15 @@ def publish_assets(
393393
if npm_token:
394394
util.run("npm whoami")
395395

396+
res = python_package.split(":")
397+
python_package_path = res[0]
398+
if len(res) == 2:
399+
python_package_name = res[1].replace("-", "_")
400+
else:
401+
python_package_name = ""
402+
396403
if len(glob(f"{dist_dir}/*.whl")):
397-
twine_token = python.get_pypi_token(release_url, python_package)
404+
twine_token = python.get_pypi_token(release_url, python_package_path)
398405

399406
if dry_run:
400407
# Start local pypi server with no auth, allowing overwrites,
@@ -413,12 +420,15 @@ def publish_assets(
413420
name = Path(path).name
414421
suffix = Path(path).suffix
415422
if suffix in [".gz", ".whl"]:
416-
env = os.environ.copy()
417-
env["TWINE_PASSWORD"] = twine_token
418-
# NOTE: Do not print the env since a twine token extracted from
419-
# a PYPI_TOKEN_MAP will not be sanitized in output
420-
util.retry(f"{twine_cmd} {name}", cwd=dist_dir, env=env)
421-
found = True
423+
if name.startswith(
424+
python_package_name
425+
): # FIXME: not enough to know it's the right package
426+
env = os.environ.copy()
427+
env["TWINE_PASSWORD"] = twine_token
428+
# NOTE: Do not print the env since a twine token extracted from
429+
# a PYPI_TOKEN_MAP will not be sanitized in output
430+
util.retry(f"{twine_cmd} {name}", cwd=dist_dir, env=env)
431+
found = True
422432
elif suffix == ".tgz":
423433
# Ignore already published versions
424434
try:

0 commit comments

Comments
 (0)