1- .PHONY : test test-live build clean bump-patch bump-minor bump-major set-token-pypi set-token-testpypi release-test release verify-release-test verify-release
1+ .PHONY : test test-live build build-legacy release-legacy release-test-legacy clean bump-patch bump-minor bump-major set-token-pypi set-token-testpypi release-test release _release-test _release verify-release-test verify-release
22
33test :
44 uv run --extra dev pytest
@@ -9,9 +9,24 @@ test-live:
99clean :
1010 rm -rf dist build * .egg-info
1111
12+ # Distribution to publish/verify. The legacy targets override this with
13+ # PKG=diffbot-python to ship the final diffbot-python release.
14+ PKG ?= diffbot
15+ PYPROJECT ?= pyproject.toml
16+
1217build : clean
1318 uv build
1419
20+ # Build the final diffbot-python release into dist/: today's src/diffbot under
21+ # the old name (see legacy/diffbot-python). Staged in build/ because the package
22+ # code lives outside that directory.
23+ build-legacy : clean
24+ mkdir -p build
25+ cp -R legacy/diffbot-python build/legacy
26+ cp -R src build/legacy/src
27+ find build/legacy -name __pycache__ -prune -exec rm -rf {} +
28+ uv build build/legacy --out-dir dist
29+
1530# Version bumps: edits pyproject.toml in place and prints old => new.
1631bump-patch :
1732 uv version --bump patch
@@ -39,11 +54,13 @@ set-token-testpypi:
3954
4055# Publish to TestPyPI. Token comes from macOS Keychain (service: pypi-token-testpypi).
4156# The `@` on the recipe lines hides the actual command so the token never appears in output.
42- release-test : build
43- @VERSION=$$(grep '^version' pyproject.toml | head -1 | cut -d'"' -f2 ) && \
44- STATUS=$$(curl -s -o /dev/null -w "%{http_code}" "https://test.pypi.org/pypi/diffbot-python/$$VERSION/json" ) && \
57+ release-test : build _release-test
58+
59+ _release-test :
60+ @VERSION=$$(grep '^version' $(PYPROJECT ) | head -1 | cut -d'"' -f2 ) && \
61+ STATUS=$$(curl -s -o /dev/null -w "%{http_code}" "https://test.pypi.org/pypi/$(PKG ) /$$VERSION/json" ) && \
4562 if [ " $$ STATUS" = " 200" ]; then \
46- echo " ERROR: diffbot-python $$ VERSION is already on TestPyPI. Bump the version in pyproject.toml." ; \
63+ echo " ERROR: $( PKG ) $$ VERSION is already on TestPyPI. Bump the version in pyproject.toml." ; \
4764 exit 1; \
4865 fi
4966 @TOKEN=$$(security find-generic-password -s pypi-token-testpypi -w 2>/dev/null ) && \
@@ -54,14 +71,16 @@ release-test: build
5471 UV_PUBLISH_TOKEN=" $$ TOKEN" uv publish --publish-url https://test.pypi.org/legacy/
5572
5673# Publish to real PyPI. Confirmation gate before upload (PyPI does not allow re-uploads).
57- release : build
58- @VERSION=$$(grep '^version' pyproject.toml | head -1 | cut -d'"' -f2 ) && \
59- STATUS=$$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/diffbot-python/$$VERSION/json" ) && \
74+ release : build _release
75+
76+ _release :
77+ @VERSION=$$(grep '^version' $(PYPROJECT ) | head -1 | cut -d'"' -f2 ) && \
78+ STATUS=$$(curl -s -o /dev/null -w "%{http_code}" "https://pypi.org/pypi/$(PKG ) /$$VERSION/json" ) && \
6079 if [ " $$ STATUS" = " 200" ]; then \
61- echo " ERROR: diffbot-python $$ VERSION is already on PyPI. Bump the version in pyproject.toml." ; \
80+ echo " ERROR: $( PKG ) $$ VERSION is already on PyPI. Bump the version in pyproject.toml." ; \
6281 exit 1; \
6382 fi && \
64- echo " About to publish diffbot-python $$ VERSION to PyPI. This cannot be undone." && \
83+ echo " About to publish $( PKG ) $$ VERSION to PyPI. This cannot be undone." && \
6584 read -p " Type the version to confirm: " CONFIRM && \
6685 [ " $$ CONFIRM" = " $$ VERSION" ] || { echo " Aborted." ; exit 1; }
6786 @TOKEN=$$(security find-generic-password -s pypi-token-pypi -w 2>/dev/null ) && \
@@ -75,20 +94,28 @@ release: build
7594# `cd $$TMP` before running python so CWD doesn't shadow the venv install with this repo's source.
7695# Deps live on prod PyPI, so TestPyPI install needs --extra-index-url.
7796verify-release-test :
78- @VERSION=$$(grep '^version' pyproject.toml | head -1 | cut -d'"' -f2 ) && \
97+ @VERSION=$$(grep '^version' $( PYPROJECT ) | head -1 | cut -d'"' -f2 ) && \
7998 TMP=$$(mktemp -d ) && \
8099 uv venv --python 3.12 $$ TMP/.venv > /dev/null 2>&1 && \
81100 uv pip install --quiet --python $$ TMP/.venv/bin/python \
82101 --index-url https://test.pypi.org/simple/ \
83102 --extra-index-url https://pypi.org/simple/ \
84- " diffbot-python ==$$ VERSION" && \
103+ " $( PKG ) ==$$ VERSION" && \
85104 (cd $$ TMP && $$ TMP/.venv/bin/python -c " import diffbot; print('TestPyPI install OK:', diffbot.__version__)" ) && \
86105 rm -rf $$ TMP
87106
88107verify-release :
89- @VERSION=$$(grep '^version' pyproject.toml | head -1 | cut -d'"' -f2 ) && \
108+ @VERSION=$$(grep '^version' $( PYPROJECT ) | head -1 | cut -d'"' -f2 ) && \
90109 TMP=$$(mktemp -d ) && \
91110 uv venv --python 3.12 $$ TMP/.venv > /dev/null 2>&1 && \
92- uv pip install --quiet --python $$ TMP/.venv/bin/python " diffbot-python ==$$ VERSION" && \
111+ uv pip install --quiet --python $$ TMP/.venv/bin/python " $( PKG ) ==$$ VERSION" && \
93112 (cd $$ TMP && $$ TMP/.venv/bin/python -c " import diffbot; print('PyPI install OK:', diffbot.__version__)" ) && \
94113 rm -rf $$ TMP
114+
115+ # Publish the final diffbot-python release. Reuses the targets above with the
116+ # legacy package's name/pyproject; `make build` is swapped for build-legacy.
117+ release-test-legacy : build-legacy
118+ @$(MAKE ) --no-print-directory _release-test PKG=diffbot-python PYPROJECT=legacy/diffbot-python/pyproject.toml
119+
120+ release-legacy : build-legacy
121+ @$(MAKE ) --no-print-directory _release PKG=diffbot-python PYPROJECT=legacy/diffbot-python/pyproject.toml
0 commit comments