Skip to content

Commit 4a6b0b1

Browse files
shixishclaude
andcommitted
Rename PyPI distribution to diffbot (3.0.0); final diffbot-python 0.3.0
The import name stays `diffbot`; only the distribution name moves. 3.0.0 sorts above the unrelated 2012-2015 releases (0.1-2.0.0, now yanked) on that name. legacy/diffbot-python builds a final, frozen diffbot-python 0.3.0 with the same code, a LEGACY README/summary, and no dependency on diffbot, so `pip install -U diffbot-python` upgrades cleanly instead of deleting shared files. Importing diffbot warns (FutureWarning) whenever diffbot-python is installed, pointing at the migration command. Makefile release targets take PKG/PYPROJECT; build-legacy, release-legacy and release-test-legacy ship the final diffbot-python. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 076cd2e commit 4a6b0b1

10 files changed

Lines changed: 188 additions & 27 deletions

File tree

‎Makefile‎

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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

33
test:
44
uv run --extra dev pytest
@@ -9,9 +9,24 @@ test-live:
99
clean:
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+
1217
build: 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.
1631
bump-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.
7796
verify-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

88107
verify-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

‎README.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Diffbot Python Library
22

3+
> ⚠️ **The PyPI package is now [`diffbot`](https://pypi.org/project/diffbot/)** (`pip install diffbot`).
4+
> `diffbot-python` is legacy and its final release (0.3.0) will never be updated.
5+
> See [Installation](#installation) to migrate.
6+
37
Python client library for [Diffbot](https://www.diffbot.com) APIs.
48

59

@@ -14,9 +18,13 @@ curl -fsSL https://raw.githubusercontent.com/diffbot/diffbot-python/main/install
1418
If you prefer, the full Python library can also be installed with pip:
1519

1620
```bash
17-
python3 -m pip install diffbot-python
21+
python3 -m pip install diffbot
1822
```
1923

24+
> This package was formerly published as `diffbot-python`, whose final release (0.3.0) gets no further updates.
25+
> If you're upgrading from it, run `pip uninstall diffbot-python && pip install --force-reinstall diffbot`
26+
> and replace `diffbot-python` with `diffbot` in your requirements.
27+
2028
For local development:
2129

2230
```bash

‎install.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ if [ -e "$target" ]; then
127127
info "but your Python package manager still treats the file as its own — a later"
128128
info "'pip install --upgrade' / 'uv tool upgrade' could clobber it again, and an"
129129
info "uninstall would delete it. To avoid the conflict, remove the managed copy first:"
130-
info " pip uninstall diffbot-python # or: uv tool uninstall diffbot-python"
130+
info " pip uninstall diffbot # or: uv tool uninstall diffbot (older installs: diffbot-python)"
131131
info ""
132132
info "Proceeding to overwrite ${target}..."
133133
else
@@ -162,8 +162,8 @@ if [ -n "$existing" ] && [ "$existing" != "$target" ]; then
162162
info "Note: another '${BIN_NAME}' is first on your PATH and will take precedence:"
163163
info " ${existing}"
164164
if is_python_console_script "$existing"; then
165-
info " (it looks pip/uv-managed; remove it with 'pip uninstall diffbot-python'"
166-
info " or 'uv tool uninstall diffbot-python', or put ${BIN_DIR} earlier on PATH.)"
165+
info " (it looks pip/uv-managed; remove it with 'pip uninstall diffbot'"
166+
info " or 'uv tool uninstall diffbot' (older installs: diffbot-python), or put ${BIN_DIR} earlier on PATH.)"
167167
fi
168168
fi
169169

‎legacy/diffbot-python/LICENSE‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Diffbot
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎legacy/diffbot-python/README.md‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# ⚠️ LEGACY PACKAGE — `diffbot-python` is now `diffbot` ⚠️
2+
3+
> ## 🛑 Do not install `diffbot-python`. Install [`diffbot`](https://pypi.org/project/diffbot/) instead:
4+
>
5+
> ```bash
6+
> pip uninstall diffbot-python
7+
> pip install diffbot
8+
> ```
9+
>
10+
> **This is the final release of `diffbot-python` (0.3.0). It will never be updated again**:
11+
> no bug fixes, no new Diffbot API features, no security fixes.
12+
13+
---
14+
15+
The Diffbot Python library and `db` CLI now live at
16+
**[diffbot](https://pypi.org/project/diffbot/)**. The import name is unchanged
17+
(`import diffbot`), so no code changes are needed.
18+
19+
This release contains the same code as `diffbot` 3.0.0 so existing installs keep
20+
working, but it prints a warning on every import until you migrate.
21+
22+
## Migrating
23+
24+
1. Replace `diffbot-python` with `diffbot` in your `requirements.txt`, `pyproject.toml`, etc.
25+
2. Uninstall the old package **before** installing the new one:
26+
27+
```bash
28+
pip uninstall diffbot-python
29+
pip install diffbot
30+
```
31+
32+
Both packages provide the same `diffbot` module, so uninstalling
33+
`diffbot-python` after `diffbot` is installed deletes files that `diffbot`
34+
needs. If that happened, run `pip install --force-reinstall diffbot`.
35+
36+
Source and issues: <https://github.com/diffbot/diffbot-python>.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Final release under the old distribution name. diffbot-python was renamed to
2+
# diffbot (3.0.0+). This release freezes the current library code under the old
3+
# name and warns on import, so `pip install -U diffbot-python` keeps working
4+
# while pointing users at the new package. It deliberately does NOT depend on
5+
# diffbot: both ship the same top-level `diffbot` module, and installing them
6+
# together lets pip delete one's files when it uninstalls the other.
7+
#
8+
# `make build-legacy` copies ../../src next to this file before building, so
9+
# keep dependencies and scripts in step with the main pyproject.toml.
10+
# Published with `make release-legacy`.
11+
[build-system]
12+
requires = ["hatchling"]
13+
build-backend = "hatchling.build"
14+
15+
[project]
16+
name = "diffbot-python"
17+
version = "0.3.0"
18+
description = "⚠️ LEGACY — renamed to diffbot. Final release, no further updates: pip install diffbot"
19+
readme = "README.md"
20+
requires-python = ">=3.9"
21+
license = "MIT"
22+
license-files = ["LICENSE"]
23+
authors = [
24+
{ name = "Jerome Choo", email = "jerome@diffbot.com" },
25+
{ name = "Mike Tung", email = "miket@diffbot.com" }
26+
]
27+
classifiers = [
28+
"Development Status :: 7 - Inactive",
29+
"Programming Language :: Python :: 3",
30+
"Programming Language :: Python :: 3 :: Only",
31+
]
32+
dependencies = [
33+
"httpx>=0.27.0",
34+
"click>=8.1.0",
35+
"rich>=13.0.0",
36+
]
37+
38+
[project.urls]
39+
Homepage = "https://pypi.org/project/diffbot/"
40+
Repository = "https://github.com/diffbot/diffbot-python"
41+
42+
[project.scripts]
43+
db = "diffbot.cli:main"
44+
45+
[tool.hatch.build.targets.wheel]
46+
packages = ["src/diffbot"]

‎pyproject.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ requires = ["hatchling"]
33
build-backend = "hatchling.build"
44

55
[project]
6-
name = "diffbot-python"
7-
version = "0.2.3"
6+
name = "diffbot"
7+
version = "3.0.0"
88
description = "Python client library for Diffbot APIs"
99
readme = "README.md"
1010
requires-python = ">=3.9"

‎scripts/build_binary.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ log "Running PyInstaller"
111111
--workpath "$WORK_DIR" \
112112
--specpath "$WORK_DIR" \
113113
--collect-submodules diffbot \
114-
--copy-metadata diffbot-python \
114+
--copy-metadata diffbot \
115115
"$ENTRY_SCRIPT" >&2
116116

117117
BINARY="${OUTPUT_DIR}/${ASSET}"

‎src/diffbot/__init__.py‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,35 @@
22
diffbot - Python client library for the Diffbot APIs.
33
"""
44

5+
import warnings as _warnings
56
from importlib.metadata import PackageNotFoundError, version as _version
67

7-
try:
8-
__version__ = _version("diffbot-python")
9-
except PackageNotFoundError: # not installed (e.g. running from a source tree)
10-
__version__ = "0.0.0"
8+
def _installed_version(dist: str):
9+
try:
10+
return _version(dist)
11+
except PackageNotFoundError:
12+
return None
13+
14+
15+
# The distribution was renamed from diffbot-python to diffbot. The final
16+
# diffbot-python release ships this same code (see legacy/diffbot-python), so
17+
# fall back to its version when that's what is installed.
18+
_legacy_version = _installed_version("diffbot-python")
19+
# "0.0.0" when not installed (e.g. running from a source tree).
20+
__version__ = _installed_version("diffbot") or _legacy_version or "0.0.0"
21+
22+
# Both distributions ship this module, so a diffbot-python install (alone, or
23+
# left over next to diffbot) should migrate. FutureWarning, unlike
24+
# DeprecationWarning, is shown by default wherever the import happens.
25+
if _legacy_version is not None:
26+
_warnings.warn(
27+
"diffbot-python has been renamed to diffbot and will receive no further "
28+
"updates. Run `pip uninstall diffbot-python && pip install "
29+
"--force-reinstall diffbot` and replace diffbot-python with diffbot in "
30+
"your requirements.",
31+
FutureWarning,
32+
stacklevel=2,
33+
)
1134

1235
from ._auth import resolve_token
1336
from .ask import json_schema_format

‎uv.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)