-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support virtualenvs for python package building #697
Comments
If you can, can you take a peek at the dh-virtualenv code and provide a list of the commands it runs in order to do its job? |
(or anyone, for that matter, can do this) ;) |
Okay, so it seems straightforward, according to the bin. Basically, the debian rules file initializes the dh binary which then:
After that, it sort of goes back to debian. Seems pretty straightforward. |
FWIW we're currently packaging virtualenvs with fpm using the following recipe:
virtualenv-tools provides everything to update the location of a virtualenv so it'd be nice to rely on that rather than re-implement the functionality. I'm not sure if this feature should be built into fpm directly or documented as a recipe. We do a bunch of extra stuff in the build process like creating init scripts, running django's |
@thedrow there's an example in a project of mine: https://github.com/brutasse/graphite-api/tree/master/fpm |
@thedrow you can make a PR that implements it. |
Thats what a PR is for. We can discuss implementation after the fact. Would be nice to be able to specify a requirements.txt for the virtualenv, as well as config files to copy into the virtualenv. |
@brutasse's script looks really straightforward: https://github.com/brutasse/graphite-api/blob/master/fpm/build-deb.sh We can probably start with that as an fpm package type? |
This is what I did for circus, based on @brutasse's script. Some notes:
|
@josegonzalez As for interface, what would multiple deps look like? Specify on CLI or only do requirements.txt?
dependencies? Directories to include in the package?G |
Shouldn't it be For instance, I might do: fpm -t virtualenv -s folder-containing-etc -s folder-containing-var -n fancypants --requirements requirements.txt --normal-options-here Requirements could be a single package or a path to a file that contains a list of reqs in |
-t is for target, so the output of fpm. Is the goal to output a virtualenv named fancypants, in your example? |
My goal would be to make a debian package of a virtualenv. Ideally fpm manages the creation of that virtualenv - including any path modifications - so that I don't need to. |
so then the source would be virtualenv, and target would be deb. And yes, I agree with your 'fpm manages' things - fpm would do all the hard work. What inputs would you feed a virtualenv target? Dependencies? Directory to an app to package? Both? |
I think we can live with a dependency file as pip thinks of it. A single package could also work, though idk how difficult it would be to support both. Ideally the virtualenv doesn't exist to begin with. I guess what I'm trying to do is a multi-stage fpm run:
|
@josegonzalez Would you bundle an app along with its dependencies in a virtualenv? Or is it just using virtualenv to package a standalone python + some dependencies? |
What do you mean by "bundle an app"? |
Let's say we write an app that uses django. It's sweet todo manager, because that's what all the cool webapp demos are these days. You want to deploy this. Do you:
|
Definitely a single package. The app + its dependencies, as a single, isolated virtualenv. |
1 Deb file. |
woot, thanks for clarifying. I'll see what I can do to make this happen soon (assuming nobody else does). The scripting shown so far will make this very easy to implement. |
<3 |
+1 I tried to package some Python webapps with virtualenvs in early 2013 and was not successful due to symlinks/PATHs within the virtualenvs. I'm revisiting the problem now and I'm bummed that it hasn't been resolved yet. there's a number of issues on the FPM tracker that this feature would solve: I could also add to @thedrow's bounty (charity or BTC) |
Pull request waiting :) #864 |
+1 Been using dh-virtualenv as a substitute until fpm gets this feature. |
If no one objects, I'll start on this feature based on the script found here --> https://github.com/brutasse/graphite-api/blob/master/fpm/build-deb.sh . It seems pretty straight forward; expect a pull request soon. |
I have a nearly working prototype. I don't need to inherit from FPM::Package::Dir; if you look at Just take it with a grain of salt: It's a rough hewn stone at the moment. I copied from the |
DOH facepalm I see now @evilsocket has a PR open and it's farther along than mine. For shame starting a new one 👎. Maybe I'll start from where he left off. |
@djhaskin987 if u want to improve my stuff, that would be great :) |
Thanks for your support, @evilsocket . |
Submitted a PR! Many thanks again @evilsocket for your code and support. Comments and suggestions welcome! I don't think it's perfect, but I think it will cover most use cases and I think it's pretty good! 👍 Let me know if there are any deal breakers, everyone. |
#930 is merged. Release coming soon.! |
👯 👯 👯 👯 |
Finally we have good solution for Python packaging! I think from Python developers point of view merge of #930 is the best that ever happened to |
FPM currently requires separate packages for every piece of a given python package. Using the
beaver
repository, you would need to create the initial beaver package, as well as iterate over each line of the requirements file and create packages for those.The above works great if you do not also distribute other fpm-based python packages on the server with conflicting requirements. If you do, then tough shit.
A better way would be to build a python virtualenv for the package. Thus we'd only have to install
python-beaver
to get everything up and running. This is contrary to the debian way -lawl - but is more immediately useful to those attempting to run services in production.dh-virtualenv does something similar - though is python specific - and it doesn't create binaries for scripts like fpm does without need to learn more about debian packaging.
Issue #636 somewhat touches on this, though without any concrete outcome.
The text was updated successfully, but these errors were encountered: