1

What's the best way to deploy a Python package to a Windows Server if some of the dependencies need to be compiled? Installing Visual Studio is out of the question and I'm reluctant to pass a 250MB file around everytime things need updating. pip install -r requirements.txt is the goal.

Any suggestions?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
blakev
  • 4,154
  • 2
  • 32
  • 52

2 Answers2

3

easy_install - allows installing from exe

easy_install does install from exe installers, if they are available. pip does not install from exe, so in case of C/C++ packages, easy_install is often the way to install.

making pip to install binaries

pip is supporting installation from wheel format.

In case you have a wheel on pypi or another index server you use, allow pip to use wheels (--use-wheels). Latest version of pip is using wheel format by default, older ones required setting --use-wheel switch.

building wheels

You can either build (compile) wheels, or you can convert eggs or exe installers to wheels.

For this, use wheel command.

Serving packages in wheel format

Some packages (e.g. lxml) do not provide wheels on pypi server. If you want to use them, you have to manage your own index. Easiest one is to use dedicated directory and pip configured with --find-links pointing there.

See SO answer to caching packages for more tips and details.

Very good alternative is devpi index server, which is easy to set up, has very good workflow and will integrate with your pip very well.

Community
  • 1
  • 1
Jan Vlcinsky
  • 42,725
  • 12
  • 101
  • 98
2

Using a compile-once, deploy-many-times strategy might help, with the use of Python's newest package distribution format, wheels. They are an already-compiled, binary format. So the requirements are just a development / build platform that's similar / running the same python as the deployment platform (the latter won't require a build chain anymore).

Install the latest pip, setuptools and wheel packages. You can then use the pip wheel command as you would pip install, except it will instead produce a folder called (by default) wheelhouse full of the necessary, already-compiled wheels for another python/pip to install what you required.

You can then pass those wheel filepaths directly to a pip install command (e.g on your deployment machine), or use the normal package name(s) with --no-index --find-links= flags to point to the folder location where those wheels are. This location can also be a simple http folder - for example.

Ivo
  • 5,378
  • 2
  • 18
  • 18