I'm currently trying to find a way to setup an application written in python to our production hosts. I currently use Debian packages apt repository so I tend to package the application into a deb package.
The stdeb tool allows me to do so and I successfully created a deb package using the following setup.py
:
import setuptools
ld = "Some long description"
setuptools.setup(
name = "my_fancy_app",
version="0.0.1",
author="Me Myself",
author_email="[email protected]",
description="Some description",
long_description=ld,
packages=setuptools.find_packages(),
entry_points={
'console_scripts': [ 'hlpth = my_fancy_app.__main__:main' ]
},
classifiers=[
"Programming Language :: Python :: 3.7",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.7'
)
The problem I see is that the paths in the Debian package are already specified to point to system site-packages
. Here is it
$ dpkg -c deb_dist/python3-my-fancy-app_0.0.1-1_all.deb
-rw-r--r-- root/root 1 2019-11-27 15:22 ./usr/lib/python3/dist-packages/my_fancy_app/__init__.py
-rw-r--r-- root/root 78 2019-11-27 15:23 ./usr/lib/python3/dist-packages/my_fancy_app/__main__.py
//...other entries omitted
From what I see now such deb
packaging insists on setting up the package into the "core" site-packages
. Is there a way to work-around this using Debian packages and allow the app to be able to install into a virtual environment?
Python virtual environments are managed using Python's packaging tools (primarily pip
, but there are alternatives).
By packaging something up into a Debian package, you've moved it into a format that isn't compatible with Python's tooling, and of course the Debian packaging tools don't know anything about Python virtual environments.
If you want to use your app in a virtual environment, just package it up as a Python package. There's no reason to build a .deb
package for this use case.