Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/cpython/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ fi

$PYTHON $BASE_DIR/resources/test.py > /dev/null
test "`$PYTHON $BASE_DIR/resources/test.py`" = "hello"

NUMPY_TEST='import numpy; print(numpy.array([1.0]))'
$PYTHON -c "$NUMPY_TEST" > /dev/null
test "`$PYTHON -c "$NUMPY_TEST"`" = '[1.]'
15 changes: 15 additions & 0 deletions build/numpy/VERSIONS
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
1.18.3 cpython 3.8.0
1.17.5 cpython 3.8.0
1.16.6 cypthon 3.8.0

1.18.3 cpython 3.7.5
1.17.5 cpython 3.7.5
1.16.6 cypthon 3.7.5

1.18.3 cpython 3.6.2
1.17.5 cpython 3.6.2
1.16.6 cypthon 3.6.2

1.18.3 cpython 3.5.1
1.17.5 cpython 3.5.1
1.16.6 cypthon 3.5.1
22 changes: 22 additions & 0 deletions build/numpy/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM ubuntu:16.04

MAINTAINER melpon <[email protected]>

RUN apt-get update && \
apt-get install -y \
gcc \
git \
libc6-dev \
libffi-dev \
libgdbm-dev \
libncursesw5-dev \
libsqlite3-dev \
libssl-dev \
make \
openssl \
python-minimal \
tk-dev \
zlib1g-dev && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

16 changes: 16 additions & 0 deletions build/numpy/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

. ../init.sh

function check_version() {
version=$1
compiler=$2
compiler_version=$3

while read line; do
if [ "$version $compiler $compiler_version" = "$line" ]; then
return 0
fi
done < VERSIONS
return 1
}
21 changes: 21 additions & 0 deletions build/numpy/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

. ./init.sh

if [ $# -lt 3 ]; then
echo "$0 <version> <compiler> <compiler_version>"
exit 0
fi

VERSION=$1
COMPILER=$2
COMPILER_VERSION=$3

check_version $VERSION $COMPILER $COMPILER_VERSION

PREFIX=/opt/wandbox/numpy-$VERSION/$COMPILER-$COMPILER_VERSION
COMPILER_PREFIX=/opt/wandbox/$COMPILER-$COMPILER_VERSION
VERSION_TARNAME=$(echo $VERSION | sed 's/\./_/g')

$COMPILER_PREFIX/bin/python3 -m pip install -U pip
$COMPILER_PREFIX/bin/python3 -m pip install -t $PREFIX numpy==$VERSION
27 changes: 27 additions & 0 deletions build/numpy/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

. ./init.sh

if [ $# -lt 3 ]; then
echo "$0 <version> <compiler> <compiler_version>"
exit 0
fi

set -ex

VERSION=$1
COMPILER=$2
COMPILER_VERSION=$3

check_version $VERSION $COMPILER $COMPILER_VERSION

PREFIX=/opt/wandbox/numpy-$VERSION/$COMPILER-$COMPILER_VERSION
COMPILER_PREFIX=/opt/wandbox/$COMPILER-$COMPILER_VERSION

if [ "$COMPILER" = "cpython" ]; then
export PYTHONPATH=$PREFIX
$COMPILER_PREFIX/bin/python3 -c 'import numpy; numpy.array([1, 2])'
test "$($COMPILER_PREFIX/bin/python3 -c 'import numpy; a = numpy.array([1, 2]); print(a)')" = '[1 2]'
else
exit 1
fi
42 changes: 40 additions & 2 deletions cattleshed-conf/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def get_boost_versions_with_head():
return get_boost_versions() + [(bv,) + tuple(c.split('-')) for bv, c in get_boost_head_versions()]


# [(<numpy-version>, <compiler>, <compiler-version>)]
def get_numpy_versions():
lines = open(os.path.join(build_path(), 'numpy', 'VERSIONS')).readlines()
return [tuple(line.split()) for line in lines if len(line.strip()) != 0]


def read_versions(name):
lines = open(os.path.join(build_path(), name, 'VERSIONS')).readlines()
return [line.strip() for line in lines if len(line) != 0]
Expand Down Expand Up @@ -244,6 +250,34 @@ def make_cxx(self):
]
return self.resolve_conflicts(pairs, 'std-cxx')

def make_numpy(self):
numpy_vers = sort_version(set(a for a, _, _ in get_numpy_versions()))
numpy_ver_set = set(get_numpy_versions())
compiler_vers = [('cpython', v) for v in get_generic_versions('cpython', False)]

result = []
for c, cv in compiler_vers:
pairs = format_value([
('numpy-nothing-{c}-{cv}', {
'flags': [],
'display-name': "Don't Use Numpy",
'display-flags': '',
}),
], c=c, cv=cv)
for bv in numpy_vers:
if (bv, c, cv) not in numpy_ver_set:
continue

pairs.append(format_value(('numpy-{bv}-{c}-{cv}', {
'flags': [
'PYTHONPATH=/opt/wandbox/numpy-{bv}/{c}-{cv}'
],
'display-name': 'Numpy {bv}',
'display-flags': 'PYTHONPATH=/opt/wandbox/numpy-{bv}/{c}-{cv}',
}), bv=bv, c=c, cv=cv))
result.append(self.resolve_conflicts(pairs, 'numpy-{c}-{cv}'.format(c=c, cv=cv)))
return merge(*result)

def make_boost(self):
boost_vers = sort_version(set(a for a, _, _ in get_boost_versions_with_head()))
gcc_vers = sort_version(get_gcc_versions(includes_gcc_1=False, with_head=True))
Expand Down Expand Up @@ -419,7 +453,8 @@ def make(self):
self.make_boost(),
self.make_boost_header(),
self.make_c(),
self.make_cxx())
self.make_cxx(),
self.make_numpy())

class Compilers(object):
def make_gcc_c(self):
Expand Down Expand Up @@ -1351,6 +1386,9 @@ def make_cpython(self):
else:
version_command = ['/bin/echo', '{cv}']

switches = ['numpy-nothing-cpython-{cv}'.format(cv=cv)]
switches += ['numpy-{x}-cpython-{cv}'.format(x=x, cv=cv) for x in sort_version(get_numpy_versions())]

compilers.append(format_value({
'name': 'cpython-{cv}',
'displayable': True,
Expand All @@ -1359,7 +1397,7 @@ def make_cpython(self):
'compiler-option-raw': False,
'compile-command': ['/bin/true'],
'version-command': version_command,
'switches': [],
'switches': switches,
'initial-checked': [],
'display-name': display_name,
'display-compile-command': '{python} prog.py',
Expand Down