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

Commit

Permalink
trac 22582: fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpalmieri committed Apr 17, 2017
2 parents fb90d5e + 10374c1 commit dc46ea2
Show file tree
Hide file tree
Showing 19 changed files with 160 additions and 78 deletions.
33 changes: 25 additions & 8 deletions build/bin/sage-pip-install
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,18 @@ if [ "$1" != "." ]; then
exit 1
fi


if [ "$SAGE_PYTHON3" = yes ]; then
PYTHON=python3
PIP=pip3
else
PYTHON=python2
PIP=pip2
fi


# Find out the name of the package that we are installing
name="$(python setup.py --name)"
name="$($PYTHON setup.py --name)"

if [ $? -ne 0 ]; then
echo >&2 "Error: could not determine package name"
Expand All @@ -46,29 +56,36 @@ if [ $(echo "$name" | wc -l) -gt 1 ]; then
echo >&2 "line as the package name: $name"
fi

# We should avoid running pip while uninstalling a package because that

# We should avoid running pip2/3 while uninstalling a package because that
# is prone to race conditions. Therefore, we use a lockfile while
# running pip. This is implemented in the Python script pip-lock.
# running pip. This is implemented in the Python script pip2/3-lock.

# Keep uninstalling as long as it succeeds
while true; do
out=$(pip-lock uninstall --disable-pip-version-check -y "$name" 2>&1)
out=$($PIP-lock uninstall --disable-pip-version-check -y "$name" 2>&1)
if [ $? -ne 0 ]; then
break
fi
echo "$out"
done

# Not ideal, but this is the easiest way to check if the package
# was not installed to begin with (which pip treats as an error).
# was not installed to begin with (which pip2/3 treats as an error).
# If it wasn't, then we proceed quietly; if it was installed show the
# uninstallation output and error out.
if [[ "$out" != *"not installed" ]]; then
echo >&2 "$out"
exit 1
fi

# Finally actually do the installation (the "SHARED" tells pip-lock
# Finally actually do the installation (the "SHARED" tells pip2/3-lock
# to apply a shared lock)
echo "Installing package $name using pip"
exec pip-lock SHARED install $pip_install_flags .
echo "Installing package $name using $PIP"

$PIP-lock SHARED install $pip_install_flags .
if [ $? -ne 0 ]; then
echo >&2 "Error: installing with $PIP failed"
exit 3
fi

21 changes: 21 additions & 0 deletions build/bin/sage-python
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash


# Run the Python interpreter that we are currently building Sage with
#
# An existing Python is a build-time dependency for Sage, but
# sometimes packages need to specifically run the one in Sage and not
# just any Python interpreter.
#
# This is similar to the sage-pip-install script, which you should be
# using for installing Python packages if at all possible.


if [ "$SAGE_PYTHON3" = yes ]; then
PYTHON="$SAGE_LOCAL/bin/python3"
else
PYTHON="$SAGE_LOCAL/bin/python2"
fi


exec $PYTHON "$@"
7 changes: 5 additions & 2 deletions build/pkgs/matplotlib/make-setup-config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from six.moves import configparser as ConfigParser
try:
from configparser import SafeConfigParser # Python 3
except ImportError:
from ConfigParser import SafeConfigParser # Python 2
import os

config = ConfigParser.SafeConfigParser()
config = SafeConfigParser()

config.add_section('directories')
config.set('directories', 'basedirlist', os.environ['SAGE_LOCAL'])
Expand Down
6 changes: 0 additions & 6 deletions build/pkgs/matplotlib/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@ if [ $? -ne 0 ]; then
echo "Error installing matplotlib package."
exit 1
fi

# Print value of MPLCONFIGDIR
VERSION=`python -c 'import pkg_resources; print(pkg_resources.get_distribution("matplotlib").version)'`
echo
echo "When Sage runs, MPLCONFIGDIR will be set to '\$DOT_SAGE/matplotlib-$VERSION'."
echo
6 changes: 3 additions & 3 deletions build/pkgs/numpy/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tarball=numpy-VERSION.tar.gz
sha1=5fbfde55b1d4b07cc449b10395472ffa41ec00c1
md5=2f44a895a8104ffac140c3a70edbd450
cksum=4092335543
sha1=8eb0e29bf93c2f283d7691587b6322686d5baf0d
md5=2abe6efb8ea0ac1716d1fc5fa90cbacf
cksum=1617766273
2 changes: 1 addition & 1 deletion build/pkgs/numpy/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.1.p0
1.12.1
28 changes: 0 additions & 28 deletions build/pkgs/numpy/patches/numpy-1.10.1-asarray_conversion.patch

