{"id":6895,"library":"stdeb","title":"stdeb","description":"stdeb is a Python utility that extends distutils to simplify the creation of Debian source packages from Python packages. It provides new distutils commands (like `sdist_dsc`, `bdist_deb`) and command-line utilities (like `pypi-install`, `py2dsc`) to automate the conversion process. While it attempts to provide sensible defaults, many aspects of the resulting Debian package can be customized via a configuration file. The library maintains a regular release cadence, with version 0.11.0 released in September 2025, continuing active development and support for modern Python versions.","status":"active","version":"0.11.0","language":"en","source_language":"en","source_url":"https://github.com/astraw/stdeb","tags":["debian","packaging","distutils","py2deb","distribution","apt"],"install":[{"cmd":"pip install stdeb","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core dependency for Debian packaging utilities.","package":"python-debian","optional":false},{"reason":"Used in the Python packaging ecosystem for building wheels, which can interact with distutils/setuptools build processes.","package":"wheel","optional":false},{"reason":"While stdeb removed a direct dependency in older versions, it primarily works by extending distutils commands via setup.py, for which setuptools is the de facto standard and provides a distutils shim in Python 3.12+.","package":"setuptools","optional":false}],"imports":[{"note":"stdeb is primarily used via distutils commands specified on the command line, rather than direct Python imports in user code.","symbol":"stdeb.command","correct":"python setup.py --command-packages=stdeb.command <command>"},{"note":"Command-line utility for quick installation from PyPI to a .deb. Use with caution (see warnings).","symbol":"pypi-install","correct":"pypi-install mypackage"}],"quickstart":{"code":"mkdir my_python_project\ncd my_python_project\n\n# Create a dummy setup.py\ncat <<EOF > setup.py\nfrom setuptools import setup, find_packages\n\nsetup(\n    name='my-sample-package',\n    version='0.1.0',\n    packages=find_packages(),\n    scripts=['my_script.py'],\n    description='A simple test package for stdeb.',\n    author='Example User',\n    author_email='user@example.com',\n    install_requires=[],\n)\nEOF\n\n# Create a dummy script\nmkdir my_sample_package\ncat <<EOF > my_sample_package/__init__.py\nEOF\ncat <<EOF > my_sample_package/my_script.py\nimport sys\n\ndef main():\n    print(\"Hello from my_sample_package!\")\n    print(f\"Running with Python {sys.version_info.major}.{sys.version_info.minor}\")\n\nif __name__ == '__main__':\n    main()\nEOF\n\n# Generate a Debian binary package (.deb)\npython3 setup.py --command-packages=stdeb.command bdist_deb\n\necho \"\\nGenerated .deb file(s) in:\"\nls deb_dist/*.deb\n","lang":"bash","description":"This quickstart demonstrates how to create a simple Python project with a `setup.py` file and then use `stdeb` to generate a Debian binary package (`.deb`). The resulting `.deb` file will be found in the `deb_dist` directory. This is the recommended approach for creating distributable packages, rather than using `pypi-install` directly."},"warnings":[{"fix":"Ensure you are running stdeb with Python 3.7+ and have `debhelper` version 12+ installed on your system. If generating Python 2 packages, older stdeb versions (0.10.x and below) might still work on a best-effort basis.","message":"stdeb has removed support for Python 2.x and now requires Python 3.7 or newer. Additionally, it requires a minimum `debhelper` version of 12 for building Debian packages.","severity":"breaking","affected_versions":"0.11.0+"},{"fix":"For production or customized packages, use the `sdist_dsc` or `bdist_deb` distutils commands (e.g., `python setup.py --command-packages=stdeb.command bdist_deb`) and manually verify/customize the generated `debian/` directory.","message":"The `pypi-install` command-line utility provides a quick way to convert and install a PyPI package as a `.deb`, but it does not guarantee proper fulfillment of all Debian package dependencies and bypasses customization options. Manual intervention for dependencies is frequently required.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Build your `.deb` packages on the exact target distribution and version where they will be installed, or target a stable/oldstable Debian distribution for wider compatibility.","message":"Debian packages generated by `stdeb` (especially those with extension modules) are highly sensitive to the build environment. Installing a `.deb` on a different Debian/Ubuntu version than where it was compiled can lead to undefined behavior or breakages.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `setuptools` is installed and up-to-date in your environment. Be aware that the Python packaging ecosystem is evolving beyond `distutils`/`setup.py` towards `pyproject.toml` and other build backends. Monitor stdeb's official channels for updates regarding modern packaging standards.","message":"stdeb relies on extending `distutils` commands via `setup.py`. With Python 3.12+, `distutils` was removed from the standard library. While `setuptools` provides a compatibility shim, direct reliance on `distutils` might lead to future compatibility issues or require specific `setuptools` versions.","severity":"breaking","affected_versions":"Potentially Python 3.12+"},{"fix":"After running `debianize`, inspect and modify `debian/control` to ensure all build dependencies (especially `python3-all`, `dh-python`, and any other required system libraries or Python packages) are correctly listed.","message":"When using the `debianize` command (or `bdist_deb`), `stdeb` generates a `debian/` directory. The `Build-Depends` in the resulting `debian/control` file often requires manual review and adjustment to correctly specify all necessary system-level and Python package build dependencies.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Before using `stdeb`, ensure you install necessary system packages: `sudo apt-get install python3-all debhelper dh-python` (or equivalent for your distribution).","message":"System-level packages like `python3-all` (for Python 3 projects) and `dh-python` are often crucial runtime or build dependencies for `stdeb` to function correctly, but might not be explicitly pulled in by `pip install stdeb` alone. Missing these can lead to cryptic build failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z","problems":[]}