-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instrument libraries (distributions) rather than packages
To answer the questions we have, we need data on libraries installed in the environment, not packages that are imported. importlib_metadata gives us access to the RECORDS file (https://www.python.org/dev/peps/pep-0376/#record) for every package, and we build a reverse mapping of package name -> distribution once. Distribution (I am calling them libraries) names are then used. Since distributions are 'installed' specifically, they already ignore modules in the standard library and any local user written modules. The dependency on the stdlib_list library can be removed. All metric names have been changed to talk about libraries, not packages. The word 'package' is so overloaded, and nobody knows anything about 'distributions'. https://packaging.python.org/glossary/ is somewhat helpful. I will now try to use just modules (something that can be imported - since our source is sys.modules) and "library" (what is installed with pip or conda - aka a distribution). Despite what python/importlib_metadata#131 says, the package_distributions function in importlib_metadata relies on the undocumented `top_level.txt` file, and does not work with anything not using setuptools. So we go through all the RECORDs ourselves. Added some unit tests, and refactored some functions to make them easier to test. Import-time side effects are definitely harder to test, so I now require an explicit setup function call. This makes testing much easier, and is also more intuitive. Bump version number
- Loading branch information
Showing
5 changed files
with
228 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pytest | ||
pytest-cov | ||
pytest-mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.