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

port to packaging to avoid pkg_resources import cost #840

Closed
RonnyPfannschmidt opened this issue Oct 8, 2018 · 5 comments
Closed

port to packaging to avoid pkg_resources import cost #840

RonnyPfannschmidt opened this issue Oct 8, 2018 · 5 comments
Labels

Comments

@RonnyPfannschmidt
Copy link

its expensive to import pkg_resources if all that's needed is version parsing of packaging

it should be relatively straightforward to simplify and port

@asottile
Copy link
Member

asottile commented Oct 8, 2018

It's not just that, is there a direct replacement for

VERSION = pkg_resources.get_distribution('pre-commit').version

@asottile asottile changed the title port to packaging to avoid pkg_ressources import cost port to packaging to avoid pkg_resources import cost Oct 8, 2018
@RonnyPfannschmidt
Copy link
Author

@asottile that part needs a little expansion, personally i'd propose setuptools_scm and writing a version file to the package as importation is so much faster than workingset construction and packageset iteration

@asottile
Copy link
Member

asottile commented Oct 9, 2018

Nothing personal, but I'm not going to use setuptools-scm, it seems a bit over engineered for what equates to writing a text file.

There's three parts here that need solving:

  • self-referential version number
  • resource files
  • version comparison

The first can reasonably be solved with writing a version number at install time, I really don't want to get setup_requires (eggs) involved.

The second is a bit trickier, maybe importlib_resources? (backport of 3.7 package) -- that pulls in a lot of dependencies for something that to me seems like it should be simple. Should I care to support eggs and zipimport as distribution methods for pre-commit? Should I require consumers to use pip (or equivalent)?

The third is by far the easiest, pre-commit doesn't have any complicated version numbers (yet, and I don't plan on it) and really it can be replaced with map(int, s.split('.'))

@asottile
Copy link
Member

asottile commented Oct 9, 2018

and hmm, even setuptools-scm suggests using pkg_resources: https://github.com/pypa/setuptools_scm#setuppy-usage

@RonnyPfannschmidt
Copy link
Author

@asottile im the maintainer there that wrote the suggestion, its generally more useful for packages that do not have import time constraints - for example pytest uses the entrypoint system excessively anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants