Skip to content

Commit

Permalink
sagemathgh-36999: Rename install-requires.txt to `version_requireme…
Browse files Browse the repository at this point in the history
…nts.txt`

    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

As discussed in sagemath#36982:
- the name "install-requires"  has become outdated with the transition
to the new names set by the `pyproject.toml` format (see https://setupto
ols.pypa.io/en/latest/userguide/dependency_management.html#declaring-
required-dependency, compare the tabs "pyproject.toml" vs. "setup.cfg")
- this will help with sagemath#35890, as
GitHub will be able to just read the `version_requirements.txt` files

sagemath#36982 (comment)

Notes for reviewers:
- **This is a simple, limited-scope improvement and not intended as a
long-term commitment to the format of the files in build/pkgs/....**
- PRs sagemath#37430, sagemath#37350, sagemath#36740 remove direct access to build/pkgs in favor
of using the sage_bootstrap API (sage --package).

<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes sagemath#12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [x] The description explains in detail what this PR is about.
- [x] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- sagemath#12345: short description why this is a dependency
- sagemath#34567: ...
-->
- Depends on sagemath#37401

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: sagemath#36999
Reported by: Matthias Köppe
Reviewer(s): Dima Pasechnik, Kwankyu Lee, Nathan Dunfield
  • Loading branch information
