226

Is there any significant difference between

pip install -e /path/to/mypackage

and the setuptools variant?

python /path/to/mypackage/setup.py develop
dreftymac
  • 31,404
  • 26
  • 119
  • 182
PeterE
  • 5,715
  • 5
  • 29
  • 51
  • 1
    This appears to be an updated link describing development mode: https://setuptools.readthedocs.io/en/latest/setuptools.html?highlight=development%20mode#develop-deploy-the-project-source-in-development-mode – PaulR Aug 08 '16 at 19:49
  • if you are interested in uninstall (packages in development/editable mode) try this question: https://stackoverflow.com/questions/17346619/how-to-uninstall-editable-packages-with-pip-installed-with-e – Charlie Parker May 02 '20 at 16:22
  • 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? – Travis_Dudeson May 11 '23 at 17:44

4 Answers4

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.

jalanb
  • 1,097
  • 2
  • 11
  • 37
sobolevn
  • 16,714
  • 6
  • 62
  • 60
  • 2
    Does user have to run 'python setup.py sdist' again after making the file change for the change to take effect? – variable Oct 12 '19 at 08:41
  • however if you need to debug (the setup.py file itself) with 'set_trace' then 'python setup.py develop' makes it possible – mirek Jan 02 '20 at 21:41
  • @sobolevn 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? – Travis_Dudeson May 11 '23 at 17:44
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

user2488286
  • 1,231
  • 11
  • 4
  • 23
    Note that, according to https://pip.pypa.io/en/stable/reference/pip_install/, `--no-use-wheel` DEPRECATED in favour of `--no-binary :all:` – Nzbuu Mar 14 '17 at 22:59
  • Can we do pip install -e for package produced using sdist? – variable Oct 12 '19 at 07:38
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.

ely
  • 74,674
  • 34
  • 147
  • 228
  • 2
    this totally explains why my private package was failing to be installed. it's on my devpi server not pypi. thanks. – ckot Mar 23 '18 at 04:41
  • 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? – variable Oct 12 '19 at 08:39
  • @variable 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. – ely Oct 14 '19 at 12:45
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.)

Jan Kundrát
  • 3,700
  • 1
  • 18
  • 29