Skip to content

Commit 46db214

Browse files
committed
build systems stash
1 parent 187a295 commit 46db214

5 files changed

Lines changed: 130 additions & 79 deletions

File tree

tutorial/examples/Cmake/0.package.py

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
2-
# Spack Project Developers. See the top-level COPYRIGHT file for details.
1+
# Copyright Spack Project Developers. See COPYRIGHT file for details.
32
#
43
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
54

5+
# ----------------------------------------------------------------------------
6+
# If you submit this package back to Spack as a pull request,
7+
# please first remove this boilerplate and all FIXME comments.
68
#
79
# This is a template package file for Spack. We've put "FIXME"
810
# next to all the things you'll want to change. Once you've handled
@@ -15,23 +17,37 @@
1517
# spack edit callpath
1618
#
1719
# See the Spack documentation for more information on packaging.
18-
# If you submit this package back to Spack as a pull request,
19-
# please first remove this boilerplate and all FIXME comments.
20-
#
21-
from spack import *
20+
# ----------------------------------------------------------------------------
21+
22+
from spack.package import *
23+
from spack_repo.builtin.build_systems.cmake import CMakePackage
2224

2325

2426
class Callpath(CMakePackage):
2527
"""FIXME: Put a proper description of your package here."""
2628

2729
# FIXME: Add a proper url for your package's homepage here.
28-
homepage = "http://www.example.com"
29-
url = "https://github.com/llnl/callpath/archive/v1.0.1.tar.gz"
30+
homepage = "https://www.example.com"
31+
url = "https://github.com/llnl/callpath/archive/v1.0.3.tar.gz"
32+
33+
# FIXME: Add a list of GitHub accounts to
34+
# notify when the package is updated.
35+
# maintainers("github_user1", "github_user2")
36+
37+
# FIXME: Add the SPDX identifier of the project's license below.
38+
# See https://spdx.org/licenses/ for a list. Upon manually verifying
39+
# the license, set checked_by to your Github username.
40+
license("UNKNOWN", checked_by="github_user1")
41+
42+
version(
43+
"1.0.3",
44+
sha256="a7ddba34de8387a8cb2af9c46bf24e5d307fb196e6dd433707641219c8b4af3e",
45+
)
3046

31-
version('1.0.3', 'c89089b3f1c1ba47b09b8508a574294a')
47+
depends_on("cxx", type="build")
3248

3349
# FIXME: Add dependencies if required.
34-
# depends_on('foo')
50+
# depends_on("foo")
3551

3652
def cmake_args(self):
3753
# FIXME: Add arguments other than

tutorial/examples/Cmake/1.package.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
2-
# Spack Project Developers. See the top-level COPYRIGHT file for details.
1+
# Copyright Spack Project Developers. See COPYRIGHT file for details.
32
#
43
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
54

6-
from spack import *
5+
from spack.package import *
6+
from spack_repo.builtin.build_systems.cmake import CMakePackage
77

88

99
class Callpath(CMakePackage):
1010
"""Library for representing callpaths consistently in
11-
distributed-memory performance tools."""
11+
distributed-memory performance tools."""
1212

1313
homepage = "https://github.com/llnl/callpath"
14-
url = "https://github.com/llnl/callpath/archive/v1.0.3.tar.gz"
14+
url = "https://github.com/llnl/callpath/archive/v1.0.3.tar.gz"
1515

16-
version('1.0.3', 'c89089b3f1c1ba47b09b8508a574294a')
16+
version(
17+
"1.0.3",
18+
sha256="a7ddba34de8387a8cb2af9c46bf24e5d307fb196e6dd433707641219c8b4af3e",
19+
)
1720

21+
depends_on("cxx", type="build")
1822
depends_on("elf", type="link")
1923
depends_on("libdwarf")
2024
depends_on("dyninst")

tutorial/examples/Cmake/2.package.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
1-
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
2-
# Spack Project Developers. See the top-level COPYRIGHT file for details.
1+
# Copyright Spack Project Developers. See COPYRIGHT file for details.
32
#
43
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
54

6-
from spack import *
5+
from spack.package import *
6+
from spack_repo.builtin.build_systems.cmake import CMakePackage
77

88

99
class Callpath(CMakePackage):
1010
"""Library for representing callpaths consistently in
11-
distributed-memory performance tools."""
11+
distributed-memory performance tools."""
1212

