diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..4297ef3 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,76 @@ +name: Publish to PyPI + +# Publishing a GitHub release (tag vX.Y.Z) uploads linx-bbn X.Y.Z to PyPI. +# Running this workflow by hand uploads a dev build to TestPyPI instead. +on: + release: + types: [published] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # hatch-vcs reads the version from the git tag + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Build sdist and wheel + run: | + python -m pip install --upgrade pip build twine + python -m build + twine check --strict dist/* + + - name: Smoke-test the wheel + run: | + pip install dist/*.whl + # Run outside the checkout so the installed package is imported, not ./linx + cd "$RUNNER_TEMP" + python -c " + import linx, linx.background, linx.abundances + from linx.nuclear import NuclearRates + for net in ['key_recommended', 'key_PRIMAT_2018', 'key_PRIMAT_2023', 'key_YOF']: + NuclearRates(nuclear_net=net) + print('linx imported from', linx.__file__) + " + + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + publish-testpypi: + if: github.event_name == 'workflow_dispatch' + needs: build + runs-on: ubuntu-latest + environment: testpypi + permissions: + id-token: write # trusted publishing + steps: + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + skip-existing: true + + publish-pypi: + if: github.event_name == 'release' + needs: build + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write # trusted publishing + steps: + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + - uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/docs/index.rst b/docs/index.rst index 073b944..d5a48f2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,7 +11,11 @@ LINX Installation ------------ -To download and install LINX, please visit our `GitHub `_. There you will find detailed instructions for installing LINX and its dependencies. +LINX is pip installable! In a clean conda environment, run + + pip install linx-bbn + +For installing from source, or with the pinned dependency versions that give faster runtimes, please visit our `GitHub `_. Module Structure ---------------- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..f017e4e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,59 @@ +[build-system] +requires = ["hatchling>=1.27", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +# The PyPI name `linx` belongs to an unrelated project; the import name is still `linx`. +name = "linx-bbn" +dynamic = ["version"] +description = "A fast, differentiable, and extensible Big Bang Nucleosynthesis package in JAX" +readme = "README.md" +license = "MIT" +license-files = ["LICENSE.txt"] +requires-python = ">=3.11" +authors = [ + { name = "Cara Giovanetti" }, + { name = "Mariangela Lisanti" }, + { name = "Hongwan Liu" }, + { name = "Siddharth Mishra-Sharma" }, + { name = "Joshua T. Ruderman" }, +] +keywords = ["cosmology", "big bang nucleosynthesis", "BBN", "jax", "differentiable"] +classifiers = [ + "Intended Audience :: Science/Research", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering :: Astronomy", + "Topic :: Scientific/Engineering :: Physics", +] +# Keep in sync with requirements.txt +dependencies = [ + "diffrax==0.7.1", + "equinox>=0.12.0", + "interpax>=0.3.1", + "jax>=0.4.38", + "jaxlib>=0.4.38", + "numpy>=2.0", + "optimistix==0.0.11", +] + +[project.urls] +Homepage = "https://github.com/cgiovanetti/LINX" +Documentation = "https://linx.readthedocs.io" +Issues = "https://github.com/cgiovanetti/LINX/issues" +Paper = "https://arxiv.org/abs/2408.14538" + +[tool.hatch.version] +source = "vcs" + +[tool.hatch.version.raw-options] +# Untagged builds (TestPyPI dry runs) get X.Y.devN; (Test)PyPI rejects +local versions +local_scheme = "no-local-version" + +[tool.hatch.build.targets.wheel] +packages = ["linx"] +exclude = ["*.ipynb"] + +[tool.hatch.build.targets.sdist] +include = ["/linx", "/README.md", "/LICENSE.txt"] +exclude = ["*.ipynb"]