@@ -1041,20 +1041,25 @@ by opening a new issue and including ``@conda-forge-admin, please add noarch: py
1041
1041
Noarch packages with OS-specific dependencies
1042
1042
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1043
1043
1044
- It is possible to build ``noarch `` packages with runtime requirements that depend on the target OS (Linux, Windows,
1045
- MacOS), regardless the architecture (amd64, ARM, PowerPC, etc). This approach relies on four concepts:
1046
-
1047
- 1. Virtual packages. Prefixed with a double underscore, they are used by conda to represent properties of the running system
1048
- as constraints for the solver. We will use ``__linux ``, ``__win `` or ``__osx ``, which are only present when
1049
- the running platform is Linux, Windows, or MacOS, respectively. ``__unix `` is present in both Linux and MacOS. Note
1050
- that this feature is **only fully available on conda 4.10 or above **.
1051
- 2. Jinja conditionals, which can be used to mimic platform selectors.
1044
+ It is possible to build ``noarch `` packages with runtime requirements that depend on the target OS
1045
+ (Linux, Windows, MacOS), regardless the architecture (amd64, ARM, PowerPC, etc). This approach
1046
+ relies on four concepts:
1047
+
1048
+ 1. `Virtual packages <https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-virtual.html >`__.
1049
+ Prefixed with a double underscore, they are used by conda to represent system properties as
1050
+ constraints for the solver at install-time. We will use ``__linux ``, ``__win `` or ``__osx ``,
1051
+ which are only present when the running platform is Linux, Windows, or MacOS, respectively.
1052
+ ``__unix `` is present in both Linux and MacOS. Note that this feature is **only fully available
1053
+ on conda 4.10 or above **.
1054
+ 2. Jinja ``{% if ... %} `` conditionals, which can be used to mimic platform selectors.
1052
1055
3. ``conda-forge.ymls ``'s :ref: `noarch_platforms ` option.
1053
- 4. conda-build's ``conda_build_config.yaml `` to create a matrix build that depends on the ``noarch_platforms `` values.
1056
+ 4. `conda-build variants <https://docs.conda.io/projects/conda-build/en/latest/resources/variants.html >`__.
1057
+ We can use ``conda_build_config.yaml `` to create a matrix build that depends on the
1058
+ ``noarch_platforms `` values.
1054
1059
1055
- The idea is to generate OS-specific noarch packages for the OS that need different dependencies. Let's say you have a pure
1056
- Python package, perfectly eligible for ``noarch: python ``, but on Windows it requires `` windows-only-dependency ``. You might
1057
- have something like:
1060
+ The idea is to generate different noarch packages for each OS needing different dependencies.
1061
+ Let's say you have a pure Python package, perfectly eligible for ``noarch: python ``, but on Windows
1062
+ it requires `` windows-only-dependency ``. You might have something like:
1058
1063
1059
1064
.. code-block :: yaml
1060
1065
:caption : recipe/meta.yaml (original)
@@ -1071,7 +1076,9 @@ have something like:
1071
1076
- numpy
1072
1077
- windows-only-dependency # [win]
1073
1078
1074
- We can replace it with:
1079
+ Being non-noarch, this means that the build matrix will include at least 12 outputs: three platforms,
1080
+ times four Python versions. This gets worse with arm64, aarch64 and ppc64le in the mix. We can get it down
1081
+ to two outputs if replace it with this other approach!
1075
1082
1076
1083
.. code-block :: yaml+jinja
1077
1084
:caption: recipe/meta.yaml (modified)
@@ -1115,11 +1122,12 @@ would never be true). Fortunately, we can change the default behaviour in ``cond
1115
1122
- linux-64
1116
1123
- win-64
1117
1124
1118
- This will provide two runners per package! But since we are using selectors in `` conda_build_config.yaml ``,
1119
- only one is true at a time. Perfect! All these changes require a feedstock rerender to be applied. See
1120
- :ref: `dev_update_rerender `.
1125
+ This will provide two runners per package! But since we are using selectors in
1126
+ `` conda_build_config.yaml ``, only one is true at a time. Perfect! All these changes require a
1127
+ feedstock rerender to be applied. See :ref: `dev_update_rerender `.
1121
1128
1122
- Last but not least, what if you need conditional dependencies on all three operating systems? Do it like this:
1129
+ Last but not least, what if you need conditional dependencies on all three operating systems? Do it
1130
+ like this:
1123
1131
1124
1132
.. code-block :: yaml+jinja
1125
1133
:caption: recipe/meta.yaml
0 commit comments