This file was deleted.

6 changes: 3 additions & 3 deletions build/pkgs/numpy/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ else
export LDFLAGS="${LDFLAGS} -shared"
fi

python ../lapack_conf.py
sage-python ../lapack_conf.py

# Make sure that the fortran objects are compiled with -fPIC
export FFLAGS="$FFLAGS -fPIC"
Expand All @@ -44,7 +44,7 @@ export NUMPY_FCONFIG="config_fc --noopt --noarch"

rm -rf "$SAGE_LOCAL/lib/python*/site-packages/numpy"

python setup.py \
sage-python setup.py \
--no-user-cfg \
install \
--single-version-externally-managed \
Expand All @@ -54,7 +54,7 @@ python setup.py \
# Touch all includes such that dependency checking works properly:
# the timestamp of the includes should be *now*, not the time when
# the numpy package was created.
python <<EOF
sage-python <<EOF
import os
os.chdir(os.environ["SAGE_ROOT"]) # Import numpy from safe location
import numpy
Expand Down
8 changes: 5 additions & 3 deletions build/pkgs/pillow/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ fi
cd src

# Delete old version
site_packages="$SAGE_LOCAL/lib/python*/site-packages"
rm -rf "$site_packages"/PIL "$site_packages"/PIL-*.egg* "$site_packages"/Pillow-*.egg*
rm -rf \
"$SAGE_LOCAL"/lib/python*/site-packages/PIL \
"$SAGE_LOCAL"/lib/python*/site-packages/PIL-*.egg* \
"$SAGE_LOCAL"/lib/python*/site-packages/Pillow-*.egg*

# Note: Avoid shared libraries inside egg files, Trac #19467
python setup.py \
sage-python setup.py \
--no-user-cfg \
build_ext \
--disable-jpeg \
Expand Down
2 changes: 1 addition & 1 deletion build/pkgs/pip/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(PYTHON) setuptools
python2 python3 setuptools

----------
All lines of this file are ignored except the first.
Expand Down
20 changes: 17 additions & 3 deletions build/pkgs/pip/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
cd src

# pip can install itself!
# need to use --upgrade or else pip, which is importing itself, will think
# itself is already installed
python -m pip install --verbose --no-index --upgrade --isolated .
#
# need to use --upgrade or --ignore-installed; Otherwise pip, which is
# importing itself, will think itself is already installed
#
# Install pip3 first so pip2 overwrites local/bin/pip

python3 -m pip install --verbose --no-index --ignore-installed --isolated .
if [ $? -ne 0 ]; then
echo "Error building / installing pip3"
exit 1
fi

python2 -m pip install --verbose --no-index --ignore-installed --isolated .
if [ $? -ne 0 ]; then
echo "Error building / installing pip2"
exit 1
fi
3 changes: 1 addition & 2 deletions build/pkgs/python2/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,13 @@ rm -f "$SAGE_LOCAL/lib/python"

build

PYTHON_VERSION=$("$SAGE_LOCAL/bin/python2" -c 'import sys; print("%d.%d" % sys.version_info[:2])')

# On OS X with XCode 4, the presence of
# $SAGE_LOCAL/lib/python2.*/config/libpython2.x.a causes problems with
# GiNaC -- see #11967. It is easiest to test the version of OS X; we
# delete this file if using OS X 10.6 or later (so `uname -r` returns
# x.y.z with x >= 10).
if [ "$UNAME" = "Darwin" ] && \
PYTHON_VERSION=$("$SAGE_LOCAL/bin/python2" -c 'import sys; print("%d.%d" % sys.version_info[:2])')
[ `uname -r | cut '-d.' -f1` -gt 9 ]; then
rm -f "$SAGE_LOCAL/lib/python$PYTHON_VERSION/config/libpython${PYTHON_VERSION}.a"
elif [ "$UNAME" = "CYGWIN" ]; then
Expand Down
6 changes: 5 additions & 1 deletion build/pkgs/python3/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
zlib readline sqlite libpng | bzip2
zlib readline sqlite libpng | bzip2 python2


Note: depends on python2 so the python -> python2 symlink is created
first. Python 3 will not overwrite that symlink if it already exists.

----------
All lines of this file are ignored except the first.
Expand Down
10 changes: 0 additions & 10 deletions build/pkgs/python3/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,6 @@ rm -f "$SAGE_LOCAL/lib/python"

build

