From 5bd1074afb79710c115fc64ce49f57c424235801 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Mon, 11 Jul 2022 16:23:28 -0700 Subject: py-hatchling: add new packages, document new build backend (#31512) * py-hatchling: add new package, document new build backend * Minor doc changes Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com> --- lib/spack/docs/build_systems/pythonpackage.rst | 33 ++++++++++++++++++++-- .../repos/builtin/packages/py-editables/package.py | 18 ++++++++++++ .../repos/builtin/packages/py-hatchling/package.py | 23 +++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 var/spack/repos/builtin/packages/py-editables/package.py create mode 100644 var/spack/repos/builtin/packages/py-hatchling/package.py diff --git a/lib/spack/docs/build_systems/pythonpackage.rst b/lib/spack/docs/build_systems/pythonpackage.rst index b246ed1445..de79324de1 100644 --- a/lib/spack/docs/build_systems/pythonpackage.rst +++ b/lib/spack/docs/build_systems/pythonpackage.rst @@ -48,8 +48,9 @@ important to understand. **build backend** Libraries used to define how to build a wheel. Examples include `setuptools `__, - `flit `_, and - `poetry `_. + `flit `_, + `poetry `_, and + `hatchling `_. ^^^^^^^^^^^ Downloading @@ -326,6 +327,33 @@ for specifying the version requirements. Note that ``~=`` works differently in poetry than in setuptools and flit for versions that start with a zero. +""""""""" +hatchling +""""""""" + +If the ``pyproject.toml`` lists ``hatchling.build`` as the +``build-backend``, it uses the hatchling build system. Look for +dependencies under the following keys: + +* ``requires-python`` + + This specifies the version of Python that is required + +* ``project.dependencies`` + + These packages are required for building and installation. You can + add them with ``type=('build', 'run')``. + +* ``project.optional-dependencies`` + + This section includes keys with lists of optional dependencies + needed to enable those features. You should add a variant that + optionally adds these dependencies. This variant should be ``False`` + by default. + +See https://hatch.pypa.io/latest/config/dependency/ for more +information. + """""" wheels """""" @@ -666,3 +694,4 @@ For more information on build backend tools, see: * setuptools: https://setuptools.pypa.io/ * flit: https://flit.readthedocs.io/ * poetry: https://python-poetry.org/ +* hatchling: https://hatch.pypa.io/latest/ diff --git a/var/spack/repos/builtin/packages/py-editables/package.py b/var/spack/repos/builtin/packages/py-editables/package.py new file mode 100644 index 0000000000..6fc80e07fd --- /dev/null +++ b/var/spack/repos/builtin/packages/py-editables/package.py @@ -0,0 +1,18 @@ +# Copyright 2013-2022 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 PyEditables(PythonPackage): + """A Python library for creating "editable wheels".""" + + homepage = "https://github.com/pfmoore/editables" + pypi = "editables/editables-0.3.tar.gz" + + version('0.3', sha256='167524e377358ed1f1374e61c268f0d7a4bf7dbd046c656f7b410cde16161b1a') + + depends_on('python@3.7:', type=('build', 'run')) + depends_on('py-setuptools@42:', type='build') diff --git a/var/spack/repos/builtin/packages/py-hatchling/package.py b/var/spack/repos/builtin/packages/py-hatchling/package.py new file mode 100644 index 0000000000..deada44946 --- /dev/null +++ b/var/spack/repos/builtin/packages/py-hatchling/package.py @@ -0,0 +1,23 @@ +# Copyright 2013-2022 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 PyHatchling(PythonPackage): + """Modern, extensible Python build backend.""" + + homepage = "https://hatch.pypa.io/latest/" + pypi = "hatchling/hatchling-1.4.1.tar.gz" + + version('1.4.1', sha256='13461b42876ade4f75ee5d2a2c656b288ca0aab7f048ef66657ef166996b2118') + + depends_on('python@3.7:', type=('build', 'run')) + depends_on('py-editables@0.3:', type=('build', 'run')) + depends_on('py-importlib-metadata', when='^python@:3.7', type=('build', 'run')) + depends_on('py-packaging@21.3:', type=('build', 'run')) + depends_on('py-pathspec@0.9:', type=('build', 'run')) + depends_on('py-pluggy@1:', type=('build', 'run')) + depends_on('py-tomli@1.2.2:', when='^python@:3.10', type=('build', 'run')) -- cgit v1.2.3-70-g09d2