You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
summary: Platforms constrain environments to help development teams stay consistent.
4
+
weight: 25
5
+
---
6
+
7
+
As a concept, platforms are packages that only provide _opinions_ on what should exist in an environment. They contain no files or code, and have no concrete dependencies but limit what versions are allowed in order to enforce consistency across teams, applications and developers.
8
+
9
+
As an example, the [VFX Reference Platform](https://vfxplatform.com/) provides "a set of tools and library version to be used as a common target platform for building software for the VFX industry". Platforms in SPK were designed to be able to describe and enforce these kind of recommendations.
10
+
11
+
### Platforms are Packages
12
+
13
+
At their core, platforms are a convent way to write package specs that only provide an opinion on what versions can be used and nothing else. Once defines, platforms are still built, published, and used the same way as any other package.
14
+
15
+
A platform spec reduces the amount of boilerplate needed to set up a platform package compared to using the full `v0/package` recipe format. A platform spec will be filled in with appropriate defaults automatically for a platform-style package.
16
+
17
+
### Creating Platforms
18
+
19
+
Below is an example platform
20
+
21
+
```yaml
22
+
api: v1/platform
23
+
platform: company-platform/2025.01.01
24
+
requirements:
25
+
- pkg: gcc
26
+
atBuild: =9.3.1
27
+
atRuntime: 9.3.1
28
+
- pkg: python
29
+
atBuild: =3.9.18
30
+
atRuntime: 3.9
31
+
- pkg: imath
32
+
atBuild: =3.0.1
33
+
atRuntime: 3
34
+
```
35
+
36
+
The `platform:` fields provides the name of the platform package. The
37
+
`api:`field indicates this is a platform spec.
38
+
39
+
The `requirements` field contains the list of requirements in the
40
+
platform. In each case, the requirement specifies the version request to be
41
+
used at build time vs at run time. This allows the platform to differently
42
+
constrain the requirement depending on if it's being used to define a build
43
+
environment or a runtime environment.
44
+
45
+
These requirements are placed onto the `build` and `run` components of the package
46
+
generated by this platform, respectively. The generated requirements will have
47
+
`include: IfAlreadyPresent` added to them automatically, it does not need to be
48
+
specified for them.
49
+
50
+
#### Inheritance
51
+
52
+
Additionally, the platform spec provides a way to inherit requirements from another package. Typically, it makes the most sense to inherit from another platform, but it could be any package.
53
+
54
+
By inheriting from base packages, platforms can augment and override their requirements. For example, a DCC (Digital Concent Creation) application platform can inherit the requirements from company or site-specific platform and then introduce additional constraints for the application itself.
55
+
56
+
Here is an example platform spec that inherits from the 'company-platform' and makes adjustments of its own:
57
+
58
+
```yaml
59
+
api: v1/platform
60
+
platform: dcc-platform/2025.01.01
61
+
base:
62
+
- company-platform/2024.01.01
63
+
requirements:
64
+
# this DCC uses an older version of python
65
+
- pkg: python
66
+
atBuild: =3.7.10
67
+
atRuntime: 3.7
68
+
# it also has no need to constrain the version of imath that's used
69
+
- pkg: imath
70
+
atBuild: false
71
+
atRuntime: false
72
+
```
73
+
74
+
The `base:` field indicates which platform this one inherits from. In the case of multiple bases, each one simply overrides the previous in turn.
75
+
76
+
Any `atBuild` or `atRuntime` value that is specified in the platform spec will override the same value for the named requirement in the bases. Conversely, this also means that if a requirement omits either of the `atBuild` or `atRuntime` fields, then the value from the base will still remain.
77
+
78
+
The special `false` value can be used to remove the requirement entirely.
79
+
80
+
This is the complete specification of the same resulting `dcc-platform` without basing it on the `company-platform`:
Copy file name to clipboardexpand all lines: docs/use/spec.md
+4-99
Original file line number
Diff line number
Diff line change
@@ -257,6 +257,10 @@ The spk build system performs a number of validations against the package create
257
257
258
258
The install configuration specifies the environment that your package needs when it is installed or included in an spk environment.
259
259
260
+
{{% notice info %}}
261
+
Packages that only provide opinions/constraints on an environment, but no actual dependencies or content are considered 'platform' packages. SPK provides a native spec for this use case, see {{< ref "./platforms" >}}.
262
+
{{% /notice %}}
263
+
260
264
#### Environment Variables
261
265
262
266
Packages can append, prepend and set environment variables at runtime if needed. Furthermore, you are able to add comments and set the priority of the generated activation script. It's strongly encouraged to only modify variables that your package can reasonably take ownership for. For example, the `python` package should be the only one setting `PYTHON*` variables that affect the runtime of python. This is not an enforced rule, but if you find yourself setting `PYTHONPATH`, for example, then it might mean that you are installing to a non-standard location within spfs and breaking away from the intended consistency of spfs.
@@ -414,105 +418,6 @@ install:
414
418
- { var: abi, static: cp27m }
415
419
```
416
420
417
-
#### Platform Package Specs
418
-
419
-
Platforms are a convenience for writing the package spec for
420
-
"meta-packages"used to specify versions of a set of packages. They
421
-
are used to constrain builds of other packages and do not contain
422
-
usable programs, libraries or code themselves.
423
-
424
-
A typical platform package has an empty build options list, and one or
425
-
more install requirements, all in `IfAlreadyPresent` mode. These
426
-
install requirements describe the versions of dependencies that target
427
-
compatibility with some application execution environment, like a
428
-
DCC.
429
-
430
-
A platform spec reduces the amount of boilerplate needed to set up a
431
-
platform package compared to using the v0/package recipe format. A
432
-
platform spec will be filled in with appropriate defaults
433
-
automatically for a platform.
434
-
435
-
The platform spec also provides a way to inherit package requirements
436
-
from another package, such as another platform. This allows platforms
437
-
to be based on other platforms without respecifying the same
438
-
requirements, e.g. a DCC specific platform can pull in the
439
-
requirements in a company or site specific platform. The expectation
440
-
is that a platform would only inherit from other platforms, but that
441
-
is not strictly required.
442
-
443
-
When a platform is built, it produces an ordinary v0/package just like
444
-
a "normal" v0/package spec would do, and it is treated like any other
445
-
package for use by downstream consumers. All its requirements will
446
-
always be `IfAlreadyPresent` ones.
447
-
448
-
An example platform spec:
449
-
450
-
```yaml
451
-
platform: company-platform
452
-
api: v1/platform
453
-
requirements:
454
-
- pkg: gcc
455
-
atBuild: =9.3.1
456
-
atRuntime: 9.3.1
457
-
- pkg: python
458
-
atBuild: =3.9.18
459
-
atRuntime: 3.9
460
-
- pkg: imath
461
-
atBuild: =3.0.1
462
-
atRuntime: 3
463
-
```
464
-
465
-
The `platform:` fields provides the name of the platform package. The
466
-
`api:`field indicates this is a platform spec.
467
-
468
-
The `requirements` field contains the list of requirements in the
469
-
platform. In each case, the requirement specifies the version request to be
470
-
used at build time vs at run time. This allows the platform to differently
471
-
constrain the requirement depending on if it's being used to define a build
472
-
environment or a runtime environment.
473
-
474
-
These requirements are placed onto the `build` and `run` components of the package
475
-
generated by this platform, respectively. The generated requirements will have
476
-
`include: IfAlreadyPresent` added to them automatically, it does not need to be
477
-
specified for them.
478
-
479
-
An example platform spec that inherits from the 'company-platform' and makes adjustments of its own:
480
-
481
-
```yaml
482
-
platform: dcc-platform
483
-
base:
484
-
- company-platform
485
-
api: v0/platform
486
-
requirements:
487
-
- pkg: python
488
-
atBuild: =3.7.10
489
-
atRuntime: 3.7
490
-
- pkg: imath
491
-
atBuild: false
492
-
atRuntime: false
493
-
```
494
-
495
-
The `base:` field indicates which platform this platform spec is based on (inherits the requirements from). In the case of multiple bases, each one simply overrides the previous in turn.
496
-
497
-
Any `atBuild` or `atRuntime` value that is specified in the platform spec will override the same value for the named requirement in the bases. Conversely, this also means that if a requirement omits either of the `atBuild` or `atRuntime` fields, then the value from the base will still remain.
498
-
499
-
The special `false` value can be used to remove the requirement entirely.
500
-
501
-
This is the complete specification of the same resulting `dcc-platform` without basing it on the `company-platform`:
502
-
503
-
```yaml
504
-
platform: dcc-platform
505
-
api: v0/platform
506
-
requirements:
507
-
- pkg: gcc
508
-
atBuild: =9.3.1
509
-
atRuntime: 9.3.1
510
-
- pkg: python
511
-
atBuild: =3.7.10
512
-
atRuntime: 3.7
513
-
# - pkg: imath not present
514
-
```
515
-
516
421
### Testing
517
422
518
423
Tests can also be defined in the package spec file. SPK currently supports three types of tests that validate different aspects of the package. Tests are defined by a bash script and _stage_.
0 commit comments