-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
poetry export pre-commit hook #2457
Comments
Hey @Diaoul, sounds like this is something for the upcoming plugin system. fin swimmer |
My code is only rearranging arguments for improved pre-commit compatibility. I don't think a full blown plugin system is necessary for that to be delivered. It's common for libraries with a CLI to ship pre-commit hooks officially (black and isort for example). So it would be an officially supported plugin? Is that a thing? |
Hello @Diaoul, I see now. I misunderstood your feature request. This is really nothing for the plugin system. I cannot answer the question by my own, whether we will create and support such a pre-commit hook. So I let this request open for further discussion. fin swimmer |
Thanks @finswimmer, I'll wait for others to weight in. |
Also relevant to add here https://pre-commit.com/hooks.html |
I just also had the idea to add In itself the setup is straightforward and pretty easy. You just need to add the file with the correct config and done. I did this on my fork to prepare a PR (#2511). Then I went to test it and a catastrophic error occurred: check-egg-error (as it seems) When I clone the poetry repo I cannot install it via
repos:
- repo: https://github.com/Cielquan/poetry
rev: 81d92b53d742f874f260f14651f340c04592cfdf
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "requirements.txt"] You can also just clone the repo and try to install it with Here the output from pre-commit. It looks almost the same when you do Click to expand output
SolutionsSo before we can proceed the chicken-egg-problem must be solved. The solutions I came up with could be:
old: [build-system]
requires = ["intreehooks"]
build-backend = "intreehooks:loader"
[tool.intreehooks]
build-backend = "poetry.masonry.api" new: [build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
I think option 2 and 3 are overhead and IMO option 1 is the solution. If the solutions above all don't sound good to the devs and there are no other solutions
I personally don't like both workarounds because the first one is too specific and the second is just a hack to pre-commit and no clean solution. I implemented solution 1 in my draft PR and you can test it with the following repos:
- repo: https://github.com/Cielquan/poetry
rev: b9c381b6a8c5226e79cbec30de99c7bcda537089
hooks:
- id: poetry-check
- id: poetry-lock
- id: poetry-export EDIT: Added |
Stumbled on this looking for something else. |
I took a simpler approach I guess? Supposing
|
Well good point. I think for local development its fine, but when you want to run it in CI I think it gets eventually problematic. When #2511 gets merged the issue will be nonexistent anymore. |
I created a mirror of poetry for use with pre-commit. I plan to support it as of now till #2511 gets merged. The current version 1.1.4 is the only one supported at the moment. As poetry releases new versions they will be added also. If you need a specific earlier version for whatever reason leave me an issue so I will add the corresponding tag. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature Request
Having both a requirements.txt file and pyproject.toml + poetry.lock file may seem like duplication but it is sometimes needed for example for installing dependencies in Docker without loosing the cache on version bump or other changes unrelated to dependencies.
Installing poetry on the docker image is also a bit of a pain, and slower than pip as mentioned on other issues.
For all those reasons I decided to maintain a requirements.txt in addition to poetry, I wanted this process to be smooth and never forget about it so I created this simple pre-commit-hook that takes care of running poetry export for me! 🍰
This issue is a feature request for having poetry-related pre-commit hooks like this one maintained here rather than on 3rd party repositories.
The text was updated successfully, but these errors were encountered: