From a04cc4470e20a9b8b72c914229d67d2eaaf49b82 Mon Sep 17 00:00:00 2001 From: "Seth R. Johnson" Date: Fri, 12 Nov 2021 11:58:44 -0500 Subject: Add PyPI docs and warning in auto-generated package (#27404) * docs: Add cross-references for pypi setup * create: add warning for missing pypi --- lib/spack/docs/build_systems/pythonpackage.rst | 13 ++++++++++--- lib/spack/spack/cmd/create.py | 6 ++++++ 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/spack/docs/build_systems/pythonpackage.rst b/lib/spack/docs/build_systems/pythonpackage.rst index 30875d15f3..365c5d7bce 100644 --- a/lib/spack/docs/build_systems/pythonpackage.rst +++ b/lib/spack/docs/build_systems/pythonpackage.rst @@ -125,12 +125,15 @@ The zip file will not contain a ``setup.py``, but it will contain a ``METADATA`` file which contains all the information you need to write a ``package.py`` build recipe. +.. _pypi: + ^^^^ PyPI ^^^^ -The vast majority of Python packages are hosted on PyPI - The Python -Package Index. ``pip`` only supports packages hosted on PyPI, making +The vast majority of Python packages are hosted on PyPI (The Python +Package Index), which is :ref:`preferred over GitHub ` +for downloading packages. ``pip`` only supports packages hosted on PyPI, making it the only option for developers who want a simple installation. Search for "PyPI " to find the download page. Note that some pages are versioned, and the first result may not be the newest @@ -217,6 +220,7 @@ try to extract the wheel: version('1.11.0', sha256='d8c9d24ea90457214d798b0d922489863dad518adde3638e08ef62de28fb183a', expand=False) +.. _pypi-vs-github: """"""""""""""" PyPI vs. GitHub @@ -263,6 +267,9 @@ location, but PyPI is preferred for the following reasons: PyPI is nice because it makes it physically impossible to re-release the same version of a package with a different checksum. +Use the :ref:`pypi attribute ` to facilitate construction of PyPI package +references. + ^^^^^^^^^^^^^^^^^^^^^^^^^ Build system dependencies ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -709,7 +716,7 @@ The package may have its own unit or regression tests. Spack can run these tests during the installation by adding phase-appropriate test methods. -For example, ``py-numpy`` adds the following as a check to run +For example, ``py-numpy`` adds the following as a check to run after the ``install`` phase: .. code-block:: python diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py index bccf3bf66d..baeccc513e 100644 --- a/lib/spack/spack/cmd/create.py +++ b/lib/spack/spack/cmd/create.py @@ -316,6 +316,12 @@ class PythonPackageTemplate(PackageTemplate): url = '/'.join([project, match.group(4)]) self.url_line = ' pypi = "{url}"' + else: + # Add a reminder about spack preferring PyPI URLs + self.url_line = ''' + # FIXME: ensure the package is not available through PyPI. If it is, + # re-run `spack create --force` with the PyPI URL. +''' + self.url_line super(PythonPackageTemplate, self).__init__(name, url, *args, **kwargs) -- cgit v1.2.3-70-g09d2