bmad-sim / bmad-sim/PySciBmad

Register scibmad on PyPI and set up a repeatable publish path

Open
#4 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

`v0.1.0` is tagged and [released on GitHub](https://github.com/bmad-sim/PySciBmad/releases/tag/v0.1.0) with both artifacts attached, but nothing has been uploaded to PyPI yet, so `pip install scibmad` (as the README instructs) still fails. The remaining work is registering the project and wiring up a repeatable publish path.

## Already done

- `v0.1.0` tag on `a95f633`, GitHub release created with `scibmad-0.1.0-py3-none-any.whl` and `scibmad-0.1.0.tar.gz` attached.
- Packaging metadata corrected in #3 — project URLs now point at this repo rather than SciBmad.jl (PyPI renders them in the sidebar, so bug reports would have gone to the wrong tracker), and trove classifiers were added.
- Build verified: `python -m build` produces both artifacts, `twine check` passes on each, the wheel contains `_glue.jl` and `juliapkg.json` (the package does not work without them), and installing the built wheel into a clean venv imports and runs a twiss calculation end-to-end.

## Decision needed: how to publish

### Option A — Trusted Publishing via GitHub Actions (recommended)

PyPI's OIDC flow. No API token is ever created, stored, or pasted anywhere, and the publish identity is this repository rather than an individual's account — which matches how the rest of the SciBmad packages are owned.

1. On pypi.org, create a **pending publisher** (Your projects → Publishing → Add a pending publisher):
- PyPI project name: `scibmad`
- Owner: `bmad-sim`
- Repository: `PySciBmad`
- Workflow name: `release.yml`
- Environment: `pypi`
2. Add `.github/workflows/release.yml`:

```yaml
name: Publish to PyPI

on:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- run: pipx run build
- run: pipx run twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

publish:
needs: build
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write # required for trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- uses: pypa/gh-action-pypi-publish@release/v1
```

3. Re-run the workflow against the existing `v0.1.0` release (or cut `v0.1.1` if a re-tag is preferred).

Every subsequent release is then just a tag plus a GitHub release.

### Option B — one-off manual upload

Faster, but ties the release to whoever's token is used:

```bash
python -m build
twine check dist/*
twine upload dist/*
```

## Worth deciding at the same time

- **Release timing.** `0.1.0` ships with two documented upstream `DefExpr` limitations — `abs()` raises `MethodError`, and operators drop an explicitly supplied `Context`. Both are fixed by [bmad-sim/Beamlines.jl#161](https://github.com/bmad-sim/Beamlines.jl/pull/161), which is still awaiting Technical Committee review. Options are to publish `0.1.0` now with the caveats documented, or hold until #161 merges and releases so the first PyPI release has no known bugs.
- **Who owns the PyPI project.** Whichever option is chosen, more than one maintainer should have owner rights so releases are not blocked on one person.
- **conda-forge.** The README says a conda-forge package is planned; issue #76 specifically calls for `conda install scibmad`. That needs a feedstock and is worth tracking separately once PyPI is live.

## No CI yet

There is no `.github/workflows` directory at all, so nothing runs the test suite on push. Option A adds a release workflow but not a test workflow; a `pytest` job would be worth adding alongside it, noting that a cold run pays for a full Julia install and precompile (roughly 10 minutes) and benefits from caching `~/.julia`.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the existing v0.1.0 GitHub release and the proposed .github/workflows/release.yml; review the documented build and twine check commands, then verify the PyPI pending-publisher settings for this repository. Done means the selected publishing path successfully uploads the existing artifacts and makes pip install scibmad work, with the ownership and release-timing decisions resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, python
Domain
ci-cd, release
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.