@@ -183,3 +183,61 @@ An orderer that does not change the order - a no op.
183
183
This orderer is useful in cases where you want to apply some default orderer
184
184
to a set of packages, but may want to explicitly NOT reorder a particular
185
185
package. You would use a :class: `rez.package_order.NullPackageOrder ` in a :class: `rez.package_order.PerFamilyOrder ` to do this.
186
+
187
+
188
+ Custom orderers
189
+ ===============
190
+
191
+ It is possible to create custom orderers using the API. This can be achieved
192
+ by subclassing :class: `rez.package_order.PackageOrder ` and implementing some mandatory
193
+ methods. Once that's done, you need to register the orderer using :func: `rez.package_order.register_orderer `.
194
+
195
+ .. note ::
196
+
197
+ Implementing a custom orderer should only be done if absolutely necessary.
198
+ It could make your environment behave in very special ways and more importantly
199
+ in non expected ways from a user perspective. It can also make it harder to share
200
+ the set of affected packages to others.
201
+
202
+
203
+ .. code-block :: python
204
+ :caption: rezconfig.py
205
+
206
+ from rez.version import Version
207
+ from rez.package_order import PackageOrder, register_orderer
208
+
209
+
210
+ class MyOrderer (PackageOrder ):
211
+ name = " my_orderer"
212
+
213
+ def __init__ (self , custom_arg : str , ** kwargs ):
214
+ super ().__init__ (self , ** kwargs)
215
+ self .custom_arg = custom_arg
216
+
217
+ def sort_key_implementation (self , package_name : str , version : Version):
218
+ pass
219
+
220
+ def __str__ (self ):
221
+ pass
222
+
223
+ def __eq__ (self , other ):
224
+ pass
225
+
226
+ def to_pod (self , other ):
227
+ pass
228
+
229
+ @ classmethod
230
+ def from_pod (cls , data ):
231
+ pass
232
+
233
+
234
+ register_orderer(MyOrderer)
235
+
236
+ package_orderers = [
237
+ {
238
+ " type" : " my_orderer" ,
239
+ " custom_arg" : " value here"
240
+ }
241
+ ]
242
+
243
+ For more details, please see :gh-rez: `src/rez/package_order.py `.
0 commit comments