Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install psutil without gcc

Up to now we installed psutil via our custom pypi server.

Now we have a new environment where we should not install gcc.

Now the old way (pip starts gcc during install) does not work any more.

The context:

  • Linux servers
  • python inside virtualenv
  • All code needs to be deployed from our data center (without internet access)

I see these alternatives:

RPM

Create a RPM. Since we already run our virtualenv with --system-site-packages this works. This forces all virtualenvs on the server to use the same version of psutil. But this would be no big problem.

Wheel

I have never used that.

Freeze

Use a tool like cx_freeze. I have never done this before.

Other solution?

I guess there are other, maybe better, ways to solve this.

Background

psutil is just an example in this case. The same question comes up for other python packages containing c-extensions. Imagine there are no RPMs here yet.

like image 230
guettli Avatar asked May 24 '16 06:05

guettli


1 Answers

The most idiomatic way is to use wheels. In fact, your use case is one of the reasons why the wheel format was created.

Building a platform wheel is easy:

python setup.py bdist_wheel

You might get an error "invalid command 'bdist_wheel'". In this case you have to install the wheel package:

pip install wheel

After building the wheel, it is in e.g. dist/psutil-4.2.0-cp27-cp27mu-linux_x86_64.whl. You can install it by:

pip install dist/psutil-4.2.0-cp27-cp27mu-linux_x86_64.whl

In general, installing and using the wheel only works on a system which is binary-compatible. As this is not guaranteed across different Linux distributions and versions, there are restrictions when uploading wheels to the central PyPI. These restrictions don't apply when running your own PyPI server.

You can upload the wheel to your custom PyPI by:

python setup.py bdist_wheel upload --repository <url-to-custom-pypi>

And install it from your custom PyPI by e.g.:

pip install --index-url <url-to-custom-pypi> psutil
like image 100
Manuel Jacob Avatar answered Sep 24 '22 03:09

Manuel Jacob