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: 0 additions & 17 deletions .bumpversion.cfg

This file was deleted.

1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
data/ filter=lfs diff=lfs merge=lfs -text
*.cif filter=lfs diff=lfs merge=lfs -text
*.cbf filter=lfs diff=lfs merge=lfs -text
uv.lock binary
109 changes: 50 additions & 59 deletions make_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ print_help() {
echo "--no-tag Don't create a tag for the release commit"
echo "--no-edit Don't pause to allow CHANGELOG editing"
echo "--do Actually run. Safety so that no arguments doesnt commit"
# echo "--dry-run, -n Don't do anything"
# echo "--dry-run, -n Don't do anything"
echo
echo "ARG.... Arguments to pass to bump2version"
}
Expand Down Expand Up @@ -54,35 +54,35 @@ _positionals=()
while [[ $# -gt 0 ]]; do
_key="$1"
case "$_key" in
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
-n|--dry-run)
DRY_RUN=true
;;
--allow-nonmain)
ALLOW_NONMAIN=true
;;
--allow-dirty)
ALLOW_DIRTY=true
;;
--no-tag)
NO_TAG=true
;;
--no-edit)
NO_EDIT=true
;;
--do)
DO=true
;;
*)
_positionals+=("$1")
;;
-h | --help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
-n | --dry-run)
DRY_RUN=true
;;
--allow-nonmain)
ALLOW_NONMAIN=true
;;
--allow-dirty)
ALLOW_DIRTY=true
;;
--no-tag)
NO_TAG=true
;;
--no-edit)
NO_EDIT=true
;;
--do)
DO=true
;;
*)
_positionals+=("$1")
;;
esac
shift
done
Expand Down Expand Up @@ -123,40 +123,31 @@ fi
_start_commit="$(git rev-parse HEAD)"

echo "Starting release process"
bump2version_args=(release --list)
bump2version_args=(bump release)
if [[ $ALLOW_DIRTY == true ]]; then
bump2version_args+=(--allow-dirty)
fi
if ! _output="$(set -x; bump2version "${bump2version_args[@]}")"; then
echo "${R}Error: Bump2version failed"
if ! _output="$(
set -x
uvx bump-my-version "${bump2version_args[@]}"
)"; then
echo "${R}Error: Bumpbump-my-version2version failed"
echo "$_output" $NC
exit 1
fi

new_version="$(echo "$_output" | grep new_version | sed -r s,"^.*=",,)"
read_version() {
uv run --no-project --with=toml python3 -c "import toml, pathlib; print(toml.loads(pathlib.Path('pyproject.toml').read_text())['project']['version'])"
}

new_version="$(read_version)"
echo "New version: $BOLD$M$new_version$NC"

echo "Regenerating SWIG files$W"
silently ./regenerate_pycbf.py

# On M1 mac, there are no wheels for numpy, and it doesn't build.
# Numpy is only a runtime requirement so this is safe
echo "Removing numpy from dependencies"
silently cp pyproject.toml pyproject.toml.bak
silently sed -i'' -e 's/numpy = ">=1.17"/# numpy = ">=1.17"/' pyproject.toml

echo "Installing base environment"
silently poetry install

# Restore back for the build
echo "Restoring original pyproject"
silently mv pyproject.toml.bak pyproject.toml

echo "Re-running build for Cython"
silently poetry build

echo "Running towncrier"
silently towncrier --yes --version="$new_version"
silently uvx towncrier build --yes --version="$new_version"

if [[ $NO_EDIT != true ]]; then
echo "Pausing for CHANGELOG editing"
Expand All @@ -168,7 +159,6 @@ fi
echo "Running pre-commit to clean up"
quietly pre-commit run --all || true


echo "${BOLD}Making commit$NC"
quietly git add --update
quietly git commit -n -m "pycbf $new_version"
Expand All @@ -181,29 +171,30 @@ fi
echo "$NC"
echo "Advancing to new development release"

if ! _output="$(set -x; bump2version minor --list)"; then
if ! _output="$(
set -x
uvx bump-my-version bump minor
)"; then
echo "${R}Error: Advancing release tag to next development release"
echo "$_output" $NC
exit 1
fi

new_dev_version="$(echo "$_output" | grep new_version | sed -r s,"^.*=",,)"
new_dev_version="$(read_version)"
echo "New development version: $BOLD$M$new_dev_version$NC"

echo "Regenerating SWIG files$W"
silently ./regenerate_pycbf.py

echo "Re-running build for Cython"
silently poetry build

echo "${BOLD}Making new development commit$NC"
( set -x
(
set -x
git add --update
git commit -n -m "Advance to ${new_dev_version} development series"
)
echo
echo "Successfully released $M$new_version$NC and advanced to $M$new_dev_version$NC"
echo
if [[ $NO_TAG != true ]]; then
echo "Please remember to ${B}git push origin main v$new_version$NC"
echo "Please remember to ${B}git push origin --atomic main v$new_version$NC"
fi
1 change: 1 addition & 0 deletions newsfragments/27.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update release scripts to use uvx and bump-my-version.
22 changes: 19 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ Repository = "https://github.com/dials/pycbf"

[dependency-groups]
dev = [
"bump-my-version",
"Cython~=3.1.1",
"toml~=0.10.2",
"pytest~=6.2.4",
"dials-data",
"bump2version~=1.0.1",
"pytest",
"toml~=0.10.2",
"towncrier",
]

[tool.ruff]
Expand All @@ -46,3 +47,18 @@ filename = "CHANGELOG.rst"
[tool.pytest.ini_options]
addopts = "--regression -ra"
testpaths = ["tests"]

[tool.bumpversion]
parse = "(?P<cbflib_version>\\d+\\.\\d+\\.\\d+)\\.(?P<minor>\\d+)\\.?(?P<release>[a-z]+)?"
current_version = "0.9.6.7.dev"
serialize = ["{cbflib_version}.{minor}.{release}", "{cbflib_version}.{minor}"]

[tool.bumpversion.parts.release]
values = ["dev", "prod"]
optional_value = "prod"
first_value = "dev"

[[tool.bumpversion.files]]
filename = "pyproject.toml"
search = 'version = "{current_version}"'
replace = 'version = "{new_version}"'
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
PYCBF_ROOT = Path(__file__).parent
CBFLIB_INCLUDE = PYCBF_ROOT / "cbflib" / "include"

# Check we have checked out recursive
if not any(PYCBF_ROOT.joinpath(x).is_file() for x in CBF_SOURCES):
raise RuntimeError(
"Error: No CBF sources found. Did you check out --recursive? Run 'git submodule update --init'"
)

extensions = [
Extension(
"pycbf._pycbf",
Expand Down
Loading