"pip install --editable ./" vs "python setup.py develop"
Asked Answered
C

4

227

Is there any significant difference between

pip install -e /path/to/mypackage

and the setuptools variant?

python /path/to/mypackage/setup.py develop
Ctn answered 18/5, 2015 at 14:37 Comment(3)
This appears to be an updated link describing development mode: setuptools.readthedocs.io/en/latest/…Ressieressler
if you are interested in uninstall (packages in development/editable mode) try this question: #17347119Bravado
I am afraid to ask it independently, but are these 2 ways the better ways to call an own-written module than "os.sys.append/insert" and PYTHONPATH change?Melliemelliferous
T
177

Try to avoid calling setup.py directly, it will not properly tell pip that you've installed your package.

With pip install -e:

For local projects, the “SomeProject.egg-info” directory is created relative to the project path. This is one advantage over just using setup.py develop, which creates the “egg-info” directly relative the current working directory.

More: docs

Also read the setuptools' docs.

Thermoscope answered 18/5, 2015 at 14:51 Comment(3)
Does user have to run 'python setup.py sdist' again after making the file change for the change to take effect?Chuckwalla
however if you need to debug (the setup.py file itself) with 'set_trace' then 'python setup.py develop' makes it possibleDiscrimination
@Thermoscope I am afraid to ask it independently, but are these 2 ways the better ways to call an own-written module than "os.sys.append/insert" and PYTHONPATH change?Melliemelliferous
A
88

One more difference: pip install -e uses wheel while python setup.py develop
doesn't use it.

With install, you could achieve the same behavior by using
pip install -e /path/to/package --no-use-wheel

More info on wheels : python wheels

Ashraf answered 13/8, 2015 at 11:34 Comment(2)
Note that, according to pip.pypa.io/en/stable/reference/pip_install, --no-use-wheel DEPRECATED in favour of --no-binary :all:Castanon
Can we do pip install -e for package produced using sdist?Chuckwalla
D
47

Another difference that may favor pip install -e is that if your project has dependencies in install_requires in setup.py, then pip install -e . installs dependencies with pip, while python setup.py develop can install with easy_install, and may cause problems re: 'egg-info' as mentioned above. When install-requires uses dependency_links with custom git URLs, with attached egg identifiers, this can be especially annoying.

Dnieper answered 24/8, 2017 at 13:53 Comment(3)
this totally explains why my private package was failing to be installed. it's on my devpi server not pypi. thanks.Regeneration
When you say package becomes editable, Do you mean user will have to run 'python setup.py sdist' again after making change to package file? Or running above command is not required?Chuckwalla
@Chuckwalla when you install a local package with pip install -e ., it essentially makes a symlink in the relevant Python site-packages directory to point to your working copy. As code changes are made to that working copy, it is instantly reflected in the "installed" version, so you do not need to re-run installation commands as you go. This is primarily useful for developing in a repository that represents an installable package, but can also be handy for e.g. writing some collection of modules with only absolute imports, etc.Dnieper
W
6

Yet another difference: when you run python setup.py develop for a version that is considered a pre-release (perhaps because you're running it from a git clone when not having checked out a release), then you will enable installation of pre-releases of your dependencies. On the other hand, with pip install --editable you would have to pass --pre explicitly if you want these pre-releases.

(See the CI log with pre-releases accidentally used and compare that to a fixed build here.)

Willms answered 26/6, 2020 at 16:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.