summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin.mock/packages/licenses-1/package.py
diff options
context:
space:
mode:
authorAiden Grossman <agrossman154@yahoo.com>2023-10-18 03:58:19 -0700
committerGitHub <noreply@github.com>2023-10-18 03:58:19 -0700
commit2802013dc669c503041931f3f9d8a5a251d5e12e (patch)
treeb9a8cd2db1a2d2cfd177822804ca8cf6b6552b74 /var/spack/repos/builtin.mock/packages/licenses-1/package.py
parent37bafce38476e0b3043bb32b965c647cde07a887 (diff)
downloadspack-2802013dc669c503041931f3f9d8a5a251d5e12e.tar.gz
spack-2802013dc669c503041931f3f9d8a5a251d5e12e.tar.bz2
spack-2802013dc669c503041931f3f9d8a5a251d5e12e.tar.xz
spack-2802013dc669c503041931f3f9d8a5a251d5e12e.zip
Add license directive (#39346)
This patch adds in a license directive to get the ball rolling on adding in license information about packages to spack. I'm primarily interested in just adding license into spack, but this would also help with other efforts that people are interested in such as adding license information to the ASP solve for concretization to make sure licenses are compatible. Usage: Specifying the specific license that a package is released under in a project's `package.py` is good practice. To specify a license, find the SPDX identifier for a project and then add it using the license directive: ```python license("<SPDX Identifier HERE>") ``` For example, for Apache 2.0, you might write: ```python license("Apache-2.0") ``` Note that specifying a license without a when clause makes it apply to all versions and variants of the package, which might not actually be the case. For example, a project might have switched licenses at some point or have certain build configurations that include files that are licensed differently. To account for this, you can specify when licenses should be applied. For example, to specify that a specific license identifier should only apply to versionup to and including 1.5, you could write the following directive: ```python license("MIT", when="@:1.5") ```
Diffstat (limited to 'var/spack/repos/builtin.mock/packages/licenses-1/package.py')
-rw-r--r--var/spack/repos/builtin.mock/packages/licenses-1/package.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/var/spack/repos/builtin.mock/packages/licenses-1/package.py b/var/spack/repos/builtin.mock/packages/licenses-1/package.py
new file mode 100644
index 0000000000..d5c67830c9
--- /dev/null
+++ b/var/spack/repos/builtin.mock/packages/licenses-1/package.py
@@ -0,0 +1,18 @@
+# Copyright 2013-2023 Lawrence Livermore National Security, LLC and other
+# Spack Project Developers. See the top-level COPYRIGHT file for details.
+#
+# SPDX-License-Identifier: (Apache-2.0 OR MIT)
+
+from spack.package import *
+
+
+class Licenses1(Package):
+ """Package with a licenses field."""
+
+ homepage = "https://www.example.com"
+ url = "https://www.example.com/license"
+
+ license("MIT", when="+foo")
+ license("Apache-2.0", when="~foo")
+
+ version("1.0", md5="0123456789abcdef0123456789abcdef")