Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 10cabc1

Browse files
committedMar 7, 2025·
Split the docs on platform into their own page
Signed-off-by: Ryan Bottriell <[email protected]>
1 parent 73f6942 commit 10cabc1

File tree

3 files changed

+99
-101
lines changed

3 files changed

+99
-101
lines changed
 

‎docs/ref/spec.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The root package spec defines which fields can and should exist at the top level
2727
| ----------- | -------------- | ---------------------------------------------------------------------- |
2828
| description | _str_ | (Optional) A concise, one sentence description of the package |
2929
| homepage | _str_ | (Optional) URL where the package lives |
30-
| license | _str_ | (Optional) Package license. If not specified, defaults to _Unlicensed_ |
30+
| license | _str_ | (Optional) Package license. If not specified, defaults to _Unlicensed_ |
3131
| labels | _Map[str,str]_ | (Optional) A storage for arbitrary key-value data |
3232

3333
## SourceSpec

‎docs/use/platforms.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Specifying Platforms
3+
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`:
81+
82+
```yaml
83+
api: v1/platform
84+
platform: dcc-platform
85+
requirements:
86+
- pkg: gcc
87+
atBuild: =9.3.1
88+
atRuntime: 9.3.1
89+
- pkg: python
90+
atBuild: =3.7.10
91+
atRuntime: 3.7
92+
# - pkg: imath not present
93+
```

‎docs/use/spec.md

+5-100
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ build:
203203

204204
The build script is bash code which builds your package. The script is responsible for installing your software into the `/spfs` directory.
205205

206-
spk assumes that your installed files will be layed out similarly to the unix standard filesystem hierarchy. Most build systems can be configured with a **prefix**-type argument like the cmake example above which will handle this for you. If you are create python code, spk works just like an python virtual environment, and your code can be pip-installed using the /spfs/bin/pip that is included in the spk python packages or by manually copying to the appropriate `/spfs/lib/python<version>/site-packages` folder.
206+
spk assumes that your installed files will be laid out similarly to the unix standard filesystem hierarchy. Most build systems can be configured with a **prefix**-type argument like the cmake example above which will handle this for you. If you are create python code, spk works just like an python virtual environment, and your code can be pip-installed using the /spfs/bin/pip that is included in the spk python packages or by manually copying to the appropriate `/spfs/lib/python<version>/site-packages` folder.
207207

208208
{{% notice tip %}}
209209
If your build script is getting long or feels obstructive in your spec file, you can also create a build.sh script in your source tree which will be run if no build script is specified.
@@ -257,6 +257,10 @@ The spk build system performs a number of validations against the package create
257257

258258
The install configuration specifies the environment that your package needs when it is installed or included in an spk environment.
259259

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+
260264
#### Environment Variables
261265

262266
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:
414418
- { var: abi, static: cp27m }
415419
```
416420

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-
516421
### Testing
517422

518423
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

Comments
 (0)
Please sign in to comment.