-
Notifications
You must be signed in to change notification settings - Fork 5
Description
The first of the open issues on the pre-GLEP is:
How should dependencies be expressed when a package depends on a variant of another package?
I think it makes sense to start discussing that. I'm going to list some specific problems and ideas I can think of.
Dependencies in metadata
I think the first question that needs to be answered is what kind of dependencies do we need to express. I'd like to propose a few for initial discussion, with some pseudocode syntax. For now, let's start with the actual dependencies that will appear in the generated metadata for a distribution, rather than the specification used in pyproject.toml
, etc.
- Requiring a specific variant:
blas::variant::openblas
- wheels without
blas::variant
or with any other variant are not permitted
- wheels without
- Requiring one of permitted variants:
blas::variant::{mkl,openblas}
- either
mkl
oropenblas
variant is permitted - wheels without
blas::variant
or with any other variant are not permitted
- either
- Requiring any variant to be present:
blas::variant::*
- any
blas::variant
is permitted - wheels without
blas::variant
are not permitted
- any
- Disallowing a specific variant:
!blas::variant::mkl
- any
blas::variant
other thanmkl
is permitted - wheels without
blas::variant
are permitted
- any
- Requiring a variant other than the specified set:
blas::variant::^{mkl,openblas}
mkl
andopenblas
are not permitted, other variants (including new variants) are permitted- wheels without
blas::variant
are not permitted - kinda redundant, can be more verbosely expressed as:
blas::variant::* !blas::variant::mkl !blas::variant::openblas
These are all the simple cases I can think of. Technically, we could consider more complex solutions — perhaps even being able to express stuff like "I'm fine with any version of torch
but if a CUDA-enabled version is installed, I also need triton
" (presuming torch
wouldn't depend on triton
itself). But given that the requirement syntax in wheels is already quite limited and we managed, I don't think we really need to overthink that — that is, unless we are actually trying to extend dependencies in general.
Dependency specifications in pyproject.toml
The above options are good for generated metadata, but pyproject.toml
would probably need some more:
- Requiring the same variant as used to build this package:
blas::variant::=
- creates
blas::variant::mkl
when building amkl
variant,openblas
when buildingopenblas
variant, etc. - should we just skip it when building with no
blas::variant
?
- creates
- Requiring any supported variant when building against any other variant:
cuda::runtime::?
- creates
cuda::runtime::*
when building a CUDA variant, no dependency otherwise - could be used to require a CUDA-enabled dependency without fixing on a specific version
- abuses the fact that two incompatible versions cannot be "supported" on the same system, so a wheel with a compatible runtime will always be selected
- creates
Full syntax
I would lean towards reusing the "extras" syntax. For example:
torch[optree,cuda::runtime::*]
Since names of "extras" don't permit :
, the variant syntax would not collide with existing extras. I think it also fits reasonably well mentally, as a similar enough concept: "I want optree support" and "I want a CUDA-enabled variant".
Metadata
Metadata
Assignees
Labels
Type
Projects
Status