Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Flask deployment without pip

I've usually deployed my Flask applications with a fairly simple fabric script that put the source on the target machine, used pip to install any dependencies, then fired up uwsgi with all the necessary settings and off it went.

However, I have a new issue that some new security settings in our environments have blocked us from access outside the network so trying to use pip to install our dependencies fails. I looked into using python setup.py sdist to create a package thinking this would build everything down on the developer machine then I could upload the .tar.gz to the deployment machine and install it but it is still trying to contact pip to get the dependencies.

Is there a way to get a completely compiled package with dependencies and all that I could use to deploy to my server? Is there some sdist setting I can use?

like image 756
ThrowsException Avatar asked Jun 10 '15 14:06

ThrowsException


1 Answers

Assuming your build machine is binary-compatible with the target, or you don't need any compiled extensions, you can use pip wheel to compile you project and all its dependencies to wheels, copy those files to the server, and pip install from the wheel directory only.

# on build machine
cd myproject
pip wheel --wheel-dir wheelbase .
scp -r wheelbase [email protected]

# on target machine
pip install --no-index --find-links=wheelbase myproject

You should be able to copy the odd sdist into the --find-links directory as well, in which case pip will install from the sdist, if you have to recompile on the server.

like image 124
joeforker Avatar answered Sep 24 '22 10:09

joeforker