Beastcraft
Beastcraft

Reputation: 375

Python deployment with virtualenv (on a no-internet-access server)

My production server has no access to the internet, so it's a bit a mess copying all the dependencies from my dev machine to the production/development server.

If I'd use virtualenv, I'd have all my dependencies in this environment. Doing this I'd also be able to deploy it on any machine, which has python & virtualenv installed.

But I've seen this rarely, and it seems kind of dirty. Am I wrong and this could be a good practice, or are there other ways to solve that nicely?

Upvotes: 11

Views: 3119

Answers (1)

Kyle Kelley
Kyle Kelley

Reputation: 14144

Three options I would consider:

  1. Run your own PyPI mirror with the dependencies you need. You really only need to build the file layout and pull from your local server using the index-url flag:

    $ pip install --index-url http://pypi.beastcraft.net/ numpy

  2. Build virtualenvs on the same architecture and copy those over as needed.

    This works, but you're taking a risk on true portability.

  3. Use terrarium to build virtual environments then bring those over (basically option 2 but with easier bookkeeping/automation).

I've done all of these and actually think that hosting your own PyPI mirror is the best option. It gives you the most flexibility when you're making a deployment or trying out new code.

Upvotes: 7

Related Questions