[Distutils] Having a Python package install itself under a different name

P.J. Eby pje at telecommunity.com
Fri May 28 21:14:26 CEST 2010


At 08:00 PM 5/28/2010 +0200, cool-RR wrote:
>On Fri, May 28, 2010 at 7:44 PM, P.J. Eby 
><<mailto:pje at telecommunity.com>pje at telecommunity.com> wrote:
>At 02:53 AM 5/28/2010 +0200, cool-RR wrote:
>
>On Fri, May 28, 2010 at 2:36 AM, P.J. Eby 
><<mailto:pje at telecommunity.com><mailto:pje at telecommunity.com>pje at telecommunity.com> 
>wrote:
>However, as long as both versions alert the user when used on the 
>wrong Python version, they will quickly discover their mistake.  ;-)
>
>Yes, I thought about this too. You suggest doing that on the setup 
>script, the package itself, or both?
>
>
>The package itself; doing it in the setup script is ridiculously 
>hard.  (Not detecting the Python version, but detecting whether 
>you're installing both versions to the same location.)
>
>
>I'm not sure we're on the same page here. My intention is that 
>Python 2.x users will use only `garlicsim`, and Python 3.x users 
>will use only `garlicsim_py3`.

But both projects will contain a package named 'garlicsim' - so if 
they're installed to the same location, then either one will 
overwrite the other (distutils/pip install) or override the other (setuptools).

In principle, they won't be installed to the same location, unless 
somebody has a directory that's used for both Python 2 packages and 
Python 3 packages -- and if they do that, they'll have other 
problems.  (i.e., they shouldn't be doing it)


>  Why would I want to detect anything beyond the Python version in 
> the setup script?

Even though you detect the version in the setup script, it won't stop 
the problem of installing both versions to the same location.  That's 
why the package itself needs to give a good error message if imported 
from the wrong Python version, to handle the case where somebody's 
sys.path is wrong (e.g. due to a PYTHONPATH that includes both Python 
2 and 3 packages).

Again, people are going to have other problems if they do that, 
unrelated to your package.  Putting in the check is just a courtesy 
measure so they don't have to spend a lot of time figuring out what 
they did wrong.




More information about the Distutils-SIG mailing list