1313
homepage = "https://github.com/llnl/callpath"
14-
url = "https://github.com/llnl/callpath/archive/v1.0.3.tar.gz"
14+
url = "https://github.com/llnl/callpath/archive/v1.0.3.tar.gz"
1515

16-
version('1.0.3', 'c89089b3f1c1ba47b09b8508a574294a')
16+
version(
17+
"1.0.3",
18+
sha256="a7ddba34de8387a8cb2af9c46bf24e5d307fb196e6dd433707641219c8b4af3e",
19+
)
1720

21+
depends_on("cxx", type="build")
1822
depends_on("elf", type="link")
1923
depends_on("libdwarf")
2024
depends_on("dyninst")
Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
2-
# Spack Project Developers. See the top-level COPYRIGHT file for details.
1+
# Copyright Spack Project Developers. See COPYRIGHT file for details.
32
#
43
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
54

5+
# ----------------------------------------------------------------------------
6+
# If you submit this package back to Spack as a pull request,
7+
# please first remove this boilerplate and all FIXME comments.
68
#
79
# This is a template package file for Spack. We've put "FIXME"
810
# next to all the things you'll want to change. Once you've handled
@@ -15,27 +17,54 @@
1517
# spack edit py-pandas
1618
#
1719
# See the Spack documentation for more information on packaging.
18-
# If you submit this package back to Spack as a pull request,
19-
# please first remove this boilerplate and all FIXME comments.
20-
#
21-
from spack import *
20+
# ----------------------------------------------------------------------------
21+
22+
from spack.package import *
23+
from spack_repo.builtin.build_systems.python import PythonPackage
2224

2325

2426
class PyPandas(PythonPackage):
2527
"""FIXME: Put a proper description of your package here."""
2628

2729
# FIXME: Add a proper url for your package's homepage here.
28-
homepage = "http://www.example.com"
29-
url = "https://pypi.io/packages/source/p/pandas/pandas-0.19.0.tar.gz"
30+
homepage = "https://www.example.com"
31+
pypi = "pandas/pandas-0.19.0.tar.gz"
32+
33+
# FIXME: Add a list of GitHub accounts to
34+
# notify when the package is updated.
35+
# maintainers("github_user1", "github_user2")
36+
37+
# FIXME: Add the SPDX identifier of the project's license below.
38+
# See https://spdx.org/licenses/ for a list. Upon manually verifying
39+
# the license, set checked_by to your Github username.
40+
license("UNKNOWN", checked_by="github_user1")
41+
42+
version(
43+
"2.2.3",
44+
sha256="4f18ba62b61d7e192368b84517265a99b4d7ee8912f8708660fb4a366cc82667",
45+
)
46+
47+
depends_on("c", type="build")
48+
49+
# FIXME: Only add the python/pip/wheel dependencies if you need specific versions
50+
# or need to change the dependency type. Generic python/pip/wheel dependencies are
51+
# added implicity by the PythonPackage base class.
52+
# depends_on("python@2.X:2.Y,3.Z:", type=("build", "run"))
53+
# depends_on("py-pip@X.Y:", type="build")
54+
# depends_on("py-wheel@X.Y:", type="build")
3055

31-
version('0.19.0', 'bc9bb7188e510b5d44fbdd249698a2c3')
56+
# FIXME: Add a build backend, usually defined in pyproject.toml. If no such file
57+
# exists, use setuptools.
58+
# depends_on("py-setuptools", type="build")
59+
# depends_on("py-hatchling", type="build")
60+
# depends_on("py-flit-core", type="build")
61+
# depends_on("py-poetry-core", type="build")
3262

33-
# FIXME: Add dependencies if required.
34-
# depends_on('py-setuptools', type='build')
35-
# depends_on('py-foo', type=('build', 'run'))
63+
# FIXME: Add additional dependencies if required.
64+
# depends_on("py-foo", type=("build", "run"))
3665

