kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

The --pythonpath CLI option currently does nothing!

Open rtibbles opened this issue 2 years ago • 4 comments

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.

rtibbles avatar Mar 22 '23 15:03 rtibbles

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.

dbnicholson avatar Mar 22 '23 16:03 dbnicholson

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).

rtibbles avatar Mar 22 '23 16:03 rtibbles

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.

dbnicholson avatar Mar 22 '23 17:03 dbnicholson

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

rtibbles avatar Mar 22 '23 18:03 rtibbles