6

My familiarity with pip ends up with the ability to do: 'pip install', 'pip uninstall', and 'pip list' - with the name of the package I want to install as the single argument.

This limited knowledge carried me so far, to the extent I'm able to install most of the simple packages, and sometime, when I'm luck, I'm even able to install packages that requires compilation. This is all magic for me.

I'm now facing a situation where I need to do a little bit of editing to the C file (side note: this seems to be a known workaround for the 'netifaces' package - which everyone seems to be in peace with. By itself this is an amazing phenomena).

So I would like to break the installation into smaller steps:

  1. Download the egg file (I've figured out this one: pip install --download).
  2. Unzip or otherwise unpackage the package file, to the point I can edit individual
  3. Do my custom modification.
  4. Do the build
  5. Do the installation.

Other than step #1, I don't know how to proceed.

Uri London
  • 10,631
  • 5
  • 51
  • 81
  • Thankfully this is no longer the case. FWIW, netifaces *used to compile fine* if you were using the MinGW toolchain (that's how it was originally built on Windows). Anyway, the latest version doesn't require this workaround. – al45tair May 02 '14 at 15:39

4 Answers4

7

Modern pip (Since 1.10)

Use pip download:

pip download mypackage

pip 1.5 - 1.9

Use pip install -d

pip install -d . --allow-external netifaces --allow-unverified netifaces netifaces
tar xzf netifaces-0.8.tar.gz     # Unpack the downloaded file.
cd netifaces-0.8

Now do your modifications and continue:

pip install .

Old pip (Before 1.5)

  1. Install the package with --no-install option; with --no-install option, pip downloads and unpacks all packages, but does not actually install the package.

    pip install --no-install netifaces
    
  2. Change to the build directory. If you don't know where is the build directory, issue above command again, then it display the location.

    cd /tmp/pip_build_falsetru/netifaces
    
  3. Do the custom modification.

  4. Install the package using pip install . (add --no-clean option if you want keep the build directory) or python setup.py install.

    sudo pip install --no-clean . 
    

Udi
  • 29,222
  • 9
  • 96
  • 129
falsetru
  • 357,413
  • 63
  • 732
  • 636
  • 3
    Looks like `pip download` is now (pip 9.0.1 at least) preferred to `pip install -d . --allow-external ...`, which gave lots of deprecation notices -- primarily: `DEPRECATION: pip install --download has been deprecated and will be removed in the future. Pip now has a download command which should be used instead.` – Braham Snyder Aug 31 '17 at 06:32
  • 1
    @braham-snyder, Thank you for the information. I updated the answer accordingly. – falsetru Aug 31 '17 at 10:09
2

First, download the source to 0.8 from the author's home page (there's no direct download link from PyPI, for some reason). Go to the directory where you downloaded it and unzip it:

tar zxvf netifaces-0.8.tar.gz

Enter the netifaces-0.8/ directory and edit netifaces.c with your favorite editor. Save the file. Then, build the module:

python setup.py build

and install it:

sudo python setup.py install

To test, first leave the directory, then start your python interpreter and import netifaces to see if it works.

Good luck!

MattDMo
  • 100,794
  • 21
  • 241
  • 231
1

Download your selected package, extract the files,edit what you want. Then, open the directory with your terminal\cmd and run:

python setup.py install

Depending on your os you might need to add a little sudo to the beginning of this command (if you intend to install globally on a Unix machine)

yuvi
  • 18,155
  • 8
  • 56
  • 93
0

You could just download the source from pypi, edit it and use setup.py buid, setup.py install

Alvaro
  • 11,797
  • 9
  • 40
  • 57