I think the best way would be to make sharedlib
a real package. That means changing the structure a bit:
sharedlib/
sharedlib/
__init__.py
ps_lib.py
another.py
setup.py
And using something like this in the setup.py
(taken partially from Python-packaging "Minimal Structure"):
from setuptools import setup
setup(name='sharedlib',
version='0.1',
description='...',
license='...',
packages=['sharedlib'], # you might need to change this if you have subfolders.
zip_safe=False)
Then install it with python setup.py develop
or pip install -e .
when in the root folder of the sharedlib
package.
That way (using the develop
or -e
option) changes to the contents of sharedlib/sharedlib/*
files will be visible without re-installing the sharedlib
package - although you may need to restart the interpreter if you're working in an interactive interpreter. That's because the interpreter caches already imported packages.
From the setuptools
documentation:
Setuptools allows you to deploy your projects for use in a common directory or staging area, but without copying any files. Thus, you can edit each project’s code in its checkout directory, and only need to run build commands when you change a project’s C extensions or similarly compiled files. [...]
To do this, use the setup.py develop
command.
(emphasis mine)
The most important thing is that you can import sharedlib
everywhere now - no need to insert the sharedlib
package in the PATH
or PYTHONPATH
anymore because Python (or at least the Python where you installed it) now treats sharedlib
like any other installed package.
sharedlib
as package? Then you can import it everywhere. – Presbyterianpython setup.py develop
. That way if you changesharedlib
the changes will take effect immediatly (or after an interpreter restart if you're using an interactive interpreter). – Presbyterianpython setup.py develop
and I'm using windows. However that requires you to make thesharedlib
package installable (I always usedsetuptools.setup
but it probably also works withdistutils.setup
). :) – Presbyterianpip install -e ..
– Cuficdevelop
command is only available insetuptools
, but not indistutils
. – Firestonesetup.py develop
not work?" when using puredistutils
... – Presbyterian