Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
first tentative of allowing a legacy version of packages
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Jul 17, 2019
1 parent 95ea5f3 commit ecb7133
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
9 changes: 8 additions & 1 deletion build/bin/sage-spkg
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,14 @@ elif [ -z "$PKG_HAS_PATH" ]; then
PKG_VER="${PKG_NAME#${PKG_BASE}}"
PKG_VER="${PKG_VER#-}"
PKG_SCRIPTS="$SAGE_ROOT/build/pkgs/$PKG_BASE"
LOCAL_PKG_VER=`cat $PKG_SCRIPTS/package-version.txt 2>/dev/null`
if [ "$SAGE_PYTHON3" = yes ]; then
LOCAL_PKG_VER=`cat $PKG_SCRIPTS/package-version.txt 2>/dev/null`
else
LOCAL_PKG_VER=`cat $PKG_SCRIPTS/package-version-legacy.txt 2>/dev/null`
if ! [ -f "$LOCAL_PKG_VER" ]; then
LOCAL_PKG_VER=`cat $PKG_SCRIPTS/package-version.txt 2>/dev/null`
fi
fi
if [ -n "$LOCAL_PKG_VER" ] && [ -z "$PKG_VER" -o "$PKG_VER" = "$LOCAL_PKG_VER" ]; then
PKG_VER="$LOCAL_PKG_VER"
if [ -z "$PKG_VER" ]; then
Expand Down
18 changes: 14 additions & 4 deletions build/sage_bootstrap/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************
import six

import re
import os
Expand Down Expand Up @@ -216,7 +217,12 @@ def _init_checksum(self):
"""
Load the checksums from the appropriate ``checksums.ini`` file
"""
checksums_ini = os.path.join(self.path, 'checksums.ini')
if six.PY2:
checksums_ini = os.path.join(self.path, 'checksums-legacy.ini')
if not os.path.isfile(checksums_ini):
checksums_ini = os.path.join(self.path, 'checksums.ini')
else:
checksums_ini = os.path.join(self.path, 'checksums.ini')
assignment = re.compile('(?P<var>[a-zA-Z0-9]*)=(?P<value>.*)')
result = dict()
with open(checksums_ini, 'rt') as f:
Expand All @@ -236,7 +242,13 @@ def _init_checksum(self):
VERSION_PATCHLEVEL = re.compile('(?P<version>.*)\.p(?P<patchlevel>[0-9]+)')

def _init_version(self):
with open(os.path.join(self.path, 'package-version.txt')) as f:
if six.PY2:
pkg_version = os.path.join(self.path, 'package-version-legacy.txt')
if not os.path.isfile(package_version):
pkg_version = os.path.join(self.path, 'package-version.txt')
else:
pkg_version = os.path.join(self.path, 'package-version.txt')
with open(pkg_version) as f:
package_version = f.read().strip()
match = self.VERSION_PATCHLEVEL.match(package_version)
if match is None:
Expand All @@ -245,5 +257,3 @@ def _init_version(self):
else:
self.__version = match.group('version')
self.__patchlevel = int(match.group('patchlevel'))


8 changes: 7 additions & 1 deletion src/sage/misc/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import print_function
import six

import sage.env

Expand Down Expand Up @@ -257,9 +258,14 @@ def list_packages(*pkg_types, **opts):
else:
pkg['remote_version'] = None
else:
package_filename = os.path.join(SAGE_PKGS, p, "package-version.txt")
if six.PY2:
package_filename_legacy = os.path.join(SAGE_PKGS, p, "package-version-legacy.txt")
if os.path.isfile(package_filename_legacy):
package_filename = package_filename_legacy

# If package-version.txt does not exist, that is an error
# in the build system => we just propagate the exception
package_filename = os.path.join(SAGE_PKGS, p, "package-version.txt")
with open(package_filename) as f:
pkg['remote_version'] = f.read().strip()
pkg['installed_version'] = installed.get(p)
Expand Down

0 comments on commit ecb7133

Please sign in to comment.