Trapped in python package; send food.
jessenoller.com
jessenoller.com
[PS]: http://svn.pythonpaste.org/Paste/Script/trunk/setup.py
[pr]: http://pastie.org/550423
On the other hand, distutils has a `scripts=` keyword that points directly to a file, which then gets copied and pasted into the bin directory. Since the file has be word-for-word the script, the shebang is written directly. It depends on env, which should normally function; but, if it doesn't, as in the OP's case, there's no fallback. A good example of this is Mercurial [hg]. (Note: I actually haven't used raw distutils all that much, so there might be a work-around for this. A few fruitless minutes of Google Code Search hasn't turned up anything interesting.)
"The only clever feature is that if the first line of the script starts with #! and contains the word “python”, the Distutils will adjust the first line to refer to the current interpreter location. By default, it is replaced with the current interpreter location. The --executable (or -e) option will allow the interpreter path to be explicitly overridden."
In the light of this article classpaths sound a lot like what they really are: a working compromise everybody can live with.
#!/usr/bin/env python
Will dynamically start whatever Python is in your $PATH.
I don't think you mean this. When you specify an absolute name, $PATH is not even in the picture. (I do know that some systems put env in /bin. Those systems are misconfigured.)
Anyway, shebangs are flaky by design. I just run the correct interpreter directly, as in "/path/to/perl -Ilib bin/script.pl". There is no confusion that way.
Related pet peeve: people using #!/bin/sh when they really want #!/bin/bash. They are not interchangeable!
./configure --prefix=/opt/my_python
make && make install
export PATH="/opt/my_python/bin:$PATH"I agree, all you should need is a --prefix, and that scripts should obey whatever python interpreter is in /usr/bin/env - but that's not the way it works, sadly.
Such scripts are broken. One should fix the scripts instead of mangling the environment. It's a one-liner:
find /opt/myproject -type f -exec sed -i 's/#!\/usr\/bin\/python/#!\/usr\/bin\/env python/' {} \;
but if you move it, everything breaks in unexpected ways.If you move it then PYTHONPATH is your friend.
Once you have a python build for each project (which you want to have anyways) you'll notice that you don't need virtualenv or other kludges anymore either. Yep, it's really that easy. 4 lines of code. How many lines was yours again?
As for pythonpath - that has nothing to do with moving the entire directory path, including the interpreter, /bin dir, etc.
I have 9 python projects under /opt/foo* right now. Each of them has their own python in /opt/foo*/sys/python. I su to the respective user who has PATH and PYTHONPATH set appropiately in its profile - and everything works as expected.
I also don't follow why you consider sed a "hack" here. A hardcoded hashbang line is clearly a Bug - but gladly one that is trivially fixed with that one-liner. On the other side we have your "fix" that involves permanently mangling the environment in strange ways. In my book you are the one proposing the hack here.
I still haven't fixed the build something and upload it for people, because of the hardcoded shebang, and yes - sed could fix that.
How often do your projects depend on something else, written in python, that installs a binary? For me that number is zero. iirc all of my python dependencies are libraries. And if I stumbled into something that comes with a binary, with a broken hashbang line, then I'd be rather motivated to not only fix it, but to also feed the fix upstream. If the project is useful enough for me to use it then those 10 minutes of my time for a brown-paper-bag micropatch are a no-brainer.
Well, to each their own. - But I still think this is a solution looking for a problem, with the potential to create more problems than it solves.
http://mail.python.org/pipermail/python-dev/2009-July/090259... http://mail.python.org/pipermail/python-dev/2009-July/090356...
And so on. I agree wholeheartedly though - library-only dependencies are stupid simple.
easy_install is irrelevant anyways, nobody in their right mind would use that on a production system.
(We also have a generic way to get at installed data files without hard-coded paths; see File::ShareDir.)
Not sure why Python can't do this.