37-
def build_args(self, spec, prefix):
38-
# FIXME: Add arguments other than --prefix
39-
# FIXME: If not needed delete this function
40-
args = []
41-
return args
66+
def config_settings(self, spec, prefix):
67+
# FIXME: Add configuration settings to be passed to the build backend
68+
# FIXME: If not needed, delete this function
69+
settings = {}
70+
return settings

tutorial_buildsystems.rst

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ If we look inside, we see that ``CC`` and ``CXX`` point to our GNU compiler:
237237
238238
.. note::
239239
As usual make sure you have shell support activated with Spack:
240-
``source /path/to/spack/share/spack/setup-env.sh``
240+
``source /path/to/spack/share/spack/setup-env.sh``
241241

242242
.. code-block:: console
243243
@@ -496,21 +496,11 @@ Let's try to recreate callpath_:
496496
497497
$ spack create -f https://github.com/llnl/callpath/archive/v1.0.3.tar.gz
498498
==> This looks like a URL for callpath
499-
==> Found 4 versions of callpath:
500-
501-
1.0.3 https://github.com/LLNL/callpath/archive/v1.0.3.tar.gz
502-
1.0.2 https://github.com/LLNL/callpath/archive/v1.0.2.tar.gz
503-
1.0.1 https://github.com/LLNL/callpath/archive/v1.0.1.tar.gz
504-
1.0 https://github.com/LLNL/callpath/archive/v1.0.tar.gz
505-
506-
==> How many would you like to checksum? (default is 1, q to abort) 1
507-
==> Downloading...
508-
==> Fetching https://github.com/LLNL/callpath/archive/v1.0.3.tar.gz
509-
######################################################################## 100.0%
510-
==> Checksummed 1 version of callpath
499+
==> Fetching https://github.com/llnl/callpath/archive/v1.0.3.tar.gz
500+
[100%] 47.00 KB @ 916.6 KB/s
511501
==> This package looks like it uses the cmake build system
512502
==> Created template for callpath package
513-
==> Created package file: /Users/mamelara/spack/var/spack/repos/builtin/packages/callpath/package.py
503+
==> Created package file: /home/spack/spack/var/spack/repos/spack_repo/builtin/packages/callpath/package.py
514504
515505
516506
which then produces the following template:
@@ -524,7 +514,7 @@ Again we fill in the details:
524514
.. literalinclude:: tutorial/examples/Cmake/1.package.py
525515
:language: python
526516
:linenos:
527-
:emphasize-lines: 9,13,14,18,19,20,21,22,23
517+
:emphasize-lines: 9,13,14,22,23,24,25,26,27
528518

529519
As mentioned earlier, Spack's ``CMakePackage`` uses sensible defaults to reduce boilerplate and simplify writing package files for ``CMake``-based software.
530520

@@ -534,7 +524,7 @@ We can return these options from ``cmake_args()`` like so:
534524
.. literalinclude:: tutorial/examples/Cmake/2.package.py
535525
:language: python
536526
:linenos:
537-
:emphasize-lines: 26,30,31
527+
:emphasize-lines: 30,34
538528

539529
Now we can control our build options using ``cmake_args()``.
540530
If defaults are sufficient enough for the package, we can leave this method out.
@@ -596,22 +586,26 @@ We will write a package file for Pandas_:
596586