Release Manager committed Apr 7, 2024
2 parents 071499f + 918448a commit 2f5d9f1
Show file tree
Hide file tree
Showing 247 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,15 @@ CONFIGURE_DEPENDENCIES = \
build/pkgs/*/spkg-configure.m4 \
build/pkgs/*/type build/pkgs/*/SPKG.rst \
build/pkgs/*/checksums.ini build/pkgs/*/requirements.txt \
build/pkgs/*/install-requires.txt build/pkgs/*/package-version.txt \
build/pkgs/*/version_requirements.txt build/pkgs/*/package-version.txt \
build/pkgs/*/spkg-install build/pkgs/*/spkg-install.in

# SPKG_INFO_DEPENDENCIES is the list of files that influence the run of 'sage-spkg-info' and hence
# the generation of the files generated in 'src/doc' by 'src/doc/bootstrap'.
SPKG_INFO_DEPENDENCIES = \
build/pkgs/*/type build/pkgs/*/SPKG.rst \
build/pkgs/*/requirements.txt \
build/pkgs/*/install-requires.txt build/pkgs/*/package-version.txt \
build/pkgs/*/version_requirements.txt build/pkgs/*/package-version.txt \
build/pkgs/*/distros/*.txt

configure: bootstrap src/doc/bootstrap $(CONFIGURE_DEPENDENCIES) $(SPKG_INFO_DEPENDENCIES)
Expand Down
2 changes: 1 addition & 1 deletion bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ EOF
SPKG_TREE_VAR="$(sed "s/#.*//;" "$DIR/trees.txt")"
else
SPKG_TREE_VAR=SAGE_LOCAL
if test -f "$DIR/requirements.txt" -o -f "$DIR/install-requires.txt"; then
if test -f "$DIR/requirements.txt" -o -f "$DIR/version_requirements.txt"; then
# A Python package
SPKG_TREE_VAR=SAGE_VENV
echo "define(>>>SPKG_INSTALL_REQUIRES_${pkgname}<<<, >>>$(echo $(sage-get-system-packages install-requires ${pkgname}))<<<)dnl" >> m4/sage_spkg_versions.m4
Expand Down
4 changes: 2 additions & 2 deletions bootstrap-conda
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ echo >&2 $0:$LINENO: generate conda environment files
(
echo >&4 " - pip:"
echo >&5 " - pip:"
for PKG_BASE in $(sage-package list :standard: :optional: --has-file requirements.txt --no-file distros/conda.txt --no-file src; sage-package list :standard: :optional: --has-file install-requires.txt --no-file requirements.txt --no-file distros/conda.txt --no-file src); do
for PKG_BASE in $(sage-package list :standard: :optional: --has-file requirements.txt --no-file distros/conda.txt --no-file src; sage-package list :standard: :optional: --has-file version_requirements.txt --no-file requirements.txt --no-file distros/conda.txt --no-file src); do
PKG_SCRIPTS=build/pkgs/$PKG_BASE
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/requirements.txt
if [ ! -f $SYSTEM_PACKAGES_FILE ]; then
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/install-requires.txt
SYSTEM_PACKAGES_FILE=$PKG_SCRIPTS/version_requirements.txt
fi
PKG_TYPE=$(cat $PKG_SCRIPTS/type)
if grep -q SAGERUNTIME $PKG_SCRIPTS/dependencies $PKG_SCRIPTS/dependencies_order_only 2>/dev/null; then
Expand Down
12 changes: 6 additions & 6 deletions build/bin/sage-get-system-packages
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ fi

case "$SYSTEM" in
install-requires)
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
# needed by setup.cfg [options] install_requires=
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt requirements.txt"
# Collect version_requirements.txt (falling back to requirements.txt) and output it in the format
# needed by setup.cfg [options] version_requirements=
SYSTEM_PACKAGES_FILE_NAMES="version_requirements.txt requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;"
COLLECT=
;;
install-requires-toml)
# Collect install-requires.txt (falling back to requirements.txt) and output it in the format
# Collect version_requirements.txt (falling back to requirements.txt) and output it in the format
# needed by pyproject.toml [build-system] requires=
SYSTEM_PACKAGES_FILE_NAMES="install-requires.txt requirements.txt"
SYSTEM_PACKAGES_FILE_NAMES="version_requirements.txt requirements.txt"
STRIP_COMMENTS="sed s/#.*//;/^[[:space:]]*$/d;s/^/'/;s/$/',/;"
COLLECT=
;;
pip)
SYSTEM_PACKAGES_FILE_NAMES="requirements.txt install-requires.txt"
SYSTEM_PACKAGES_FILE_NAMES="requirements.txt version_requirements.txt"
STRIP_COMMENTS='sed s/#.*//;s/[[:space:]]//g;'
COLLECT=echo
;;
Expand Down
2 changes: 1 addition & 1 deletion build/bin/sage-spkg-info
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ echo
echo "Version Information"
echo "-------------------"
echo
for a in package-version.txt requirements.txt install-requires.txt; do
for a in package-version.txt requirements.txt version_requirements.txt; do
if [ -f "$PKG_SCRIPTS"/"$a" ]; then
echo "$a::"
echo
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions build/sage_bootstrap/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def update_latest(self, package_name, commit=False):
pkg = Package(package_name)
dist_name = pkg.distribution_name
if dist_name is None:
log.debug('%s does not have Python distribution info in install-requires.txt' % pkg)
log.debug('%s does not have Python distribution info in version_requirements.txt' % pkg)
return
if pkg.tarball_pattern.endswith('.whl'):
source = 'wheel'
Expand All @@ -279,7 +279,7 @@ def update_latest_cls(self, package_name_or_class, commit=False):
'cypari' # Name conflict
]
# Restrict to normal Python packages
pc = PackageClass(package_name_or_class, has_files=['checksums.ini', 'install-requires.txt'])
pc = PackageClass(package_name_or_class, has_files=['checksums.ini', 'version_requirements.txt'])
if not pc.names:
log.warn('nothing to do (does not name a normal Python package)')
for package_name in sorted(pc.names):
Expand Down
8 changes: 4 additions & 4 deletions build/sage_bootstrap/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def set_python_data_and_scripts(self, pypi_package_name=None, source='normal'):
Write the file ``dependencies`` and other files for Python packages.
If ``source`` is ``"normal"``, write the files ``spkg-install.in`` and
``install-requires.txt``.
``version_requirements.txt``.
If ``source`` is ``"wheel"``, write the file ``install-requires.txt``.
If ``source`` is ``"wheel"``, write the file ``version_requirements.txt``.
If ``source`` is ``"pip"``, write the file ``requirements.txt``.
Expand All @@ -126,12 +126,12 @@ def set_python_data_and_scripts(self, pypi_package_name=None, source='normal'):
if source == 'normal':
with open(os.path.join(self.path, 'spkg-install.in'), 'w+') as f:
f.write('cd src\nsdh_pip_install .\n')
with open(os.path.join(self.path, 'install-requires.txt'), 'w+') as f:
with open(os.path.join(self.path, 'version_requirements.txt'), 'w+') as f:
f.write('{0}\n'.format(pypi_package_name))
# Remove this file, which would mark the package as a pip package.
self._remove_files(['requirements.txt'])
elif source == 'wheel':
with open(os.path.join(self.path, 'install-requires.txt'), 'w+') as f:
with open(os.path.join(self.path, 'version_requirements.txt'), 'w+') as f:
f.write('{0}\n'.format(pypi_package_name))
# Remove this file, which would mark the package as a pip package.
self._remove_files(['requirements.txt'])
Expand Down
16 changes: 8 additions & 8 deletions build/sage_bootstrap/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, package_name):
self._init_checksum()
self._init_version()
self._init_type()
self._init_install_requires()
self._init_version_requirements()
self._init_dependencies()
self._init_trees()

