Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nullx5/bd59baa698b0458234aaa120a7d1d6be to your computer and use it in GitHub Desktop.
Save nullx5/bd59baa698b0458234aaa120a7d1d6be to your computer and use it in GitHub Desktop.

Python empaquetado - sdist (Source Distribution) vs bdist (Built Distribution) y crear .deb desde codigo fuente python.

sudo apt install setuptools dh_make devscripts dpkg-dev
pip install setuptool

sdist (Source Distribution)

python setup.py sdist

python -m build --sdist

Ejemplo de salida:


dist/
├── mi_paquete-1.0.0.tar.gz

bdist (Built Distribution)

python setup.py bdist

python -m build --wheel

Ejemplo de salida:


dist/
├── mi_paquete-1.0.0-py3-none-any.whl

Tipos de bdist más comunes:

  • Wheel (.whl): Es el formato estándar moderno y recomendado.

  • Egg (.egg): Formato obsoleto, usado antes de wheel.

  • bdist_wininst: Instalador .exe para Windows. obsoleto, no compatible con Python 3.10 en adelante. python setup.py bdist_wininst

  • bdist_rpm, bdist_deb: Paquetes específicos para distribuciones Linux:

    • bdist_deb:

      • python3 -m pip install stdeb
      • sudo apt install python3-stdeb
      • python3 setup.py --command-packages=stdeb.command bdist_deb
      • deb_dist/python3-mi-paquete_1.0.0-1_all.deb
    • dh-python y debuild: crea paquetes con estándares de Debian, recomendado empaquetar módulos de Python en Debian:

      • sudo apt install dh-python devscripts
      • Generar el sdist - dist/mipaquete-1.0.0.tar.gz
      • 7z x mipaquete-1.0.0.tar.gz
      • cd mipaquete-1.0.0
      • dh_make -p mipaquete-1.0.0 --createorig # dh_make no permite guiones bajos (_) en el nombre del paquete
      • dpkg-buildpackage -us -uc #crea .deb
      • debuild -S -sa # crea fuentes y los firma ideal para launchpad
      • si da algun error instalar pybuild-plugin-pyproject y usar debuild --buildsystem=pybuild --with=pybuild o editar debian/rules
      • Falta probar subirlo a launchpad - tal vez de errores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment