Skip to content

Experimental project to build Debian packages from Python virtualenv

License

Notifications You must be signed in to change notification settings

internap/python2debian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python 2 Debian

The goal of this project is to create a Debian package from a Python project using dh-virtualenv and Docker as build environment.

Requirements

  • To build a Debian package the only requirement on your machine is Docker.
  • The Docker image is not rebuilt each time.

Build Debian package from a Python package:

Use the argument python-package:

docker run --rm -v /tmp/debs:/packages internap/python2debian \
    --package-name=almanach-api \
    --package-version=4.0.7 \
    --package-desc="Almanach is awesome" \
    --package-author="Internap Hosting <opensource@internap.com>" \
    --python-package="almanach==4.0.7"
ls /tmp/debs/
almanach-api_4.0.7_amd64.deb

Build package with custom hooks (prerm, postinst, etc.)

docker run --rm \
    -v /tmp/debs:/packages \
    -v /my/local/debian_folder:/debian \
    internap/python2debian \
    --package-name=almanach-api \
    --package-version=4.0.7 \
    --python-package="almanach==4.0.7" \
    --postinst=/debian/almanach-api.postinst \
    --prerm=/debian/almanach-api.prerm

Build package with additional files

docker run --rm \
    -v /tmp/debs:/packages \
    -v /my/local/debian_folder:/debian \
    internap/python2debian \
    --package-name=almanach-api \
    --package-version=4.0.7 \
    --python-package="almanach==4.0.7" \
    --postinst=/debian/almanach-api.postinst \
    --prerm=/debian/almanach-api.prerm \
    --file "/debian/almanach-api.upstart:/etc/init/almanach-api.conf" \
    --file "/debian/almanach-common.logrotate:/etc/logrotate.d/almanach"

Build Debian package from local source folder

Use the argument source-dir. The project must have a setup.py and optionally a debian folder.

docker run --rm \
    -v /tmp:/packages \
    -v /my/local/source/folder:/src \
    internap/python2debian \
    --package-name=myapp \
    --package-version=42 \
    --source-dir=/src

Use another version of Python

Use the arguments python-version and python-bin.

docker run --rm \
    -v /tmp:/packages \
    -v /my/local/source/folder:/src \
    internap/python2debian \
    --package-name=myapp \
    --package-version=42 \
    --python-version=python3.4 \
    --python-bin=/usr/bin/python3.4 \
    --source-dir=/src

Build Docker image locally

make image