This packaging virtual environment is dedicated to building, validating, and distributing Python projects. It supports PyPI uploads and Debian (.deb) package builds.
Install these APT packages before using this environment:
sudo apt update
sudo apt install -y \
python3-venv python3-pip \
fakeroot devscripts debhelper dh-python lintian gpg| Package | Purpose |
|---|---|
python3-venv |
Create virtual environments |
python3-pip |
Install Python packages |
fakeroot |
Build .deb files without real root permissions |
devscripts |
Tools like debuild, dch for Debian packaging |
debhelper |
Scripts to help Debian packaging |
dh-python |
Integrate Python packages into Debian builds |
lintian |
Validate .deb quality |
gpg |
Sign packages or uploads if needed |
cd ~/pydev/packaging
python3 -m venv venv
source venv/bin/activateUpgrade and install critical Python packaging tools:
pip install --upgrade pip setuptools wheel
pip install build twine stdeb check-manifest validate-pyproject setuptools_scmOptional extras:
pip install hatchling flitpython -m buildArtifacts appear under dist/.
Create ~/.pypirc:
[distutils]
index-servers =
pypi
[pypi]
username = __token__
password = pypi-<your-token-here>Then upload:
twine upload dist/*Simple build:
python setup.py --command-packages=stdeb.command bdist_debFull manual control:
debuild -us -ucCheck .deb with:
lintian ../your-package_*.debBefore releasing:
check-manifest
validate-pyprojectUseful when using pyproject.toml structure.
~/pydev/packaging/
├── README.md
├── venv/ # Virtual environment only for packaging
├── Makefile # (Optional) Automate builds
├── project-srcs/ # (Optional) Source trees ready to package
-
Problem: Missing system package?
- Solution: Re-run
apt installlist from Section 1.
- Solution: Re-run
-
Problem: GPG key error during PyPI upload?
- Solution: Run
gpg --list-keysand configure signing properly, or upload without signing if using token auth.
- Solution: Run
-
Problem: Wrong Python version?
- Solution: Create a separate virtual environment under Python 3.10/3.11.
- Build from clean git tags.
- Use setuptools_scm for versioning if possible.
- Always test installs inside a fresh venv.
- Only install packaging-specific tools into this environment.
- **Use **`` before uploads.
Updated: 2025-04-27
Maintained by Rick's Lab.