Re: [Distutils] Trouble installing Myghty with --prefix
At 11:58 AM 11/30/2005 -0600, skip@pobox.com wrote:
Ian> There's non-root installation instructions on the setuptools site Ian> (and maybe included in easy_install now?) that will create a full Ian> Python environment in a non-standard location, which would probably Ian> resolve this issue.
Thanks, but that's not what I'm after. On my CentOS 4 server, Python 2.3.x is installed with /usr as the prefix (that is, I use the CentOS-provided version of Python). I install all third-party packages (including my own code) with a prefix of /usr/local/mojam so I can a) avoid polluting the base package and b) install things without becoming root. Accordingly, I dump a mojam.pth file in the system site-packages directory which contains this one line:
/usr/local/mojam/lib/python2.3/site-packages
That is my only pollution of the default Python installation. I'd like to keep it that way. Can setuptools (be made to) do the job?
Yes, but you need two things: 1. Change your .pth file to read: import site; site.addsitedir('/usr/local/mojam/lib/python2.3/site-packages') 2. Create a distutils.cfg in /usr/lib/python2.3/distutils/ with the contents I mentioned before. Basically, without #1, .pth files in /usr/local/mojam/lib/python2.3/site-package won't be processed by Python, and without #2, setuptools won't know that Python is processing the .pth files.
pje> 1. Change your .pth file to read: pje> import site; site.addsitedir('/usr/local/mojam/lib/python2.3/site-packages') Did that: $ cat /usr/lib/python2.3/site-packages/mojam.pth # This file should be the only intrusion on the system-installed version of # python... import site; site.addsitedir("/usr/local/mojam/lib/python2.3/site-packages") pje> 2. Create a distutils.cfg in /usr/lib/python2.3/distutils/ with the pje> contents I mentioned before. Again with my desire to minimize cruft in /usr/lib/python2.3, I saw that setuptools is supposed to honor ~/.pydistutils.cfg and created: $ cat ~/.pydistutils.cfg [install] prefix = /usr/local/mojam [easy_install] site_dirs = /usr/local/mojam/lib/python2.3/site-packages Then, after removing all the previously installed .egg directories and the build directory in my Myghty source tree, I tried python setup.py install --prefix=/usr/local/mojam again. Same result. So I suffered with creating /usr/lib/python2.3/distutils/distutils.cfg. Lather. Rinse. Repeat. Same result: $ python Python 2.3.4 (#1, Feb 22 2005, 04:09:37) [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pkg_resources Traceback (most recent call last): File "<stdin>", line 1, in ? ImportError: No module named pkg_resources What to try next? Skip
At 05:49 PM 11/30/2005 -0600, skip@pobox.com wrote:
Then, after removing all the previously installed .egg directories and the build directory in my Myghty source tree, I tried
python setup.py install --prefix=/usr/local/mojam
again. Same result.
Argh. Sorry, I just realized I was ignoring the part where you are using "setup.py install" rather than easy_install. "setup.py install" doesn't honor easy_install's options, because it's assumed that only people who don't have/use easy_install will run "setup.py install". So, it's sort of a chicken and egg thing here, as I had you edit options that somebody using "setup.py install" wouldn't ordinarily be working with. This is arguably a bug in setuptools, so I'll work on fixing it. In the meantime, you should be able to just do: python setup.py easy_install . in order to do the installation, whether you use distutils.cfg or ~/.pydistutils.cfg. Again, sorry about that, it's a problem with the setuptools "install" command, which is just a wrapper around easy_install, but apparently isn't loading its config file settings. I'll fix that as soon as I can. I should probably also be recommending that authors using setuptools recommend that their users refer to the EasyInstall documentation if they are installing to custom locations.
>> python setup.py install --prefix=/usr/local/mojam >> >> again. Same result. ... pje> In the meantime, you should be able to just do: pje> python setup.py easy_install . pje> in order to do the installation, whether you use distutils.cfg or pje> ~/.pydistutils.cfg. That seems to have worked. I can now "import myghty". Much thanks for your patient help. Skip
At 07:39 PM 11/30/2005 -0600, skip@pobox.com wrote:
>> python setup.py install --prefix=/usr/local/mojam >> >> again. Same result.
...
pje> In the meantime, you should be able to just do:
pje> python setup.py easy_install .
pje> in order to do the installation, whether you use distutils.cfg or pje> ~/.pydistutils.cfg.
That seems to have worked. I can now "import myghty". Much thanks for your patient help.
And thanks for your bug report. The SVN version of setuptools now fixes this problem, so that "setup.py install" honors any configuration file settings for the "easy_install" command. I'll also be refactoring the "non-root installation" docs to be a more general section on "Customizing Installation Locations", with a sub-heading on non-root installations, and add in more stuff about the site hack, .pth transitivity, etc. I kind of hate to make the docs more complex, but oh well. I'll also be adding a "What Your Users Should Know" section to the setuptools manual that will cross-reference to all that, so that authors of setuptools-based packages can direct people to a single link.
participants (2)
-
Phillip J. Eby
-
skip@pobox.com