Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/bump.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Dev copy of pyproject.toml used in CI
pyproject-dev.toml

# Local install dir
install-example

Expand Down
4 changes: 4 additions & 0 deletions changelog/13.fix.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
63 changes: 63 additions & 0 deletions scripts/strip-sdist.py
Original file line number Diff line number Diff line change
@@ -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()