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

There is no option to install the project with --no-deps or equivalent #1733

Open
TurbineJoshua opened this issue Sep 24, 2024 · 1 comment

Comments

@TurbineJoshua
Copy link

I am currently working on a suite of Python projects where conflicting dependencies are to be expected. For example, we have a wheel that is depending on numpy==1.24.0 and a wheel that is depending on numpy==1.26.4. The way we've been approaching this is to generate an expanded_requirements.txt by installing each of the explicit dependencies in requirements.txt into a clean virtual environment using --dry-run and recording the returned dependencies into the expanded_requirements.txt file. In our hatch.toml we are defining:

[metadata.hooks.requirements_txt]
files = ["requirements.txt", "expanded_requirements.txt"]

The high-level idea is that the developer can then go through the expanded_requirements.txt and resolve conflicts. For example, delete the line referring to numpy==1.26.4 and confirm that the tests pass using numpy==1.24.0. Then, when the wheel is created, or environments are created, the --no-deps flag can be used with either pip or uv pip to install the dependencies explicitly listed in requirements.txt and expanded_requirements.txt.

However, when hatch goes to install the project, there is no way to specify --no-deps. Therefore, when I go to try and create the types or hatch-test environments, I see errors around the conflicting dependencies that would normally arise from trying to install the explicitly required packages.

I have attempted adding a uv.toml with:

[pip]
no-deps = true

This does correctly disable dependency expansion, but this ends up breaking the installation of hatch's infrastructure packages in the backends.

I think what I would like is either:

  • A way to specify arguments to the install command.
  • An explicit option for installing the hatch project using --no-deps.

For example, if I add skip-install = true to the [envs.hatch-test], then I am able to correctly load the shell. Once I'm in the shell, I can run uv pip install --no-deps -r requirements.txt -r expanded_requirements.txt to install all of the dependencies correctly. I thought of using this command in the post-install-commands, but it looks like none of install, pre-install-commands or post-install-commands are executed when skip-install is specified.

I am happy to help with a PR, but would love some feedback from the community (@ofek) on the best way to proceed. Thank you for your time!

@TurbineJoshua
Copy link
Author

I have solved this, for now, by using:

[envs.hatch-test]
skip-install = true

[envs.hatch-test.scripts]
"install-deps" = "uv pip install --no-deps -r requirements.txt -r expanded_requirements.txt ."

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

No branches or pull requests

1 participant