-
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
Document the workaround of "ModuleNotFoundError" when setup.py depends on custom dependencies like 'torch' #9707
Comments
this is not a good workaround, the whole point of an isolated build environment is that it should be isolated. you should prefer to raise issues with projects that do not build with isolated environments asking them either (or both) to:
|
The reality of it is that a large amount of python packages have this problem specifically. I agree that this is a problem with the packages, but it would be nice if poetry for example allowed to specify build requirements for such packages in |
@deivse I have to agree with @dimbleby here, this is a problem for the project. While it might be nice to provide an override feature, it introduces a significant maintenance burden for Poetry maintainers. And when considering that standards exist for a reason and a feature like that would encourage misbehaving actors in the ecosystem, I do not think there is sufficient value there. I am not saying that this specific case is misbehavior, it is likely a simple misconfiguration that haven't been caught yet in the development process - a lot of these cases are. I understand that it would be nice to have the flexibility, amongst other priorities this might not be a top one. I have raised open-mmlab/mmagic#2154 to help fix the issue. But note that |
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. |
Issue Kind
Other
Description
I'm working on deploying the AI/ML models to production. I'm using Poetry for dependency management and notably the lock file capabilities. However, I observe a common problem that many AI packages have custom dependencies like
torch
in theirsetup.py
:Steps to reproduce:
Now I edit my
pyproject.toml
to have a dependency onhttps://github.com/open-mmlab/mmagic.git
:Locking:
So the problem is that mmagic's setup.py depends on
torch
as build dependency.Attempt 1: try to add this dependency to
[build-system]
:Attempt 2: try to install
torch
into my poetry virtualenv:So the problem is that poetry creates a new isolated virtual environment using
virtualenv
, which uses the default value of--system-site-packages=false
. However, this value can be overwritten using env varVIRTUALENV_SYSTEM_SITE_PACKAGES=true
:Success!
Conclusion
I think this workaround should be officially supported (by guaranteeing that
--system-site-packages
won't be overwritten by poetry when creating temporary virtual envs and clearly documented in a troubleshooting section.Impact
see details in Description
Workarounds
So Poetry can't work on the listed set of packages, even if running within a docker image where
torch
is definitely installed, for example:I don't know a better workaround of this issue rather than
RUN poetry export --output=requirements.txt
and thenpip install -r requirements.txt
, which is a dirty hack because solves only a part of the problem (installing in docker image in CI/CD) and doesn't work for setting up my local dev environment.The text was updated successfully, but these errors were encountered: