learningequality / kolibri

Kolibri Learning Platform: the offline app for universal education
https://learningequality.org/kolibri/
MIT License
769 stars 647 forks source link

The --pythonpath CLI option currently does nothing! #10296

Open rtibbles opened 1 year ago

rtibbles commented 1 year ago

This has probably been extant for quite some time, and probably got lost in a CLI refactor/reshuffle at some point.

The --pythonpath option should validate the file path, and append the path to the PYTHONPATH.

dbnicholson commented 1 year ago

It doesn't do completely nothing. It's used in kolibri.utils.main.initialize to provide to Django when loading the settings. Unfortunately, the validation of the --settings CLI option doesn't take it into account, so it effectively doesn't do anything since that's the only reason you'd use --pythonpath.

rtibbles commented 1 year ago

It seems like the appropriate fix here then is to migrate this from kolibri.utils.main.initialize to earlier in the CLI pipeline (before the settings option is processed).

dbnicholson commented 1 year ago

I suppose, but the both the parsed pythonpath and settings option are passed to initialize. It seems like a bit of a circular dependency - you need to parse and process pythonpath before settings. To me the simpler solution is to not do validate_module at option parsing time or maybe not at all since it's only used for the django setup and django will certainly validate it.

rtibbles commented 1 year ago

It's possible with Click to require that one setting is parsed before another, so that would allow pythonpath to be processed first.