diff --git a/.github/workflows/bump.yaml b/.github/workflows/bump.yaml index 478c1ae..64d5baa 100644 --- a/.github/workflows/bump.yaml +++ b/.github/workflows/bump.yaml @@ -51,12 +51,25 @@ jobs: # Bump uv version --no-sync --bump ${{ github.event.inputs.bump_rule }} + # Create a copy of pyproject.toml which we can use for restoring + cp pyproject.toml pyproject-dev.toml NEW_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml` echo "Bumping to version $NEW_VERSION" # Build CHANGELOG uv run --no-sync towncrier build --yes --version v$NEW_VERSION + # Add locked targets to pyproject.toml + uv run --no-sync python scripts/add-locked-targets-to-pyproject-toml.py + # Propogate new version to meson.build + uv run --no-sync python scripts/propogate-pyproject-metadata.py + + # Lock everything again + git add . + uv run --no-sync pre-commit run --all-files + uv sync --no-editable --all-extras --group all-dev + git add . + uv run --no-sync pre-commit run --all-files # Commit, tag and push git commit -a -m "bump: version $BASE_VERSION -> $NEW_VERSION" @@ -67,8 +80,12 @@ jobs: # version as the tagged commit) BASE_VERSION=`sed -ne 's/^version = "\([0-9\.]*\)"/\1/p' pyproject.toml` + # Put pyproject.toml back + mv pyproject-dev.toml pyproject.toml # Bump to pre-release of next version uv version --no-sync --bump post + # Propogate dev version back to meson.build + uv run --no-sync python scripts/propogate-pyproject-metadata.py NEW_VERSION=`sed -ne 's/^version = "\([0-9\.post]*\)"/\1/p' pyproject.toml` echo "Bumping version $BASE_VERSION > $NEW_VERSION" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 79f9590..4230068 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -232,13 +232,22 @@ jobs: run: | uv run --no-sync python scripts/add-locked-targets-to-pyproject-toml.py cat pyproject.toml - uv build + uv build --sdist # Just in case, undo the changes to `pyproject.toml` git restore --staged . && git restore . - - name: Check build + - name: Check included files in source distribution run: | tar -tvf dist/example_fgen_basic-*.tar.gz --wildcards '*example_fgen_basic/py.typed' tar -tvf dist/example_fgen_basic-*.tar.gz --wildcards 'example_fgen_basic-*/LICENCE' + - name: Check source distribution can be used for installation + run: | + cd dist + ls + python3 -m venv venv + # TODO: alter for windows + source venv/bin/activate + pip install example_fgen_basic* + python -c 'from example_fgen_basic.get_wavelength import get_wavelength_plain; print(get_wavelength_plain(23.4))' check-dependency-licences: strategy: diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 1b5f422..ef24f4c 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -34,7 +34,6 @@ jobs: uv-dependency-install-flags: "--all-extras --group dev" - name: Publish to PyPI run: | - uv run --no-sync python scripts/add-locked-targets-to-pyproject-toml.py # TODO: move to using cibuildwheel so we have wheels for multiple platforms and python versions # starting docs: https://cibuildwheel.pypa.io/en/stable/ uv build --sdist diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8d57a68..17dbefe 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -31,7 +31,6 @@ jobs: echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV - name: Build package for PyPI run: | - uv run --no-sync python scripts/add-locked-targets-to-pyproject-toml.py uv build # Just in case, undo the changes to `pyproject.toml` git restore --staged . && git restore . diff --git a/.gitignore b/.gitignore index 4feda63..1f87080 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Dev copy of pyproject.toml used in CI +pyproject-dev.toml + # Local install dir install-example diff --git a/changelog/13.fix.md b/changelog/13.fix.md new file mode 100644 index 0000000..0c1953a --- /dev/null +++ b/changelog/13.fix.md @@ -0,0 +1,4 @@ +Fixed building: + +- now include the `locked` targets in releases +- stripped out all superfluous files from the source distribution and check that the package can be installed from the source distribution alone diff --git a/meson.build b/meson.build index c7f8970..82c4120 100644 --- a/meson.build +++ b/meson.build @@ -142,6 +142,9 @@ if pyprojectwheelbuild_enabled endforeach + # dist - script to reduce the *tar.gz + meson.add_dist_script(py, files('scripts' / 'strip-sdist.py')) + else ## Fortran library standalone compilation diff --git a/scripts/strip-sdist.py b/scripts/strip-sdist.py new file mode 100644 index 0000000..9098e36 --- /dev/null +++ b/scripts/strip-sdist.py @@ -0,0 +1,63 @@ +""" +Script file to strip unwanted files from dist tarball +""" + +import os +import shutil +from pathlib import Path + + +def main(): + """ + Strip the files we don't want in the tarball + """ + dist_root = os.environ.get("MESON_DIST_ROOT") + + # Files/Folders to strip from the *.tar.gz + exclude = [ + ".github", + "docs", + "tests", + "changelog", + "stubs", + Path("scripts") / "add-locked-targets-to-pyproject-toml.py", + Path("scripts") / "inject-srcs-into-meson-build.py", + Path("scripts") / "propogate-pyproject-metadata.py", + Path("scripts") / "test-install.py", + Path("scripts") / "changelog-to-release-template.py", + Path("scripts") / "print-conda-recipe-pins.py", + # Keep this one + # Path("scripts") / "strip-sdist.py", + ".pre-commit-config.yaml", + ".gitignore", + ".readthedocs.yaml", + "Makefile", + "environment-docs-conda-base.yml", + "mkdocs.yml", + "uv.lock", + "requirements-docs-locked.txt", + "requirements-incl-optional-locked.txt", + "requirements-locked.txt", + "requirements-only-tests-locked.txt", + "requirements-only-tests-min-locked.txt", + "requirements-upstream-dev.txt", + ".copier-answers.yml", + ".fprettify.rc", + ] + + # Strip + for path in exclude: + abs_path = os.path.join(dist_root, path) + if not os.path.exists(abs_path): + msg = f"File not found: {abs_path}" + raise FileNotFoundError(msg) + + if os.path.isdir(abs_path): + shutil.rmtree(abs_path) + + elif os.path.isfile(abs_path): + os.remove(abs_path) + + +if __name__ == "__main__": + main()