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

Install pip deps like conda #2241

Merged

Conversation

michalsieron
Copy link
Contributor

Fixes #1894

Suppose we have the following dependencies in the environment.yml:

```
dependencies:
  - pip
  - pip:
    - -r requirements.txt
    - -e deps/my_local_package
```

Without this commit, it is impossible to install such dependencies with
micromamba. That is because micromamba was creating its own temporary
requirements.txt file in the /tmp directory and called pip to install them.

For some reason pip resolves `-r` paths as relative to the file that
contains them, but `-e` paths as relative to the current working directory.
It is a known issue in pip: pypa/pip#8765.

So in the case of mamba, pip looks for `/tmp/requirements.txt` and
`directory/of/env/yml/deps/my_local_package` and unless whole project
is thrown right into `/tmp` this installation will fail.

This commit makes it so installing pip deps matches the behavior of conda.
@michalsieron michalsieron force-pushed the msieron/install-pip-deps-like-conda branch from 932ead4 to 374d8b7 Compare January 21, 2023 22:12
@jonashaag
Copy link
Collaborator

Thanks for the PR! Can you please add a test for this change?

@michalsieron
Copy link
Contributor Author

I think I fixed the formatting errors, however I am not sure where I should write those tests.
My changes are in libmamba and I can't find tests related to resolving and installing pip dependencies. Such test would need to start pip subprocess to test if it was successful in installing the dependencies specified in the temporary file.

@jonashaag
Copy link
Collaborator

You could add a test in the micromamba Python tests, maybe here? https://github.com/mamba-org/mamba/blob/main/micromamba/tests/test_create.py Feel free to create additional test files. I just saw that there are spec_file_{1,2}.txt but they seem unused.

@wolfv
Copy link
Member

wolfv commented Feb 2, 2023

I've made some small adjustments. Since this doesn't make the testing status worse, I think it's fine to merge as is.

@wolfv wolfv merged commit 870d8d4 into mamba-org:main Feb 2, 2023
@michalsieron michalsieron deleted the msieron/install-pip-deps-like-conda branch February 3, 2023 11:30
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

Successfully merging this pull request may close these issues.

Problems with installing pip's -r dependencies
3 participants