597587
.. code-block:: console
598588
599-
$ spack create -f https://pypi.io/packages/source/p/pandas/pandas-0.19.0.tar.gz
589+
$ spack create -t python -f https://pypi.io/packages/source/p/pandas/pandas-2.2.3.tar.gz
600590
==> This looks like a URL for pandas
601-
==> Warning: Spack was unable to fetch url list due to a certificate verification problem. You can try running spack -k, which will not check SSL certificates. Use this at your own risk.
602-
==> Found 1 version of pandas:
603-
604-
0.19.0 https://pypi.io/packages/source/p/pandas/pandas-0.19.0.tar.gz
605-
606-
==> How many would you like to checksum? (default is 1, q to abort) 1
607-
==> Downloading...
608-
==> Fetching https://pypi.io/packages/source/p/pandas/pandas-0.19.0.tar.gz
609-
######################################################################## 100.0%
610-
==> Checksummed 1 version of pandas
611-
==> This package looks like it uses the python build system
591+
==> Selected 110 versions
592+
...
593+
594+
==> Enter number of versions to take, or use a command:
595+
[c]hecksum [e]dit [f]ilter [a]sk each [n]ew only [r]estart [q]uit
596+
action> 1
597+
==> Selected 1 of 110 versions
598+
2.2.3 https://files.pythonhosted.org/packages/9c/d6/9f8431bacc2e19dca897724cd097b1bb224a6ad5433784a44b587c7c13af/pandas-2.2.3.tar.gz#sha256=4f18ba62b61d7e192368b84517265a99b4d7ee8912f8708660fb4a366cc82667
599+
600+
==> Enter number of versions to take, or use a command:
601+
[c]hecksum [e]dit [f]ilter [a]sk each [n]ew only [r]estart [q]uit
602+
action> c
603+
==> Fetching https://files.pythonhosted.org/packages/9c/d6/9f8431bacc2e19dca897724cd097b1bb224a6ad5433784a44b587c7c13af/pandas-2.2.3.tar.gz#sha256=4f18ba62b61d7e192368b84517265a99b4d7ee8912f8708660fb4a366cc82667
604+
[100%] 4.40 MB @ 99.6 MB/s
605+
==> Using specified package template: 'python'
612606
==> Changing package name from pandas to py-pandas
613607
==> Created template for py-pandas package
614-
==> Created package file: /Users/mamelara/spack/var/spack/repos/builtin/packages/py-pandas/package.py
608+
==> Created package file: /home/spack/spack/var/spack/repos/spack_repo/builtin/packages/py_pandas/package.py
615609
616610
And we are left with the following template:
617611

@@ -671,18 +665,22 @@ From this example, you can see that building Python modules is made easy through
671665
Other Build Systems
672666
-------------------
673667

674-
Although we won't get in depth with any of the other build systems that Spack supports, it is worth mentioning that Spack does provide subclasses for the following build systems:
668+
While we won't go in depth on the other build systems that Spack supports, it's worth noting that Spack provides support for many specialized build systems beyond the ones covered in this tutorial.
669+
670+
Some examples include:
671+
672+
1. `RPackage <https://spack.readthedocs.io/en/latest/build_systems/rpackage.html>`_
673+
2. `MesonPackage <https://spack.readthedocs.io/en/latest/build_systems/mesonpackage.html>`_
674+
3. `PerlPackage <https://spack.readthedocs.io/en/latest/build_systems/perlpackage.html>`_
675+
4. `CUDAPackage <https://spack.readthedocs.io/en/latest/build_systems/cudapackage.html>`_
676+
5. `ROCmPackage <https://spack.readthedocs.io/en/latest/build_systems/rocmpackage.html>`_
675677

676-
1. ``IntelPackage``
677-
2. ``SconsPackage``
678-
3. ``WafPackage``
679-
4. ``RPackage``
680-
5. ``PerlPackage``
681-
6. ``QMakePackage``
678+
...and `many more <https://spack.readthedocs.io/en/latest/build_systems.html>`_!
682679

680+
Each of these build system classes provides abstractions to simplify and standardize the process of writing package recipes.
681+
They help manage common build logic and reduce duplication across packages in the same ecosystem.
683682

684-
Each of these classes have their own abstractions to help assist in writing package files.
685-
For whatever doesn't fit nicely into the other build systems, you can use the ``Package`` class.
683+
For packages that don't align well with any specific build system, Spack also provides a generic ``Package`` base class that gives full control over the build process.
686684

687-
Hopefully by now you can see how we aim to make packaging simple and robust through these classes.
688-
If you want to learn more about these build systems, check out `Implementing the installation procedure <https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure>`_ in the Packaging Guide.
685+
By now, you've seen how Spack aims to make packaging both simple and robust through its build system abstractions.
686+
To learn more, refer to the `Overview of the installation procedure <https://spack.readthedocs.io/en/latest/packaging_guide.html#installation-procedure>`_ in the Packaging Guide.

0 commit comments

Comments
 (0)