Skip to content

Commit

Permalink
Update scripts for rename of build/pkgs/*/install-requires.txt to ver…
Browse files Browse the repository at this point in the history
…sion_requirements.txt
  • Loading branch information
Matthias Koeppe committed Feb 2, 2024
1 parent 0c390a0 commit 3e7e406
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ ptestoptionallong-nodoc:

###############################################################################

configure: bootstrap src/doc/bootstrap configure.ac src/bin/sage-version.sh m4/*.m4 build/pkgs/*/spkg-configure.m4 build/pkgs/*/type build/pkgs/*/install-requires.txt build/pkgs/*/package-version.txt build/pkgs/*/distros/*.txt
configure: bootstrap src/doc/bootstrap configure.ac src/bin/sage-version.sh m4/*.m4 build/pkgs/*/spkg-configure.m4 build/pkgs/*/type build/pkgs/*/version_requirements.txt build/pkgs/*/package-version.txt build/pkgs/*/distros/*.txt
./bootstrap -d

install: all
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 @@ -72,7 +72,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
4 changes: 2 additions & 2 deletions build/sage_bootstrap/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,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 @@ -205,7 +205,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 @@ -85,9 +85,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 @@ -99,10 +99,10 @@ 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))
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))
elif source == 'pip':
with open(os.path.join(self.path, 'requirements.txt'), 'w+') as f:
Expand Down
14 changes: 7 additions & 7 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 @@ -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 @@ -493,12 +493,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
12 changes: 6 additions & 6 deletions src/doc/en/developer/packaging.rst
Original file line number Diff line number Diff line change
Expand Up @@ -599,10 +599,10 @@ For example, the ``scipy`` ``spkg-check.in`` file contains the line
exec python3 spkg-check.py
All normal Python packages and all wheel packages must have a file ``install-requires.txt``.
All normal Python packages and all wheel packages must have a file ``version_requirements.txt``.
If a Python package is available on PyPI, this 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 @@ -619,15 +619,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 @@ -795,7 +795,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 @@ -1111,7 +1111,7 @@ obtains most of the necessary information by querying PyPI.
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``.
in the file ``version_requirements.txt``.
By default, when the package is available as a platform-independent
wheel, the ``sage --package`` creates a wheel package. To create a normal package
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 3e7e406

Please sign in to comment.