Add PyPI docs and warning in auto-generated package (#27404)

* docs: Add cross-references for pypi setup

* create: add warning for missing pypi
This commit is contained in:
Seth R. Johnson 2021-11-12 11:58:44 -05:00 committed by GitHub
parent 407f68a67b
commit a04cc4470e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -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 ``METADATA`` file which contains all the information you need to
write a ``package.py`` build recipe. write a ``package.py`` build recipe.
.. _pypi:
^^^^ ^^^^
PyPI PyPI
^^^^ ^^^^
The vast majority of Python packages are hosted on PyPI - The Python The vast majority of Python packages are hosted on PyPI (The Python
Package Index. ``pip`` only supports packages hosted on PyPI, making Package Index), which is :ref:`preferred over GitHub <pypi-vs-github>`
for downloading packages. ``pip`` only supports packages hosted on PyPI, making
it the only option for developers who want a simple installation. it the only option for developers who want a simple installation.
Search for "PyPI <package-name>" to find the download page. Note that Search for "PyPI <package-name>" to find the download page. Note that
some pages are versioned, and the first result may not be the newest 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) version('1.11.0', sha256='d8c9d24ea90457214d798b0d922489863dad518adde3638e08ef62de28fb183a', expand=False)
.. _pypi-vs-github:
""""""""""""""" """""""""""""""
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 PyPI is nice because it makes it physically impossible to
re-release the same version of a package with a different checksum. re-release the same version of a package with a different checksum.
Use the :ref:`pypi attribute <pypi>` to facilitate construction of PyPI package
references.
^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^
Build system dependencies Build system dependencies
^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -316,6 +316,12 @@ def __init__(self, name, url, *args, **kwargs):
url = '/'.join([project, match.group(4)]) url = '/'.join([project, match.group(4)])
self.url_line = ' pypi = "{url}"' 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) super(PythonPackageTemplate, self).__init__(name, url, *args, **kwargs)