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

Replace pkg_resources #358

Merged
merged 4 commits into from
Nov 13, 2023
Merged

Replace pkg_resources #358

merged 4 commits into from
Nov 13, 2023

Conversation

fschulze
Copy link
Contributor

Just importing pkg_resources becomes slower and slower the more packages are installed. Even on fast machines with SSDs this can add a second or more to the startup time.

@fschulze
Copy link
Contributor Author

fschulze commented Jul 22, 2022

This will most likely fail for packages where the resources have to be extracted, as the used context wrapper will cleanup upon exit and the current *TemplateFile implementations currently try to access the file later. There should most likely be a separate class like ResourceTemplate and the loader should return that instead.

@malthe
Copy link
Owner

malthe commented Aug 29, 2023

@fschulze seems this is almost there? what remains here before we can merge

@fschulze
Copy link
Contributor Author

See my last comment. It fails for packages which have the templates zipped. I'm also not sure whether that case is covered by tests yet (and how hard such tests would be to implement/simulate).

@malthe
Copy link
Owner

malthe commented Aug 29, 2023

@fschulze that makes sense – perhaps we should shift this way of loading a file-based template to the *File classes – instead of having it in the loader?

But one question, doesn't the current code also fail with zipped templates?

@fschulze
Copy link
Contributor Author

I will most likely work on that this week.

@fschulze fschulze marked this pull request as ready for review October 11, 2023 12:39
@coveralls
Copy link

coveralls commented Oct 11, 2023

Pull Request Test Coverage Report for Build 6840603550

  • 126 of 138 (91.3%) changed or added relevant lines in 7 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 87.43%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/chameleon/template.py 42 48 87.5%
src/chameleon/tests/test_loader.py 75 81 92.59%
Totals Coverage Status
Change from base Build 6839785589: 0.2%
Covered Lines: 4283
Relevant Lines: 4792

💛 - Coveralls

@fschulze fschulze force-pushed the pkg_resources branch 2 times, most recently from 9a22b8c to 177e664 Compare October 12, 2023 05:21
@fschulze
Copy link
Contributor Author

The spec is now stored on the template and handled properly. The filename attribute is now marked as deprecated.

@malthe malthe merged commit eebc803 into malthe:master Nov 13, 2023
11 checks passed
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.

None yet

4 participants