Python/Flask deployment without pip

727 views Asked by At

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?

1

There are 1 answers

3
joeforker On BEST ANSWER

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.