Package: py2deb
The Python packagepy2debconverts Python source distributions to Debian
binary packages (the ones used for installation). It usespip-accel(based onpip) to download, unpack and compile Python packages. Because of thispy2debis compatible with the command line interface of thepip installcommand.
For example you can specify packages to convert as command line arguments but
you can also userequirement filesif you want.During the conversion process dependencies are automatically taken into account
and converted as well so you don’t actually have to use requirement files
including transitive dependencies. In fact you might prefer not explicitly
listing your transitive dependencies in requirement files becausepy2debwill
translate the version constraints of Python packages into Debian package
relationships.Thepy2debpackage is currently tested onCPython2.7, 3.5, 3.6, 3.7 andPyPy2 and 3. Unfortunately Python 3.8+ is not yet supported (see below). For
usage instructions please refer to the documentation hosted onRead The
Docs.InstallationUsageCommand lineFuture improvementsPython 3.8+ compatibilityInstallation of system wide filesConversion of binary wheelsFull PEP-440 compatibilitySimilar projectsContactLicenseInstallationThepy2debpackage is available onPyPI, so installation is very simple:$pipinstallpy2debThere are some system dependencies which you have to install as well:$sudoapt-getinstalldpkg-devfakerootOptionally you can also installLintian(which is not a hard dependency but
more of a “nice to have”):$sudoapt-getinstalllintianWhen Lintian is installed it will be run automatically to sanity check
converted packages. This slows down the conversion process somewhat but can be
very useful, especially when working on py2deb itself. Currently py2deb doesn’t
fail when Lintian reports errors, this is due to the unorthodox ways in which
py2deb can be used. This may change in the future as py2deb becomes more
mature.UsageThere are two ways to use thepy2debpackage: As the command line programpy2deband as a Python API. For details about the Python API please refer
to the API documentation hosted onRead the Docs. The command line interface
is described below.Command lineUsage:py2deb [OPTIONS] …Convert Python packages to Debian packages according to the given
command line options (see below). The command line arguments are the
same as accepted by the “pip install” command because py2deb invokes
pip during the conversion process. This means you can name the
package(s) to convert on the command line but you can also use
“requirement files” if you prefer.If you want to pass command line options to pip (e.g. because you want
to use a custom index URL or a requirements file) then you will need
to tell py2deb where the options for py2deb stop and the options for
pip begin. In such cases you can use the following syntax:$py2deb-r/tmp---rrequirements.txtSo the “–” marker separates the py2deb options from the pip options.Supported options:OptionDescription-c,--config=FILENAMELoad a configuration file. Because the command line arguments are processed
in the given order, you have the choice and responsibility to decide if
command line options override configuration file options or vice versa.
Refer to the documentation for details on the configuration file format.The default configuration files /etc/py2deb.ini and ~/.py2deb.ini are
automatically loaded if they exist. This happens before environment
variables and command line options are processed.Can also be set using the environment variable$PY2DEB_CONFIG.-r,--repository=DIRECTORYChange the directory where *.deb archives are stored. Defaults to
the system wide temporary directory (which is usually /tmp). If
this directory doesn’t exist py2deb refuses to run.Can also be set using the environment variable$PY2DEB_REPOSITORY.--use-system-package=PYTHON_PACKAGE_NAME,DEBIAN_PACKAGE_NAMEExclude a Python package (the name before the comma) from conversion and
replace references to the Python package with a specific Debian package
name. This allows you to use system packages for specific Python
requirements.--name-prefix=PREFIXSet the name prefix used during the name conversion from Python to
Debian packages. Defaults to “python”. The name prefix and package
names are always delimited by a dash.Can also be set using the environment variable$PY2DEB_NAME_PREFIX.--no-name-prefix=PYTHON_PACKAGE_NAMEExclude a Python package from having the name prefix applied
during the package name conversion. This is useful to avoid
awkward repetitions.--rename=PYTHON_PACKAGE_NAME,DEBIAN_PACKAGE_NAMEOverride the package name conversion algorithm for the given pair
of package names. Useful if you don’t agree with the algorithm :-)--install-prefix=DIRECTORYOverride the default system wide installation prefix. By setting
this to anything other than “/usr” or “/usr/local” you change the
way py2deb works. It will build packages with a file system layout
similar to a Python virtual environment, except there will not be
a Python executable: The packages are meant to be loaded by
modifying Python’s module search path. Refer to the documentation
for details.Can also be set using the environment variable$PY2DEB_INSTALL_PREFIX.--install-alternative=LINK,PATHUse Debian’s “update-alternatives” system to add an executable
that’s installed in a custom installation prefix (see above) to
the system wide executable search path. Refer to the documentation
for details.--python-callback=EXPRESSIONSet a Python callback to be called during the conversion process. Refer to
the documentation for details about the use of this feature and the syntax
ofEXPRESSION.Can also be set using the environment variable$PY2DEB_CALLBACK.--report-dependencies=FILENAMEAdd the Debian relationships needed to depend on the converted
package(s) to the given control file. If the control file already
contains relationships the additional relationships will be added
to the control file; they won’t overwrite existing relationships.-y,--yesInstruct pip-accel to automatically install build time dependencies
where possible. Refer to the pip-accel documentation for details.Can also be set using the environment variable$PY2DEB_AUTO_INSTALL.-v,--verboseMake more noise :-).-h,--helpShow this message and exit.Future improvementsThe following sections list possible improvements to the project:Python 3.8+ compatibilityInstallation of system wide filesConversion of binary wheelsFull PEP-440 compatibilityPython 3.8+ compatibilityThepy2debproject builds on top ofpip-accel, which was developed between
2013 and 2015 on top ofpip >= 7.0, < 7.2. Since that timepiphas grown
enormously: At the time of writing (in August 2020) we’re now at pip 20!None of the improvements made between pip 7-20 are available in pip-accel and
py2deb and this has become somewhat of a glaring issue that plenty of users
have run into (see#17,#18,#27and#31).Known issues being caused by this include:The old pip version prevents Python 3.8+ compatibility.The old pip version doesn’t know aboutpython_requiresmetadata provided
by PyPI and this forces users to maintain constraints files themselves, even
though this shouldn’t be necessary.While pip-accel supports installation from wheels, it was never exposed via
the Python API and so py2deb lacks support for converting wheels (it
currently needs source distributions).The current state of affairs is best summarized inthis comment. I’m hoping
to complete the upgrade to newer pip and pip-accel releases in the coming weeks
(as of this writing in August 2020) but can’t commit to a date.Installation of system wide filesFind a way to facilitate (explicit / opt-in) installation of system wide files
(not related to Python per se) based on a Python distribution? This could
significantly reduce the need for “wrapper packages” that basically just pull
in packages converted by py2deb and drop a few configuration files into place.Related issues:See issue#7for a related discussion.Conversion of binary wheelsInvestigate the feasability of supporting conversion of binary wheels. Slowly
but surely the Python community seems to be gravitating towards (binary) wheels
and once gravity has shifted we don’t want to be left in the dust! 😉Full PEP-440 compatibilityDive intoPEP-440and see if it can be fully supported? Thenthis question on
Redditcan finally get a satisfying answer 🙂.Similar projectsThere are several projects out there that share similarities with py2deb, for
example I know ofstdeb,dh-virtualenvandfpm. The documentation includes a
fairlydetailed comparisonwith each of these projects.ContactThe latest version of py2deb is available onPyPIandGitHub. The
documentation is hosted onRead the Docsand includes achangelog. For
questions, bug reports, suggestions, etc. please create an issue onGitHub.LicenseThis software is licensed under theMIT license.© 2020 Peter Odding, Arjan Verwer and Paylogic International.