When Would the -E, --Editable Option Be Useful with Pip Install

pip install --editable cause running develop, error in 'egg_base' option: 'src' does not exist

The location of the setup.cfg and setup.py files are the problem here.

Depending on experiences with another project out of habit I located them in the src folder.

hyperorg
├── src
│ ├── hyperorg
│ │ └── ...
│ ├── setup.cfg
│ └── setup.py

This can work in some circumstances but the official setuptools documentation about usage of setup.cfg also state to locate that files in the project root like this.

hyperorg
├── src
│ └── ...
├── setup.cfg
└── setup.py

In that case my setup work like a charm without modifying any other files. I just have to do in the project root

pip3 install --editable .

The string develop in the error output points to a Development Mode of setuptools. This is because of the --editable option in the pip call. The effect of Development Mode is that the package is not installed the usual way via coping the py files in the right directories of the system but just links to the source folders are created.

EDIT: This answer is still valid. But keep in mind that today the recommendation is to use a pyproject.toml file instead of setup.cfg. The details can be found in the setuptools docu.

Breaking 'pip install' to smaller steps, so I can edit the package before it is installed

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 . 



Related Topics



Leave a reply



Submit