Upgrading Dependencies on Windows #59
Replies: 5 comments
-
I think hatch has big limitations regarding user-configured commands. It runs commands just with the default shell which can be wildly different on Windows, meaning that you're forced to use only "polyglot" commands - no variables of any kind, no wildcards, and also using only double quotes. I think your best bet at the moment is to not add this to Hatch (too self-referential anyway?) and keep those commands only in your shell history. Also as I keep saying, the most ergonomic way to perform an upgrade is just to delete the lock file 😅 |
Beta Was this translation helpful? Give feedback.
-
So I've had an idea for a This would be a CLI outside of hatch so you would need to install it separately - but essentially all it does is temporarily set the Examplespipx install hatch-pip-compile
|
Beta Was this translation helpful? Give feedback.
-
This looks very promising to me. It would be nice if the cli is compatible to the envisioned hatch plugin cli such that the only change for a future version would be to remove the "-" between hatch and pip-compile. |
Beta Was this translation helpful? Give feedback.
-
Following up here, the |
Beta Was this translation helpful? Give feedback.
-
@juftin this is really nice and useful! The link at in the README.md is wrong so it took me a while to find 🙈. Seems to be due to the refactor commit 1d3dd12. I seem to be able to avoid having to install the plugin in the root python installation by prepending hatch run to the command: [tool.hatch.envs.default.scripts]
upgrade-all = "hatch env run --env {env_name} -- hatch-pip-compile -U"
upgrade-pkg = "hatch env run --env {env_name} -- hatch-pip-compile -P '{args}'"
The upgrade all works as intended! However when using hatch-pip-compile: Upgrading packages: 'pydantic'
hatch-pip-compile: Targeting environments: default
hatch-pip-compile: Running `hatch env run --env default -- python --version` |
Beta Was this translation helpful? Give feedback.
-
The scripts provided in the readme.md for upgrading dependencies works in linux only as setting an environment variable in windows for a command is not done in the same way.
Now i have tried to make a seperate script for linux and for windows without success, example:
My current working workaround is to use
hatch shell
followed by$env:PIP_COMPILE_UPGRADE=1 ; pip -V
Any ideas?
The best fix i can think of to not have linux and windows specific commands is to introduce a command to the hatch cli from the plugin, but this feature is not yet possible but there is a PR ongoing pypa/hatch#798
Then something like
hatch pip-compile upgrade
would be possible.Beta Was this translation helpful? Give feedback.
All reactions