# Make symbolic link (after removing old link first)
if [ "$SAGE_PYTHON3" = yes ]; then
rm -f "$SAGE_LOCAL/bin/python"
ln -s python3 "$SAGE_LOCAL/bin/python"
if [ $? -ne 0 ]; then
echo >&2 "Error creating symbolic link"
exit 1
fi
fi

PYTHON_VERSION=$("$SAGE_LOCAL/bin/python3" -c 'import sys; print("%d.%d" % sys.version_info[:2])')

# On OS X with XCode 4, the presence of
Expand Down
2 changes: 1 addition & 1 deletion build/pkgs/setuptools/dependencies
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(PYTHON)
python2 python3

----------
All lines of this file are ignored except the first.
Expand Down
12 changes: 11 additions & 1 deletion build/pkgs/setuptools/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,14 @@ export PYTHON_EGG_CACHE="$DOT_SAGE/.python-eggs"
cd src

# Prevent setuptools from installing itself with easy_install
python setup.py --no-user-cfg install --single-version-externally-managed --record=/dev/null
python2 setup.py --no-user-cfg install --single-version-externally-managed --record=/dev/null
if [ $? -ne 0 ]; then
echo "Error Python 2 building / installing setuptools"
exit 1
fi

python3 setup.py --no-user-cfg install --single-version-externally-managed --record=/dev/null
if [ $? -ne 0 ]; then
echo "Error Python 3 building / installing setuptools"
exit 1
fi
2 changes: 1 addition & 1 deletion build/pkgs/sphinx/spkg-install
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ echo

cd "$CUR"
echo "Creating grammar pickle..."
python create_grammar_pickle.py
sage-python create_grammar_pickle.py
success 'Error creating the grammar pickle'
echo
8 changes: 4 additions & 4 deletions src/bin/pip-lock → src/bin/pip2-lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python2

# We should avoid running pip while uninstalling a package because that
# is prone to race conditions. This script runs pip under a lock.
Expand All @@ -18,7 +18,7 @@ locktype = fcntl.LOCK_EX
if len(sys.argv) >= 1 and sys.argv[1] == "SHARED":
sys.argv.pop(1)
locktype = fcntl.LOCK_SH
sys.argv[0] = "pip"
sys.argv[0] = "pip2"


# Open lockfile and lock it
Expand All @@ -29,7 +29,7 @@ except OSError:
if not os.path.isdir(lockdir):
raise

lockfile = os.path.join(lockdir, "pip.lock")
lockfile = os.path.join(lockdir, "pip2.lock")
lock = open(lockfile, "w+")

# First try a non-blocking lock such that we can give an informative
Expand All @@ -52,5 +52,5 @@ except IOError:
# Note that the import of pkg_resources must happen under the lock!
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('pip', 'console_scripts', 'pip')()
load_entry_point('pip', 'console_scripts', 'pip2')()
)
56 changes: 56 additions & 0 deletions src/bin/pip3-lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env python3

# We should avoid running pip while uninstalling a package because that
# is prone to race conditions. This script runs pip under a lock.
# For details, see https://trac.sagemath.org/ticket/21672


import sys
import os
import fcntl


# Parse commandline (really just argv[1]).
# By default, we apply an exclusive (write) lock. If the string "SHARED"
# is given as first argument, we apply a shared (read) lock instead.

locktype = fcntl.LOCK_EX
if len(sys.argv) >= 1 and sys.argv[1] == "SHARED":
sys.argv.pop(1)
locktype = fcntl.LOCK_SH
sys.argv[0] = "pip3"


# Open lockfile and lock it
lockdir = os.path.join(sys.prefix, "var", "lock")
try:
os.makedirs(lockdir)
except OSError:
if not os.path.isdir(lockdir):
raise

lockfile = os.path.join(lockdir, "pip3.lock")
lock = open(lockfile, "w+")

# First try a non-blocking lock such that we can give an informative
# message while the user is waiting.
try:
fcntl.flock(lock, locktype | fcntl.LOCK_NB)
except IOError:
if locktype == fcntl.LOCK_SH:
kind = "shared"
else:
kind = "exclusive"
sys.stderr.write("Waiting for {0} lock to run {1} ... ".format(kind, " ".join(sys.argv)))
sys.stderr.flush()
fcntl.flock(lock, locktype)
sys.stderr.write("ok\n")
sys.stderr.flush()


# Finally run pip (in this Python session).
# Note that the import of pkg_resources must happen under the lock!
from pkg_resources import load_entry_point
sys.exit(
load_entry_point('pip', 'console_scripts', 'pip3')()
)

0 comments on commit dc46ea2

Please sign in to comment.