I am developing a package called garlicsim . ( Website .) The package is for Python 2.X, but I also offer 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 .
Problem: when third-party modules want to use garlicsim, they must have one package name for reference, not two. Of course, they can do something like this:
try: import garlicsim except ImportError: import garlicsim_py3 as garlicsim
But I would prefer that the developers of these modules do not do this.
Is there any way for garlicsim_py3 set itself under the alias garlicsim ? I want a Python 3 user to be able to import garlicsim and all the time refer to the module as garlicsim , but it really will be garlicsim_py3 .
I know that the Distribute project does something like this: they make it so that you can import setuptools and this will be redirected to their code. I have no idea how they do it.
Any ideas?
(1) I decided to support Python 3 on a fork, and not in the same code base; It is important for me that the code base is clean and I really would not want to introduce compatible hacks.
source share