Closed nbarlowATI closed 1 year ago
I think this is a good idea Nick. I can't think of any negative side effects and would definitely solve a few problems.
The only request I have is that it would remain the case that within the same local copy of the package all imports are relative, to avoid the confusion where I edit some file A.py but forget that the neighbouring file B.py, which has an import A
in it, doesn't import that A.py, but rather its now-out-of-date installed version. Maybe the cropcore
thing would solve that, although I'm a bit confused (I always find imports and module discovery confusing)?
Well...... this is an interesting question...
We can definitely keep it so that all the imports in modules in core
are relative (e.g. in db.py
it has from .structure import BASE
rather than from cropcore.structure import BASE
).
BUT, I think for the code in webapp/
and models/
we would be importing from cropcore
, i.e. any time you changed something in a core
module, you would need to redo pip install .
.
EXCEPT if you do pip install -e .
the first time - this would install "cropcore" in developer mode, make a symbolic link to your local installation in site-packages
rather than copying files there.
EXCEPT that Stack Overflow seems to suggest that having the package name and directory name different may not work with developer mode..... to be tested! :)
The
core
directory contains useful database schema and queries, and is used by both the webapp and the ingress functions. It could potentially also be used by the model functions. In order to do that, while avoiding the need to hack the PYTHONPATH orsys.path
, we could make thecore
directory pip-installable. This way we can always import core modules from anywhere else in the directory structure. Perhaps we would want the actual python "package" to be calledcropcore
, both to avoid potential conflicts with other packages and with the local filesystem version - I think this can be done insetup.py
.@mhauru @dsj976 , any objections to this, or other things we should think about?