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

3

11

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?

Fecit answered 30/5, 2011 at 16:29 Comment(0)
H
42

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.

Hanging answered 3/2, 2013 at 17:38 Comment(3)
You don't even need to change the name of your directory. The fix is as simple as typing cd .. and trying easy_install again from a different cwd. I'd recommend testing this before looking at Martijn's answer, because it's an easy gotcha.Zoochore
Wow, would have taken me a while to realize this on my own. Great answer.Deaf
"The problem turned out to be that I had a subdirectory named xyz in the current working directory" I think this is a kind of general problem.Mcgough
H
8

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.

Homebred answered 4/6, 2011 at 16:42 Comment(0)
T
1

Sometimes you don't actually really intend to easy_install the 'directory', which will look for a setup.py file. In simple words, you may be doing easy_install xyz/ while what you really want to do is easy_install xyz

Tun answered 19/9, 2016 at 18:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.