@@ -30,23 +30,21 @@ associating a requirements file with the platform.
3030
3131### Defining a platform
3232
33- First, we define a "platform" using {obj}` pip.defaults ` . This associates an
34- arbitrary name with a list of Bazel {obj}` config_setting ` targets. Any name can
35- be used for a platform (it's name has no inherent semantic meaning), however,
36- the name should encode all the relevant dimensions that distinguish a
37- requirements file. For example, if a requirements file is specifically for the
38- combination of CUDA 12.9 and NumPY 2.0, then platform name should represent
39- that.
33+ First, we define a "platform" using {obj}` pip.default ` . This associates an
34+ arbitrary name with a list of Bazel {obj}` config_setting ` targets. While any
35+ name can be used for a platform (its name has no inherent semantic meaning), it
36+ should encode all the relevant dimensions that distinguish a requirements file.
37+ For example, if a requirements file is specifically for the combination of CUDA
38+ 12.9 and NumPy 2.0, then the platform name should represent that.
4039
4140The convention is to follow the format of ` {os}_{cpu}{threading} ` , where:
4241
43- Where:
4442* ` {os} ` is the operating system (` linux ` , ` osx ` , ` windows ` ).
4543* ` {cpu} ` is the architecture (` x86_64 ` , ` aarch64 ` ).
4644* ` {threading} ` is ` _freethreaded ` for a freethreaded Python runtime, or an
4745 empty string for the regular runtime.
4846
49- Additional dimensions should be appended and separated with underscore (e.g.
47+ Additional dimensions should be appended and separated with an underscore (e.g.
5048` linux_x86_64_musl_cuda12.9_numpy2 ` ).
5149
5250The platform name should not include the Python version. That is handled by
@@ -63,11 +61,11 @@ targets, you can define your own flags or implement custom config matching
6361logic. This allows you to model settings that aren't inherently part of
6462rules_python.
6563
66- This is typically done using [ bazel_skylib flags] , but any [ Starlark
64+ This is typically done using [ bazel_skylib flags] ( https://bazel.build/extending/config ) , but any [ Starlark
6765defined build setting] ( https://bazel.build/extending/config ) can be used. Just
6866remember to use ` config_setting() ` to match a particular value of the flag.
6967
70- Here in our example, we define a custom flag for CUDA version.
68+ In our example below , we define a custom flag for CUDA version.
7169
7270#### Predefined and common build settings
7371
@@ -89,15 +87,15 @@ contains commonly used settings for OS and CPU:
8987Note that these are the raw flag names. In order to use them with ` pip.default ` ,
9088you must use {obj}` config_setting() ` to match a particular value for them.
9189
92- ### Associating requirements to plaforms
90+ ### Associating Requirements to Platforms
9391
9492Next, we associate a requirements file with a platform using
95- {obj}` pip.parse.requirements_by_platform ` . This is a dictionary arg where
96- keys are requirements files, and the value is a platform name. The platform
97- value can use trailing or leading ` * ` to match multiple platforms. It can also
93+ {obj}` pip.parse.requirements_by_platform ` . This is a dictionary attribute where
94+ the keys are requirements files and the value is a platform name. The platform
95+ value can use a trailing or leading ` * ` to match multiple platforms. It can also
9896specify multiple platform names using commas to separate them.
9997
100- Note that Python version is _ not_ part
98+ Note that the Python version is _ not_ part of the platform name.
10199
102100Under the hood, ` pip.parse ` merges all the requirements (for a ` hub_name ` ) and
103101constructs ` select() ` expressions to route to the appropriate dependencies.
@@ -116,15 +114,15 @@ bazel build --@rules_python//python/config_settings:py_linux_libc=musl \
116114 --cpu=aarch64 //:binary
117115
118116# Build for freethreaded
119- bazel build --@rule_python //python/config_settings:py_freethreaded=yes //:binary
117+ bazel build --@rules_python //python/config_settings:py_freethreaded=true //:binary
120118```
121119
122120Note that certain combinations of flags may result in an error or undefined
123121behavior. For example, trying to set both freethreaded and CUDA at the same
124122time would result in an error because no requirements file was registered
125123to match that combination.
126124
127- ## Multiple Python version
125+ ## Multiple Python Versions
128126
129127Having multiple Python versions is fully supported. Simply add a ` pip.parse() `
130128call and set ` python_version ` appropriately.
0 commit comments