开发者

Having a Python package install itself under a different name

I'm developing a package called garlicsim. (Website.) The package is intended for Python 2.X, but I am also offerring Python 3 support on a different fork called garlicsim_py3.(1)

So both of these packages live side by side on PyPI, and Python 3 users install garlicsim_py3, and Python 2 users install garlicsim.

The probl开发者_StackOverflow社区em is: When third party modules want to use garlicsim, they should have one package name to refer to, not two. Sure, they can do something like this:

try:
    import garlicsim
except ImportError:
    import garlicsim_py3 as garlicsim

But I would prefer not to make the developers of these modules do this.

Is there a way that garlicsim_py3 will install itself under the alias garlicsim? What I want is for a Python 3 user to be able to import garlicsim and refer to the module all the time as garlicsim, but that it will really be garlicsim_py3.

I know that the Distribute project does something like this: They make it so you can import setuptools and it will be redirected into their code. I have no idea how they do it.

Any ideas?


(1) I've reached the decision to support Python 3 on a fork instead of in the same code base; It's important for me that the code base will be clean, and I would really not want to introduce compatibilty hacks.


Eventually I decided not to do it, and just have the two projects have the same package name even though they have a different PyPI name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