-
Notifications
You must be signed in to change notification settings - Fork 543
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
Allow pip_repository (and pip_parse) to "select" requirements based on both OS and architecture #735
Comments
@likesum FYI. |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
bump. generated requirements differ between architectures, thus making version control of e.g. lock files very difficult |
This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days. |
In order to solve this problem we settled on using a workspace rule we call Our
It would be nice if there was a better solution "in the box", but per platform+venv lockfiles appears the best way to go and it would be somewhat unreasonable to teach |
Hi @aignas - thanks for #1593! My understanding of this is that we can point to dependencies that are OS-specific, but not architecture specific. For example, one can do Is there a way to switch between architectures? If not, should the API expose something akin to (FWIW I see the title of #1625 contains "multi-arch", but I'm not following how to actually switch between different architectures on say linux.) |
@thomasegriffith, thanks for the comment. What is your usecase for having different requirements files? I'd like to know a little bit more about how people use this feature. I would expect that for a particular python version, one could just have the superset of all requirements files listing all of the dependencies that are needed by all platforms and then bazel will lazily download only the required ones. Or is it that the versions for packages are different for different platforms? |
@aignas, exactly. I've had to use specific versions of packages for certain platforms, because sometimes a version of a particular package is buggy or even nonexistent for one platform but not for other platforms. I've also had to build wheels from source for certain platforms, in which case I end up pointing to a local wheel in my pip requirements, all while using the main repository for other platforms. Another thing to consider is that sometimes even the OS / architecture combination isn't sufficient. For example, the |
With this change we can in theory have multi-platform libraries in the dependency cycle and use the pip hub repo for the dependencies. With this we can also make the contents of `whl_library` not depend on what platform the actual dependencies are. This allows us to support the following topologies: * A platform-specific wheel depends on cross-platform wheel. * A cross-platform wheel depends on cross-platform wheel. * A whl_library can have `select` dependencies based on the interpreter version, e.g. pull in a `tomli` dependency only when the Python interpreter is less than 3.11. Relates to bazelbuild#1663. Work towards bazelbuild#735.
With this PR the code becomes more maintainable and easier to inspect. Since bazel-skylib is already a dependency of rules_python, this is a backwards compatible change. Skipping the CHANGELOG notes because it should not be an externally visible change. Work towards #735.
…#1856) With this change we can in theory have multi-platform libraries in the dependency cycle and use the pip hub repo for the dependencies. With this we can also make the contents of `whl_library` not depend on what platform the actual dependencies are. This allows us to support the following topologies: * A platform-specific wheel depends on cross-platform wheel. * A cross-platform wheel depends on cross-platform wheel. * A whl_library can have `select` dependencies based on the interpreter version, e.g. pull in a `tomli` dependency only when the Python interpreter is less than 3.11. Relates to #1663. Work towards #735.
…nency closures We start using the recently introduced is_python_config_setting to make it possible to have a working select statement when multiple python version selection needs to happen in a whl_library Work towards bazelbuild#735.
We start using the recently introduced `is_python_config_setting` to make it possible to have a working select statement when multiple python version selection needs to happen in a `whl_library`. This adds further fixes so that the correct dependencies are pulled in when the `python_version` string flag is unset thus making this implementation suitable for `bzlmod` use case where we would use a single `whl_library` instance for multiple python versions within the hub. Work towards bazelbuild#735.
…nency closures (#1875) We start using the recently introduced `is_python_config_setting` to make it possible to have a working select statement when multiple python version selection needs to happen in a `whl_library`. This adds further fixes so that the correct dependencies are pulled in when the `python_version` string flag is unset thus making this implementation suitable for `bzlmod` use case where we would use a single `whl_library` instance for multiple python versions within the hub. Work towards #735.
This PR implements a better way of specifying the requirements files for different (os, cpu) tuples. It allows for more granular specification than what is available today and allows for future extension to have all of the sources in the select statements in the hub repository. This is replacing the previous selection of the requirements and there are a few differences in behaviour that should not be visible to the external user. Instead of selecting the right file which we should then use to create `whl_library` instances we parse all of the provided requirements files and merge them based on the contents. The merging is done based on the blocks within the requirement file and this allows the starlark code to understand if we are working with different versions of the same package on different target platforms. Fixes #1868 Work towards #1643, #735
This has been done in #1885 |
🚀 feature request
Relevant Rules
pip_repository
and by extensionpip_parse
.Description
Because
pip_repository
is a repository rule, it somewhat awkwardly uses several attributes to override the default requirements file based exclusively on a limited selection of operating systems (linux, macos, windows).Now that ARM is a more popular architecture and available on all three operating systems, we need a way to select among that axis as well. Otherwise, some wheels that have native dependencies may not be available on certain architectures. We may want to consider an "os version" as a third axis as well. For example, rawpy is available on MacOS but only on Intel, and possibly only MacOS 10.9 (I don't have a machine to test).
Describe the solution you'd like
Because it's awkward to add all possible combinations as new attributes, perhaps we should consider passing in a dictionary of tuples to match against fields in repository_os. The current implementation uses only
.name
. It's easy to add.arch
to match against arch. It might be a little tricky to add "OS version" as it requires either adding a new field torepository_os
(probably possible), or invoking a platform-dependent shell script.Describe alternatives you've considered
Passing in a struct? It's more or less the same as a dictionary.
The text was updated successfully, but these errors were encountered: