Re-architect the code to make running from source simple
Currently the code only runs cleanly when it has been python setup.py installd into an egg.
Assume you have not done the egg install. If you're in the root of the source tree, such that, e.g. the Gateway code is in src/eddn/Gateway.py then:
-
.../src/eddnis what gets added tosys.path. -
from eddn.conf.Settings import Settingswill fail becauseeddnis on the end of thatsys.pathcomponent, so this would need to befrom conf.Settings import Settings. - If you start from
src/instead and thus useeddn/Gateway.,pyto run it thensys.pathcontains the same and you have the same issue. - If you start from
src/eddninstead and thus useGateway.pythen, again,sys.pathhas.../src/eddnin it and can't find any import beginning fromeddn..
If you install the egg then this is masked because it will find eddn.conf.Settings in the egg. But now if you make any edits to the source files, and don't re-install the egg, you'll be confused as to why your edit apparrently did nothing. Your updated src/eddn/Gateway.py will be used, because you're literally specifying it on the commandline, but anything it imports will only come from the last installed egg.
This is just needlessly frustrating when trying to rapidly iterate on code.
- [ ] - Begin by ignoring the whole install/egg thing. Get all of the code simply running from source. This will mostly mean adjusting import statements.
- [ ] - Once that is confirmed working, then update setup.py so that the install/egg works under this new paradigm.
- [ ] - Verify which is preferred, filesystem or egg contents (it should be the filesystem, given the observed sys.path order if the egg is present).
- [ ] - Verify that the egg is properly used when using the
systemd/start-eddn-servicescript without--from-sourceargument.
In the meantime this has mostly been addressed by the systemd/start-eddn-service script, with its --from-source argument, which uses:
cd "${SRC_DIR}/src/eddn"
python ${SERVICE_CAMEL}.py --config "${CONFIG_OVERRIDE}"
i.e. runs the file directly, but specifying the config file to use so it can actually be found.
There may still be some wrinkles with respect to other source files being found in the egg, not the raw files, but this at least works for the 'entry point' source files.
Also, 'egg' is deprecated in favour of 'wheel', and there are changes afoot with respect to setup.py as well, so this will likely be entirely redone under python3 anyway.