-
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
Build poetry package with extra or optional dependencies #2567
Comments
@JulianRMedina Is this stack-overflow answer related? |
@teichert, thank you for the response but this is a different problem than what I was thinking. That stack-overflow post talks about the install of optional or extra dependencies, I'm specifically talking about the inclusion of optional/extra dependencies in a package wheel. My exact use-case was the following:
or something similar, so that I can create two different wheels, one with support for a CPU, and another with support for a GPU. After considering this, it may be some type of anti-pattern, and I curse onnxruntime for separating support for CPU and GPU but it's the scenario I am in. |
Considering all of the above, it is unlikely that such a feature, as you have described, will be implemented. Especially since the wheels need to adhere PEP 427. Typically, this is usually handled by specifying extras (as mentioned above). There is a broader feature that might benefit a use case like this described in #2270. But that is still under discussion. As for a way forward for your package, I would recommend something like the following. [tool.poetry]
name = "awesome"
[tool.poetry.dependencies]
onnxruntime = { version = "^1.3.0", optional = true }
onnxruntime-gpu = { version = "^1.3.0", optional = true }
[tool.poetry.extras]
cpu = ["onnxruntime"]
gpu = ["onnxruntime-gpu"] While this would mean that the user needs to decide if they want to install the cpu version or the gpu version ahead of time, this will ensure that the user only installs the required dependencies for their environment. # this will install onnxruntime and not onnxruntime-gpu
pip install awesome[cpu]
# this will install onnxruntime-gpu and not onnxruntime
pip install awesome[gpu] Even if you had two separate wheels built as you described, you will end up with exactly the same content in both wheels except for one requirement specification in the wheel metadata having a suffix If you absolutely must have a separate package you could, split the project into three. A common package that contains your logic and a |
@abn I appreciate the feedback and feel settled in the matter, and I thought I may have been chasing some sort of anti-pattern to my problem. I'll resolve this now. |
I'm confused. Even if we build and publish the package with poetry, what happens when the user wants to install the package with one of the 2 extras? I published the package and tried to install it in a different environment from PyPI but something like: didn't work in that case. |
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. |
Feature Request
Looking through the documentation I was able to find adding optional/extra dependencies to a project as well as installing, but I could not find information about their inclusion in the build process. I see two scenarios:
The text was updated successfully, but these errors were encountered: