We\'re starting a new project in Python with a few proprietary algorithms and sensitive bits of logic that we\'d like to keep private. We also will have a few outsiders (sel
In the __init__ method of the foo package you can change __path__ to make it look for its modules in other directories.
So create a directory called secret
and put it in your private Subversion repository. In secret
put your proprietary bar.py
. In the __init__.py
of the public foo
package put in something like:
__path__.insert(0,'secret')
This will mean for users who have the private repository and so the secret
directory they will get the proprietary bar.py
as foo.bar
as secret
is the first directory in the search path. For other users, Python won't find secret
and will look as the next directory in __path__
and so will load the normal bar.py
from foo
.
So it will look something like this:
private
└── trunk/
└── secret/
└── bar.py
public
└── trunk/
├── __init__.py
└── foo/
├── __init__.py
├── bar.py
├── baz.py
└── quux.py