Expand Down Expand Up @@ -344,7 +344,7 @@ def trees(self):
"""
if self.__trees is not None:
return self.__trees
if self.__install_requires is not None:
if self.__version_requirements is not None:
return 'SAGE_VENV'
if self.has_file('requirements.txt'):
return 'SAGE_VENV'
Expand All @@ -355,9 +355,9 @@ def distribution_name(self):
"""
Return the Python distribution name or ``None`` for non-Python packages
"""
if self.__install_requires is None:
if self.__version_requirements is None:
return None
for line in self.__install_requires.split('\n'):
for line in self.__version_requirements.split('\n'):
line = line.strip()
if line.startswith('#'):
continue
Expand Down Expand Up @@ -510,12 +510,12 @@ def _init_type(self):
]
self.__type = package_type

def _init_install_requires(self):
def _init_version_requirements(self):
try:
with open(os.path.join(self.path, 'install-requires.txt')) as f:
self.__install_requires = f.read().strip()
with open(os.path.join(self.path, 'version_requirements.txt')) as f:
self.__version_requirements = f.read().strip()
except IOError:
self.__install_requires = None
self.__version_requirements = None

def _init_dependencies(self):
try:
Expand Down
8 changes: 4 additions & 4 deletions m4/sage_python_package_check.m4
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Determine if the system copy of a python package can be used by sage.
#
# This macro uses setuptools.version's pkg_resources to check that the
# "install-requires.txt" file for the named package is satisfied, and
# "version_requirements.txt" file for the named package is satisfied, and
# it can typically fail in four ways:
#
# 1. If --enable-system-site-packages was not passed to ./configure,
Expand All @@ -19,7 +19,7 @@
#
# 4. If setuptools is not available to the system python,
#
# 5. If the contents of install-requires.txt are not met (wrong
# 5. If the contents of version_requirements.txt are not met (wrong
# version, no version, etc.) by the system python.
#
# In any of those cases, we set sage_spkg_install_$package to "yes"
Expand Down Expand Up @@ -56,7 +56,7 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
config.venv dnl
2>&AS_MESSAGE_LOG_FD], [
AC_MSG_RESULT(yes)
dnl strip all comments from install-requires.txt; this should leave
dnl strip all comments from version_requirements.txt; this should leave
dnl only a single line containing the version specification for this
dnl package. Afterwards, convert all double-quotes to single quotes.
dnl Both work, but only single quotes are documented. However, at the
Expand All @@ -67,7 +67,7 @@ AC_DEFUN([SAGE_PYTHON_PACKAGE_CHECK], [
SAGE_PKG_VERSPEC=$(sed \
-e '/^#/d' \
-e "s/\"/'/g" \
"./build/pkgs/$1/install-requires.txt"
"./build/pkgs/$1/version_requirements.txt"
)
AC_MSG_CHECKING([for python package $1 ("${SAGE_PKG_VERSPEC}")])
Expand Down
8 changes: 4 additions & 4 deletions src/bin/sage-update-version
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ for version_file in "$SAGE_ROOT"/pkgs/*/VERSION.txt; do
fi
done

# Update install-requires.txt for all distribution packages
# Update version_requirements.txt for all distribution packages
( cd "$SAGE_ROOT"/build/pkgs/ && for spkg in sage*; do
if [ -f "$spkg"/install-requires.txt -a -d "$spkg"/src ]; then
if [ -f "$spkg"/version_requirements.txt -a -d "$spkg"/src ]; then
( echo "# This file is updated on every release by the sage-update-version script"
# Normalize the package name to PyPI convention (dashes, not underscores)
if [ "$spkg" = sagelib ]; then
Expand All @@ -58,7 +58,7 @@ done
version=${version//.beta/b}
version=${version//.rc/rc}
# ~= asks for a compatible release. https://peps.python.org/pep-0440/#compatible-release
echo "$pkg ~= $version" ) > "$spkg"/install-requires.txt
echo "$pkg ~= $version" ) > "$spkg"/version_requirements.txt
fi
done )

Expand Down Expand Up @@ -121,7 +121,7 @@ git commit -m "Updated SageMath version to $SAGE_VERSION" -- \
"$SAGE_SRC/bin/sage-version.sh" \
"$SAGE_ROOT/build/pkgs/configure/checksums.ini" \
"$SAGE_ROOT/build/pkgs/configure/package-version.txt" \
"$SAGE_ROOT/build/pkgs/*/install-requires.txt" \
"$SAGE_ROOT/build/pkgs/*/version_requirements.txt" \
"$SAGE_ROOT"/pkgs/*/VERSION.txt \
"$SAGE_ROOT/.upstream.d/20-github.com-sagemath-sage-releases" \
|| die "Error committing to the repository."
Expand Down
20 changes: 10 additions & 10 deletions src/doc/en/developer/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -623,18 +623,18 @@ For example, the ``scipy`` ``spkg-check.in`` file contains the line
exec python3 spkg-check.py
Abstract requirements: The ``install-requires.txt`` file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Abstract requirements: The ``version_requirements.txt`` file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All ``normal`` Python packages and all ``wheel`` packages must have a file
``install-requires.txt``. For ``pip`` packages, the file is optional; if
``version_requirements.txt``. For ``pip`` packages, the file is optional; if
it is missing, the ``requirements.txt`` file is used instead.
If a Python package is available on PyPI, the ``install-requires.txt`` file must
If a Python package is available on PyPI, the ``version_requirements.txt`` file must
contain the name of the package as it is known to PyPI.
Optionally,
``install-requires.txt`` can encode version constraints (such as lower
``version_requirements.txt`` can encode version constraints (such as lower
and upper bounds). The constraints are in the format of the
``install_requires`` key of `setup.cfg
<https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html>`_
Expand All @@ -661,15 +661,15 @@ For example:
$ cat build/pkgs/sphinx/package-version.txt
3.1.2.p0
$ cat build/pkgs/sphinx/install-requires.txt
$ cat build/pkgs/sphinx/version_requirements.txt
# gentoo uses 3.2.1
sphinx >=3, <3.3
The comments may include links to GitHub Issues/PRs, as in the following example:
.. CODE-BLOCK:: bash
$ cat build/pkgs/packaging/install-requires.txt
$ cat build/pkgs/packaging/version_requirements.txt
packaging >=18.0
# Issue #30975: packaging 20.5 is known to work
# but we have to silence "DeprecationWarning: Creating a LegacyVersion"
Expand Down Expand Up @@ -933,7 +933,7 @@ Where packages are installed
The Sage distribution has the notion of several installation trees.
- ``$SAGE_VENV`` is the default installation tree for all Python packages, i.e.,
normal packages with an ``install-requires.txt``, wheel packages, and pip packages
normal packages with an ``version_requirements.txt``, wheel packages, and pip packages
with a ``requirements.txt``.
- ``$SAGE_LOCAL`` is the default installation tree for all non-Python packages.
Expand Down Expand Up @@ -1073,7 +1073,7 @@ The ``dependencies`` file may need editing (watch out for warnings regarding
``--no-deps`` that Sage issues during installation of the package!).
Also you may want to set lower and upper bounds for acceptable package versions
in the file ``install-requires.txt``. (Make sure that the version in
in the file ``version_requirements.txt``. (Make sure that the version in
``package-version.txt`` falls within this acceptable version range!)
By default, when the package is available as a platform-independent
Expand Down Expand Up @@ -1113,7 +1113,7 @@ For Python packages available from PyPI, there is another shortcut::
When preparing the update, check that any lower and upper bounds for
acceptable package versions that may be declared in the file
``install-requires.txt`` are still correct, and update them as needed.
``version_requirements.txt`` are still correct, and update them as needed.
The version in ``package-version.txt`` always needs to fall within the
version range!
Expand Down
2 changes: 1 addition & 1 deletion src/doc/en/developer/packaging_sage_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ Version constraints of dependencies
-----------------------------------

The version information for dependencies comes from the files
``build/pkgs/*/install-requires.txt`` and
``build/pkgs/*/version_requirements.txt`` and
``build/pkgs/*/package-version.txt``. We use the
`m4 <https://www.gnu.org/software/m4/manual/html_node/index.html>`_
macro processor to insert the version information in the generated files
Expand Down

0 comments on commit 2f5d9f1

Please sign in to comment.