Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for setuptools to automatically discover new modules under src/matrix_common #27

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

anoadragon453
Copy link
Member

While trying to add a Python module at src/matrix_common/types, I ran into the issue that pip install -e . would not actually find the new module! This would result in calls to tox -e py to fail as my new module wouldn't be included in the source distribution of matrix_common (which tox builds and installs when creating its own virtualenv for testing). My tests needed to import from this new module in order to test it.

So, running down the rabbit hole of python packaging I eventually found that our existing setup.cfg was not making use of setuptools' autodiscovery features, but instead required manually specifying each package. See the documentation here.

Adding my new module to packages indeed worked, but as the documentation says, it is tiresome and likely going to confuse new contributors as it did me.


This PR removes the package_dir and packages options in setup.cfg to allow setuptools to switch to Automatic Discovery mode for packages; specifically the one for src-layout.

With this, running pip install -e . allowed my src/matrix_common/types module to be discovered and my tests which import the module to pass with when running tox.

Related: #23 (which moved us to a src-based file hierarchy initially).

@anoadragon453 anoadragon453 requested a review from a team as a code owner July 14, 2022 17:49
@anoadragon453
Copy link
Member Author

anoadragon453 commented Jul 14, 2022

Hmm, CI with Python 3.10.5 succeeded whereas 3.6 failed. I'll have to check why tomorrow.

Edit: Looks like automatic discovery was only added in setuptools v61.0.0: pypa/setuptools#2894

@DMRobertson
Copy link
Contributor

DMRobertson commented Jul 14, 2022

3.6 is end of life. Let's drop it. (https://endoflife.date/python)

@richvdh
Copy link
Member

richvdh commented Jul 15, 2022

taking this out of the review queue pending something happening about 3.6.

@richvdh richvdh removed the request for review from a team July 15, 2022 10:12
We do this by simply removing the 'packages' and 'package_dir' options
from setup.cfg.
@anoadragon453 anoadragon453 force-pushed the anoa/autofind_packages branch from 3433162 to 28011ad Compare July 15, 2022 10:56
@anoadragon453
Copy link
Member Author

anoadragon453 commented Jul 15, 2022

Python 3.6 dropped in #28.

CI passes against Python 3.7+ 🎉

@anoadragon453 anoadragon453 requested a review from a team July 15, 2022 10:57
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems plausible

@anoadragon453 anoadragon453 merged commit b1801ee into main Jul 18, 2022
@anoadragon453 anoadragon453 deleted the anoa/autofind_packages branch July 18, 2022 12:37
V02460 added a commit to V02460/matrix-python-common that referenced this pull request Oct 11, 2022
Use of the automatic discovery feature was intoduced with PR matrix-org#27. The
feature is only available in setuptools version 61 and later, though,
which this change documents in pyproject.toml.
V02460 added a commit to V02460/matrix-python-common that referenced this pull request Oct 11, 2022
Use of the automatic discovery feature was intoduced with PR matrix-org#27. The
feature is only available in setuptools version 61 and later, though,
which this change documents in pyproject.toml.

Signed-off-by: Kai A. Hiller <V02460@gmail.com>
V02460 added a commit to V02460/matrix-python-common that referenced this pull request Oct 11, 2022
Use of the automatic discovery feature was introduced with PR matrix-org#27. The
feature is only available in setuptools version 61 and later, though,
which this change documents in pyproject.toml.

Signed-off-by: Kai A. Hiller <V02460@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants