0

I need to create a Debian package for a python library, but I want to install the python library dependencies in a virtualenv, what will be best way to do that

1) I cannot install the dependencies in pre-install as I need to to create the virtualenv in my python code directory ( where python code is copied after installation )

2) I cannot install the dependencies in post- installation because if the dependency installation fails or some error is there, then too package version is bumped

3) During installation, I can write up a bash script to create a virtualenv and install dependencies and run it using Makefile , will that be a right thing to do ?

Arushix
  • 171
  • 4
  • 2
    Installing stuff in a virtualenv is fundamentally incompatible with `.deb` packages, which are meant for installing system-wide. – tripleee Jul 29 '19 at 18:53
  • @tripleee I have a use case where it's compulsory to not install the python dependencies system-wide but in a virtualenv , I know it's may not be fundamentally correct to install dependencies this way, but still if there is a workaround to this problem ? – Arushix Jul 29 '19 at 19:36
  • 2
    Not using a `.deb` package for that scenario would seem like an obvious and decisive simplification. What are you *actually* hoping to accomplish? See also [XY problem](https://en.wikipedia.org/wiki/XY_problem) – tripleee Jul 29 '19 at 20:36
  • @tripleee we have a command line tool written in python which when invoked activates its virtualenv and runs in it.. The problem with installing it in system-wide path is that this tool has dependencies which have different version of libraries than what is already installed in the system and we don't want to break the already running things on the system...... Moreover for shipping the command line tool we need a Debian package – Arushix Jul 29 '19 at 20:53
  • 2
    That doesn't explain why you think creating a Debian package with this hack is desirable. A simple Bash script with `pip` in a virtualenv seems much better for what you are describing. Maybe you can package that script in a `.deb` but the rest of your description sounds like you want it to run under a regular human user's account at installation time which again is by and large somewhere between horrible and impossible. – tripleee Jul 29 '19 at 20:58
  • @tripleee I want to ship the tool to many servers and maintain version of the tool as more features and dependencies keep getting added , using a bash script with pip will not allow me all this – Arushix Jul 29 '19 at 21:07
  • 1
    Packaging that script as a `.deb` gets you pretty far, and if there is a single root-owned standard location for the virtualenv, you could create or update that in the postinst; any failure would cause the package to show as unconfigured, and cause the installation tn fail. – tripleee Jul 29 '19 at 21:10
  • @tripleee writing the dependency installation part in post-install is causing the version to be changed even if dependencies installation is failing, is there any way to avoid that ? And what about installing dependencies in Makefile during package installation ? – Arushix Jul 29 '19 at 21:24
  • Whether your script runs `make` or some other commands doesn't change anything really. If upgrading the version number on failure is unacceptable, maybe split into two packages, where the second is a dummy empty package whose dependencies only allows it to be upgraded if the package it depends on was successfully installed. But this is really just another hack which should tell you that this approach is flawed. Again, if you are calling `pip` anyway, why isn't that acceptable as the installation method for the task at hand? – tripleee Jul 30 '19 at 04:09

0 Answers0