Hello I’m trying to create a deb package from a python project with virtualenv
and to do it I’m using cookiecutter.
I’ve never created a deb package in my life and so I’m following the guide
listed here but i had some problems trying to build the package with
dpkg-buildpackage -us -uc
(i’m on ubuntu 21.10 and i use python 3.9.7),
first of all it was warned the lack of a file (failed to run pyversions)
but i managed to solve the problem by installing python 2.7 but unfortunately
i found myself an error that I have really searched everywhere but I could
not find anything and the error in question is:
dh_auto_configure: error: invalid or non-existing path to the source directory: debian/sampleproject-0.1
make: *** [debian/rules:43: build] Errore 255
dpkg-buildpackage: Errore: debian/rules build subprocess returned exit status 2
that is, it expects the presence of a directory that has not been created
the situation tree is:
.
├── debian
│ ├── changelog
│ ├── compat
│ ├── control
│ ├── cookiecutter.json
│ ├── copyright
│ ├── rules
│ ├── sampleproject.debhelper.log
│ ├── sampleproject.links
│ ├── sampleproject.postinst
│ ├── sampleproject.triggers
│ └── source
│ ├── format
│ └── options
├── sampleproject
│ ├── __init__.py
│ └── sample.py
├── sampleproject-build-deps_0.1_all.deb
├── sampleproject-build-deps_0.1_amd64.buildinfo
├── sampleproject-build-deps_0.1_amd64.changes
└── setup.py
while the sample.py code (a simple test program) is:
from randstr import randstr
def main():
print("Hello Worls")
print(randstr())
if __name__ == "__main__":
main()
however init.py I cannot understand its usefulness and it is an empty
file while everything else is generated by answering the questions with:
cookiecutter https://github.com/Springerle/dh-virtualenv-mold.git
which I installed with pip install cookiecutter
.
I hope someone will help me because there is hardly any information about these things.
2
Answers
Struggling like you however one thing is certain, your tutorial is too old and there a new way to package the Python application.
You should definitely read the Debian Python Policy and especially the §4.3 which explains that the required structure is more this one:
Also what would be the best is to use
dh_make -p <your_package>_1.0 --python --createorig
to ensure the latest version of packaging Python files.After that the best way I found was to have a look to the way Debian itself packaged their Python application.
This one is a good (simple) example : https://salsa.debian.org/python-team/packages/python-untangle/-/tree/debian/main/debian
Good luck
In your
debian/rules
replace:
dh $@ --with python-virtualenv --sourcedir $(SDIST_DIR)
with:
dh $@ --buildsystem=pybuild --with python3 $(DH_VENV_ARGS)
and from your setup.py remove
install_requires
. I believe dh-virtual findsrequirements.txt
itself.run your build command again and remember to install required libraries. You will probably need to install python and python-setuptools (I know you running python3) to get the python versions in perl modules and you will need to add them in your control file.