Environment collector plugin + environment plugin = ❤️ #1052
oprypin
started this conversation in
Show and tell
Replies: 1 comment
-
It makes me very happy to hear you're having a good experience! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I got super inspired by @juftin's new plugin https://github.com/juftin/hatch-pip-compile (I'm really gonna add it to all my projects)
and then I had some ideas about another plugin and I was just thinking how I could make it work together with this one,
and the "environment collector" docs jumped out at me, and it's honestly the most perfect combination I could ever imagine.
I had 2 wishes that seemed to pull in totally opposite directions.
I don't want to manually specify PyPI dependencies for MkDocs sites because that could just be inferred from
mkdocs.yml
I want all dependencies to be locked though, so that the site's build is reproducible and doesn't rot.
And Hatch didn't support either of these wishes, so I had something cobbled together that only satisfied (2.)
But now... we have 2 separate Hatch plugins that perfectly satisfy the respective wishes, and the plugin system for this is so well thought out that they can both be used together or either one at a time, without them ever knowing anything about each other.
The environment collector plugin hatch-mkdocs creates an environment definition (it can be seen like virtually writing into the config file) with
dependencies
populated on the fly.The environment plugin hatch-pip-compile reads
dependencies
, populates a lock file from them, and installs the environment based on the lock file.So I did actually get exactly what I wanted - the dependencies aren't written out anywhere, but the lock file is. And I can still update the lock file any time.
So now I can just add a few config lines that can be copy-pasted with 0 changes across all Hatch projects, and I get the absolute best of all worlds - the virtual environment for MkDocs is fully managed with 0 inputs.
Even better, if someone checks out my project but really doesn't like Hatch, they can just find that requirements lock file and
pip install
it directly! So absolutely zero lock-in as well. (And actually for quicker GitHub Actions builds, I do skip installing Hatch and rely on the lock file instead, and nobody's stopping me!)EDIT:
Forgot to mention - here's an example of my soon-to-be setup that I'm so excited about
oprypin/mkdocs-literate-nav@080c735
Beta Was this translation helpful? Give feedback.
All reactions