How is the "common" package installed?

The CI pipeline for our python unit tests recently started failing because it isn’t recognizing the common module within edx-platform. Digging through the code, I haven’t been able to determine how this module is actually exposed. Unlike other modules within the edx-platform package (“lms”, “cms”, “openedx”, “xmodule”), “common” isn’t found within the packages list in the setup.py file. How is code able to import from the common module if this isn’t defined as a top-level package anywhere?

1 Like

Hey @tramck, great question.

Some background: Python code is allowed to import (a) anything on the PYTHONPATHs, which includes pip-installed packages, and (b) any Python module relative to the working directory. When using edx-platform as a working directory, that means that Python modules in all folders of edx-platform (lms, cms, common, openedx, and xmodule) can all be imported, via (b). That’s why you don’t need a setup.py when you first get started with a new Python project.

Now, the packages field in setup.py exists to tell setuptools which folders should be included when building a distributable package. For edx-platform, that list definitely should include common. Thing is, we rarely if ever install edx-platform as a package; we generally just run Python right in that repo. That’s why common has been missing all this time without anyone fixing it

It sounds like something in your CI tooling wants to treat edx-platform like a distributable package, so it needs packages in setup.py to include common. I think it would be fully reasonable to add the package to the list. Try that and see if it fixes your pipeline; if it does, please open a PR upstream and tag me for review!

2 Likes

Thanks @kmccormick that did the trick. I have opened the PR here, but don’t appear to have the necessary privileges to assign a reviewer. Could you pick it up?

1 Like