Importing modules through directory shortcuts on Windows
Thomas Heller
theller at python.net
Wed Apr 26 09:49:29 EDT 2006
Brian Quinlan wrote:
> Recently, I became responsible for maintaining some Python code, which
> was organized as follows:
>
> user/pylib
> ui
> ...
> project2/pylib
> ui
> ...
> project3/pylib
> ui
> ...
> python-packages/user => /user/pylib
> project2 => /project2/pylib
> project3 => /project3/pylib
>
> The idea is that "python-packages" is added to sys.path and then every
> project can import the library package from every other project. NOTE: I
> think that this structure is crazy but I'm just the poor maintenance
> programmer.
>
> Anyway, the problem is that Windows does not have a symlink facility to
> accommodate this (AFAIK) and the Python import mechanism does not
> resolve shortcuts.
>
> Therefore, I wrote a very simple import hook to get around that problem.
> If you are interested, the code is here:
> http://www.sweetapp.com/shortcut/shortcutimporter.py
>
> BTW, does anyone else think that this functionality should be part of
> core Python?
I wonder (but haven't yet figured out) if something similar can be achived
with pkgutil and one or more .pkg files.
Thomas
More information about the Python-list
mailing list