Release and maintain a Python package
Prepare a local release candidate for TaskFlow. You will make one small help-text improvement, identify it as version 1.0.1, build a wheel, and check that an existing user’s saved task still works. The result is a tested file ready for a release decision.
On this page
Pin down the change
In a practice copy of app/taskflow/cli.py, locate the parser for add and change its positional argument to add.add_argument("title", help="Task title to add"). This changes the add --help output. Record the expected behavior in a test so someone maintaining the package can see why the text was added.
Append this test to the capstone’s tests/test_cli.py, where run_cli is already defined.
def test_add_help_describes_title(tmp_path):
data = tmp_path / "tasks.json"
result = run_cli(data, "add", "--help")
assert result.returncode == 0
assert "Task title to add" in result.stdout
assert not data.exists()Update version in pyproject.toml and __version__ in taskflow/__init__.py to 1.0.1. Run the full test suite. Keep a release note with the visible change, supported Python version, and the outcome for existing data files. For this release, the stored schema stays at version 1.
Build and install the candidate
Run these commands from your practice app directory using the build environment prepared earlier. On Windows use the matching Python executable under Scripts. Install the exact wheel into a new environment so an earlier installation cannot mask a missing file.
.build-env/bin/python -m pytest -q tests
.build-env/bin/python -m build --wheel --outdir candidate
python3 -m venv .release-env
.release-env/bin/python -m pip install candidate/taskflow_learning-1.0.1-py3-none-any.whlCheck a previously saved file
Save this script as verify_release.py. Run it from app using .release-env/bin/python -I verify_release.py. The -I option isolates the interpreter from the script directory, preventing an import of the development copy. The temporary folder holds a version-1 fixture with a deliberately nonconsecutive next ID.
from importlib.metadata import version
import json
from pathlib import Path
import subprocess
import sys
from tempfile import TemporaryDirectory
import taskflow
assert version("taskflow-learning") == taskflow.__version__ == "1.0.1"
with TemporaryDirectory() as folder:
path = Path(folder) / "saved.json"
existing = {"id": 4, "title": "From version 1.0.0", "done": True}
path.write_text(json.dumps({
"schema_version": 1, "next_id": 8, "tasks": [existing]
}), encoding="utf-8")
base = [sys.executable, "-I", "-m", "taskflow", "--data", str(path)]
subprocess.run(base + ["add", "New task"], check=True, cwd=folder)
saved = json.loads(path.read_text(encoding="utf-8"))
assert saved["tasks"] == [existing, {"id": 8, "title": "New task", "done": False}]
assert saved["next_id"] == 9
print("Release candidate passed")The command should print Added task 8. followed by Release candidate passed. The test checks that the reader understands old data, the writer preserves its content, and new IDs continue from the stored counter.
Keep a maintenance record
Record the source revision, wheel filename, test results, and one way to recognize the installed version. A SHA-256 digest lets a teammate compare their copy with the tested wheel. Compute it on the wheel you verified; rebuilding from the same revision can produce different archive bytes.
python -m zipfile -l candidate/taskflow_learning-1.0.1-py3-none-any.whl
python -c "from pathlib import Path; import hashlib; p = Path('candidate/taskflow_learning-1.0.1-py3-none-any.whl'); print(hashlib.sha256(p.read_bytes()).hexdigest())"For an exercise, change the fixture’s schema version to 99. Expect a nonzero exit status and compare the file bytes before and after the command. A useful release note can then state exactly how this build responds to an unsupported file format.