65

How do I stop setup.py from installing a package as an egg? Or even better, how do I easy_install from installing a package as an egg?

sudo python setup.py install

The reason being that PyDev is rather picky about packages in egg format... The package I am interested in at the moment is boto.

Update: I found the brute force way of doing it:

sudo easy_install -m boto
cd path/to/boto-xyz.egg
sudo mv boto ..
sudo rm -rf boto-xyz.egg
jldupont
  • 82,560
  • 49
  • 190
  • 305

2 Answers2

77

Solution 1:

I feel like I'm missing something subtle or important (encountering this page years after the question was asked and not finding a satisfying answer) however the following works fine for me:

python setup.py install --single-version-externally-managed --root=/

Compressed *.egg files are an invention of setuptools (I'm not a big fan of them although I understand why they were created) and because the setup.py script is using (and may require) setuptools, the package ends up being installed as a compressed *.egg file.

Solution 2:

The command line options above are similar to those used by pip (the Python package manager) which hints at another way to stop a package from being installed as a compressed *.egg file: Just use pip! If you have a directory containing a setup.py script you can run the following command in that directory to install the package using pip:

pip install .

This is an improvement over the setup.py command above because it tracks additional metadata (e.g. tracking of installed files allows for more reliable removal).

Basj
  • 29,668
  • 65
  • 241
  • 451
xolox
  • 4,258
  • 1
  • 21
  • 14
  • 15
    Ha! I've been using pip for years and didn't know `pip install .` was possible. :-) – Jon Nov 15 '16 at 09:42
  • 2
    This is especially important to know for people who download and do source installs the old way with `python setup.py install` which often makes an `egg` install. – not2qubit Nov 29 '18 at 16:47
  • 1
    `pip install .` works on Windows 10 as well and fixed my issue of downloading a repo from github and having it go into a `.egg` when installing in a `virtualenv` – Infinity Cliff Feb 07 '19 at 13:34
  • I am so sick of `setuptools.setup`... everything simply works again after switching back to `disutils.core.setup`. Thanks for the tip! – shouldsee May 09 '19 at 13:01
17

Years later, same problem, not satisfied with the accepted answer. Found this in Google groups:

pushd /path/to/my/package/ 
python setup.py sdist 
popd 
pip install /path/to/my/package/dist/package-1.0.tar.gz

Explanation: python setup.py sdist creates a source distribution which naturally is not an *.egg! The resulting archive (.tar.gz in unix, .zip in windows) can be installed like any remote module with pip. It doesn't even require additional parameters! This results in the desired fully browsable module.

freeo
  • 3,272
  • 1
  • 20
  • 16