From: Antoine Pitrou on

Really, this shouldn't happen if you really are using a
non-root version of Python:

> [Errno 2] No such file or directory:
> '/usr/local/lib/python2.6/site-packages/test-easy-install-22015.write-test'

I don't think setuptools is dumb enough to hardcode things like
"/usr/local/lib/python2.6/", so the error is probably yours here.
Perhaps you should double-check you did everything fine before posting
such a rant.

Of course, if by "freshly-built version of Python", you mean you didn't
run "make install" in any way, then it's your problem. Give
"./configure" an appropriate non-root prefix and don't forget to run
"make install" at the end.


From: David Cournapeau on
On Sun, May 30, 2010 at 3:56 PM, John Nagle <nagle(a)animats.com> wrote:
>   MySQLdb won't install as non-root on Python 2.6 because
> its "setup.py" file requires "setuptools".  "setuptools",
> unlike "distutils", isn't part of the Python 2.6 distribution.
>
>   IMPORTANT PACKAGES SHOULD NOT USE "setuptools".  Use the
> standard "distutils".  "setuptools" and "eggs" create more
> problems than they solve.  "setuptools" has many built-in
> assumptions about where things are supposed to be, and they're
> usually wrong.

Yes, setuptools is often a pain.

The magic incantation you want is something like python setup.py
install --prefix=someprefix --single-version-externally-managed
--record=/dev/null. I myself have a small script which detects whether
setup.py uses setuptools or not, and add the necessary options in
setuptools case for a sane behavior.

David
From: John Nagle on
David Cournapeau wrote:
> On Sun, May 30, 2010 at 3:56 PM, John Nagle <nagle(a)animats.com> wrote:
>> MySQLdb won't install as non-root on Python 2.6 because
>> its "setup.py" file requires "setuptools". "setuptools",
>> unlike "distutils", isn't part of the Python 2.6 distribution.
>>
>> IMPORTANT PACKAGES SHOULD NOT USE "setuptools". Use the
>> standard "distutils". "setuptools" and "eggs" create more
>> problems than they solve. "setuptools" has many built-in
>> assumptions about where things are supposed to be, and they're
>> usually wrong.
>
> Yes, setuptools is often a pain.
>
> The magic incantation you want is something like python setup.py
> install --prefix=someprefix --single-version-externally-managed
> --record=/dev/null. I myself have a small script which detects whether
> setup.py uses setuptools or not, and add the necessary options in
> setuptools case for a sane behavior.
>
> David

The "setup.py" file for MySQLdb has, as its first Python
line, "from setuptools import ...". No combination of options will
get around that.

John Nagle
From: John Nagle on
Antoine Pitrou wrote:
> Really, this shouldn't happen if you really are using a
> non-root version of Python:
>
>> [Errno 2] No such file or directory:
>> '/usr/local/lib/python2.6/site-packages/test-easy-install-22015.write-test'
>
> I don't think setuptools is dumb enough to hardcode things like
> "/usr/local/lib/python2.6/", so the error is probably yours here.
> Perhaps you should double-check you did everything fine before posting
> such a rant.
>
> Of course, if by "freshly-built version of Python", you mean you didn't
> run "make install" in any way, then it's your problem. Give
> "./configure" an appropriate non-root prefix and don't forget to run
> "make install" at the end.

Actually, a "built" but "uninstalled" Python works fine. If it
didn't, "make test" wouldn't work. "sys.path" correctly points to the
library directories created during "build".

On the other hand, options to "./configure" apparently don't work
right in Python 2.6 through 3.x. "--libdir" and "--bindir" don't actually
do anything. See "http://bugs.python.org/issue858809" (an open bug). So custom
"configure" is currently broken.

The real problem here remains the unnecessary use of "setuptools".
It's Debian distro policy not to use "setuptools":

http://www.debian.org/doc/packaging-manuals/python-policy/ap-packaging_tools.html

Also read "Setuptools is not a decent software package management".

http://workaround.org/easy-install-debian

The fundamental problem is that "setuptools" is more than an installer but
less than a widely-supported system-wide package manager like "yum".

Now, how to get the dependency on "setuptools" out of MySQLdb?

John Nagle
From: John Nagle on
John Nagle wrote:
> David Cournapeau wrote:
>> On Sun, May 30, 2010 at 3:56 PM, John Nagle <nagle(a)animats.com> wrote:
>>> MySQLdb won't install as non-root on Python 2.6 because
>>> its "setup.py" file requires "setuptools". "setuptools",
>>> unlike "distutils", isn't part of the Python 2.6 distribution.
>>>
>>> IMPORTANT PACKAGES SHOULD NOT USE "setuptools". Use the
>>> standard "distutils". "setuptools" and "eggs" create more
>>> problems than they solve. "setuptools" has many built-in
>>> assumptions about where things are supposed to be, and they're
>>> usually wrong.

I tried this change on MySQLdb's "setup.py":

diff setup.py setup-nodistutils.py
5c5
< from setuptools import setup, Extension
---
> from distutils.core import setup, Extension

The build then runs. The resulting MySQLdb runs under the uninstalled
Python and connects to the database properly.

There's no need for "setuptools" here at all. It just gets in the way.

John Nagle