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
hatch-pip-compile --upgrade #8
Comments
🤔 Maybe |
🤔 Maybe we should stop with the |
That was my first thought, yeah. Another thing could be to include a large command like the one that I had in the original post with
I'm not sure if I fully understood this comment, but yeah, a temporary file is not necessary (also demonstrated in my original post). But it'll be You could probably do a plain find&replace on the filename to avoid the ugly parts, right? |
Actually.. don't mind my comment, it seems I'm just saying the same stuff that you already said at the top. |
Well.. one universal command that we already have is rm requirements/requirements-envname.txt; hatch run envname:true |
Yeah - the more I'm thinking about this the more I think it's right for a CLI. Probably something similar that combines something like this with the same post-processing that the tool does on the backend.
Similarly, |
@oprypin what would you think about a workflow like this for upgrading dependencies instead of a CLI? I was writing a CLI for the tool but figured this would be easier and has the benefit of the plugin handling the lockfile generation instead of a CLI external to the hatch environment. (taken from the README on a feature branch): Updating DependenciesPassing arguments like The below command runs PIP_COMPILE_UPGRADE=1 hatch env run --env default -- python --version The below command runs PIP_COMPILE_UPGRADE_PACKAGE="mkdocs,mkdocs-material" hatch env run --env docs -- python --version The above commands call |
Well one thing is, I think a CLI would run into a lot of issues being accessed, because yeah, if it's used through |
I got a CLI working but there are two not so-ideal options that it made me decide between:
I feel like an in-plugin implementation makes the implementation much more straightforward by only having one way that |
Actually I have an idea for this. What if, instead of this being an issue, you turn it into the place where the upgrade actually happens. Just set some kind of override (such as the environment variable as being implemented elsewhere) and make the But I still didn't get how the previous issue I mentioned would be solved - the CLI would probably be isolated by pipx and inaccessible by default? |
I'm not completely following here. Is the idea for a CLI tha handles setting the |
Yes |
That works - the way I'm thinking about it there might be four ways of doing an Removing the lock and invoking the env: rm requirements.txt
hatch env run --env default -- python --version Setting the env var and invoking the env: PIP_COMPILE_UPGRADE=1 hatch env run --env default -- python --version Installing the CLI outside of hatch - it sets the env var and invokes the env under the hood: pipx install hatch-pip-compile
hatch-pip-compile default --upgrade Creating a hatch script to set the env var and invoke the env (this might be an interesting thing to do with an Environment Collector plugin too): [tool.hatch.envs.requirements]
detached = true
[tool.hatch.envs.requirements.scripts]
upgrade = "hatch env run --env {args} -- python --version"
[tool.hatch.envs.requirements.env-vars]
PIP_COMPILE_UPGRADE = "true" hatch run requirements:upgrade default |
Ah interesting regarding the latest idea. The sad thing about an environment collector plugin though is that it needs to be explicitly mentioned in the config in order to kick in. As in this example Anyway I'm just rambling. These are all very cool ideas but in the end probably only the first two from the above list will be viable. In any case, sure, only the "delete" option and one other option of choice should be the documented one. |
🎉 This issue has been resolved in version 1.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Currently updating requirements can be tough because of the way the plugin is implemented:
Current Implementation
requirements.in
file with a project's dependenciesrequirements.in
file as the input topip-compile
with the output being the respective lock filerequirements.in
file and not the actualpyproject.toml
- some post-processing occurs replacing lines like# via -r /var/folders/qk/mw5mftjj0qz42nrxrnhctlzw0000gp/T/tmpo85wegym/default.in
with# via hatch-pip-compile (pyproject.toml)
as well as to add the customhatch-pip-compile
headerBecause of that implementation there isn't currently a command you could run locally that would update the file in-place. Ideally something like this would just work:
However running that above command will blow away the
hatch-pip-compile
header.At this point this issue is just a placeholder and place to brainstorm ideas for the ideal workflow with
pip-compile
The text was updated successfully, but these errors were encountered: