0

I am building a .deb package of python module with dpkg-buildpackage. in setup.py i have specified install_requires=['othermodule>=2.0'] but the generated control file does not specify version. Depends: python (>= 2.7), othermodule, dh_python is guessing the requirements based on setup.py file. However the manpage of dh_python2 states that

(version requirements are ignored by default)

but I cannot manage to include the version in the control file. The problem is that without the version included the .deb package gets installed but then starting the program I get:

pkg_resources.DistributionNotFound: The 'othermodule>=2.0' distribution was not found and is required by ...

because the version installed is less than 2.0

I would like to be able to specify the dependency version only once (in the setup.py for example)

[EDIT:]

I see that in pydist.py the function load() searches in absolute paths:

def load(dname='/usr/share/python/dist/', fname='debian/pydist-overrides',
         fbname='/usr/share/python/dist_fallback'):

instead of under ./debian where my package structure lays. And since the package is not installed yet (I am in the process of building it) the pydist file is not found. Am I missing something???

Magen
  • 33
  • 1
  • 1
  • 7
  • tried to use pydist file in the debian folder with: `OthermoduleName python-othermodule; PEP386` but no results – Magen Feb 05 '19 at 22:24

1 Answers1

0

As stated in the Pybuild wiki:

dh_python2 and dh_python3 will correctly fill in the installation dependencies (via ${python:Depends} and ${python3:Depends} respectively)

So, if you will use ${python:Depends} in your debian/control, dh_python will try to map your install_requires from setup.py to actual deb dependencies. Use it like this:

Depends: python (>= 2.7), ${misc:Depends}, ${python:Depends}

You can also specify the desired version for your othermodule in debian/control just like you did for python:

Depends: python (>= 2.7), othermodule (>=2.0)

[EDIT]

You can place a pydist-overrides file under the debian folder that makes use of PEP386 to force dh_python to include version information when resolving install dependencies. It uses the same syntax as a .pydist file:

OthermoduleName python-othermodule; PEP386

Hope this helps.

Alex
  • 81
  • 1
  • 5
  • Actually I have exactly that line: `Depends: python (>= 2.7), ${misc:Depends}, ${python:Depends}` but the problem is that it does not translate the version from the _install_requires_. I can specify explicitly in the _control_ file but would like to specify requirements only one (in one of the files) – Magen Feb 06 '19 at 21:34
  • It seems like having _PEP386_ flag in a pydist file is the only way I find to make dh_python2 translate dependency versions. The issue is as I mention in my question that it look for that file in the python installation path instead of the source tree where I am building the package and running dh_python from – Magen Feb 06 '19 at 21:43
  • 1
    Have you tried using a `pydist-overrides` file instead of a `python-foo.pydist` file? It uses the same syntax as the pydist file: `OthermoduleName python-othermodule; PEP386` – Alex Feb 07 '19 at 10:25
  • There you go! it worked like a charm :) man, I spent so much time tweaking this. Bless your heart! Can I convert your comment as an answer? – Magen Feb 14 '19 at 08:44
  • I will edit the current answer to include this information so you can mark it as accepted answer. Is this ok? – Alex Feb 14 '19 at 15:45