Skip to content

Commit ee13496

Browse files
authored
project.urls in ship_new template with gh_org param
1 parent 89d1e4c commit ee13496

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

fastship/release.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def _write(p:Path, s:str):
413413
p.parent.mkdir(parents=True, exist_ok=True)
414414
p.write_text(s, encoding="utf-8")
415415

416-
def _template_pyproject(proj_name:str, pkg_name:str, desc:str)->str:
416+
def _template_pyproject(proj_name:str, pkg_name:str, desc:str, gh_org:str)->str:
417417
return f"""[build-system]
418418
requires = [\"setuptools>=68\", \"wheel\"]
419419
build-backend = \"setuptools.build_meta\"
@@ -440,11 +440,11 @@ def _template_pyproject(proj_name:str, pkg_name:str, desc:str)->str:
440440
\"twine\",
441441
]
442442
443+
[project.urls]
444+
Homepage = \"https://github.com/{gh_org}/{proj_name}\"
445+
443446
[tool.setuptools.dynamic]
444447
version = {{ attr = \"{pkg_name}.__version__\" }}
445-
446-
[tool.fastship]
447-
branch = \"main\"
448448
"""
449449

450450
def _template_readme(proj_name:str, pkg_name:str)->str:
@@ -454,8 +454,6 @@ def _template_readme(proj_name:str, pkg_name:str)->str:
454454
455455
## Development
456456
457-
Create a virtualenv, then install dev tools:
458-
459457
```bash
460458
pip install -e .[dev]
461459
```
@@ -511,6 +509,7 @@ def ship_new(
511509
package: str = None, # Python package import name, e.g. "my_project" (defaults from `name`)
512510
description: str = "A Python package", # Short project description
513511
path: str = ".", # Directory to create the project folder in
512+
gh_org: str = "AnswerDotAI", # GitHub organization for project.urls
514513
force: bool = False, # Overwrite if the folder already exists
515514
):
516515
"Create a modern setuptools project wired for fastship."
@@ -520,7 +519,7 @@ def ship_new(
520519
if not force: raise FileExistsError(f"{root} already exists (use force=True to overwrite)")
521520
shutil.rmtree(root)
522521

523-
_write(root/"pyproject.toml", _template_pyproject(name, pkg, description))
522+
_write(root/"pyproject.toml", _template_pyproject(name, pkg, description, gh_org))
524523
_write(root/"README.md", _template_readme(name, pkg))
525524
_write(root/"CHANGELOG.md", "<!-- do not remove -->\n\n")
526525
_write(root/"LICENSE", _read_license())
@@ -573,8 +572,7 @@ def ship_pr(
573572
try: has_commits = bool(g.log(f'origin/{default}..HEAD', oneline=True, mute_errors=True).strip())
574573
except Exception: has_commits = False
575574
has_changes = bool(g.status(porcelain=True))
576-
if not has_commits and not has_changes:
577-
raise SystemExit("Nothing to PR: no unpushed commits and no uncommitted changes")
575+
if not has_commits and not has_changes: raise SystemExit("Nothing to PR: no unpushed commits and no uncommitted changes")
578576

579577
slug = re.sub(r'[^a-zA-Z0-9]+', '-', title.lower()).strip('-')[:50]
580578
if len(slug) == 50: slug = slug.rsplit('-', 1)[0]
@@ -607,8 +605,7 @@ def ship_pr(
607605
try: gh.git.delete_ref(f"heads/{pr_branch}")
608606
except Exception: pass
609607

610-
finally:
611-
g.switch(default)
608+
finally: g.switch(default)
612609

613610
g.fetch('origin')
614611
g.reset('--hard', f'origin/{default}')

0 commit comments

Comments
 (0)