Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use virtualenv in production without python-dev

I have a python web project and I use virtualenv with pip on my dev server. Some python packages require compilation, so I should have python-dev in order to pip install them. Is there a way to reproduce my requirements stack in production keeping virtualenv, but no python-dev, as I am dealing with no dev server ?

like image 226
ScotchAndSoda Avatar asked Jul 19 '26 01:07

ScotchAndSoda


1 Answers

pip 1.4 added support for installing and building wheel package.

"Wheel" is a built, archive format that can greatly speed installation compared to building and installing from source archives.

procedure

  1. Install/upgrade to pip 1.4. (one time only)

  2. Install wheel in both dev, production server. (one time only)

    pip install wheel
    
  3. Build wheel package in dev server:

    pip wheel --wheel-dir=/local/wheels -r requirements.txt
    
  4. Transfer /local/wheels packages to production server.

  5. Install packages in production server:

    pip install --use-wheel --no-index --find-links=/local/wheels -r requirements.txt
    

Reference

See pip documentation about building and installing wheels for more detail.

like image 62
falsetru Avatar answered Jul 20 '26 20:07

falsetru