Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

easy_install fails on error "Couldn't find setup script" after binary upload?

After uploading a binary distribution of my Python C extension with python setup.py bdist upload, easy_install [my-package-name] fails on "error: Couldn't find a setup script in /tmp/easy_install/package-name-etc-etc".

What am I doing wrong?

like image 686
Michael Avatar asked May 30 '11 16:05

Michael


2 Answers

This may not be related to your specific problem, but I am providing this information in case it is helpful to others.

I hit exactly this error when running easy_install xyz. The problem turned out to be that I had a subdirectory named xyz in the current working directory and easy_install was expecting to find a setup script locally in that subdirectory instead of going out to the web to get the real xyz. Renaming my local xyz directory temporarily fixed the problem.

This is one of a number of situations in which the command line argument you provide can be unintentionally shadowed by a file or folder of the same name. Another example is make: if you run make test in an attempt to make your test target and you happen to have a folder named test then make will not do what you want. The solution in that case is to indicate Phony Targets.

like image 79
jarmod Avatar answered Oct 31 '22 19:10

jarmod


easy_install expects to find either a source distribution, or an egg. It's best to upload source distributions (sdist) to PyPI (or whatever distribution server you are using), and only upload eggs if your python package contains C extensions, and then only for Windows eggs (see my answer to Can I create a single egg for multiple versions of python?).

The bdist command, without additional configuration, creates a .tar.gz or .zip archive containing the compiled python files (and any C extensions compiled) for your current platform, sans installer (so not including the setup.py file). It's intended for unpacking by hand in your site-packages location and pre-dates distribution via eggs. If you were to unzip it, you'll notice it even included the full, absolute path to your site-packages directory in the tarball!

You can configure bdist to generate a RPM or a .deb file, or a simple Windows installer, but these are again aimed at providing installation bundles for other distribution systems not related to PyPI and easy_install.

So, to summarize, in most cases it's best to upload an sdist source distribution and have easy_install do the python compilation (into an egg) on installation.

If you do want to upload a pre-compiled distribution (which is then tied to specific Python version and the platform for which it was compiled), use the bdist_egg command instead.

like image 28
Martijn Pieters Avatar answered Oct 31 '22 18:10

Martijn Pieters