Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.6 build using yum #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
124 changes: 78 additions & 46 deletions build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,57 +1,89 @@
#!/bin/bash
set -ex

yum update -y
yum install -y \
# Update this container
echo "Yum updating container..." > /dev/null 2>&1
yum -y update
echo "Yum updating container...done" > /dev/null 2>&1

# Set up env vars
PYTHON_VER_YUM='36'
PYTHON_VER='3.6'
NUMPY_VER='1.13.3'
SCIPY_VER='0.19.1'
SKLEARN_VER='0.19.0'

LAMBDA_PACKAGE_DIR='outputs/lambda-package'
LIB_DIR="${LAMBDA_PACKAGE_DIR}/lib"
LAMBDA_PACKAGE_ZIP='lambda-package.zip'
LAMBDA_PACKAGE_ZIP_RELPATH="outputs/${LAMBDA_PACKAGE_ZIP}"

SITE_PACKAGES_DIR="/usr/local/lib64/python${PYTHON_VER}/site-packages"

echo "Yum installing non-pip packages..." > /dev/null 2>&1
yum -y install \
atlas-devel \
atlas-sse3-devel \
blas-devel \
findutils \
gcc \
gcc-c++ \
lapack-devel \
python27-devel \
python27-virtualenv \
findutils \
python${PYTHON_VER_YUM}-devel \
zip
echo "Yum installing non-pip packages...done" > /dev/null 2>&1

echo "Pip installing packages using local compilation for numpy and scipy..." > /dev/null 2>&1
/usr/bin/pip-${PYTHON_VER} install --upgrade pip setuptools

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

produced an error later in the script as pip 18.1 was installed but numpy and scipy installation looked for 9.0.3 ??

worked when this line was commented out

/usr/bin/pip-${PYTHON_VER} install --no-binary numpy numpy==${NUMPY_VER}
/usr/bin/pip-${PYTHON_VER} install --no-binary scipy scipy==${SCIPY_VER}
/usr/bin/pip-${PYTHON_VER} install scikit-learn==${SKLEARN_VER}
echo "Pip installing packages using local compilation for numpy and scipy...done" > /dev/null 2>&1

echo "Verfifying installation..." > /dev/null 2>&1
/usr/bin/python${PYTHON_VER} -V
/usr/bin/python${PYTHON_VER} -c "import numpy as np; print(np.version.version)"
/usr/bin/python${PYTHON_VER} -c "import numpy as np; print(np.__config__.show())"
/usr/bin/python${PYTHON_VER} -c "import scipy as sp; print(sp.version.version)"
/usr/bin/python${PYTHON_VER} -c "import sklearn; print(sklearn.__version__)"
echo "Verfifying installation...done" > /dev/null 2>&1

echo "Preparing ${LIB_DIR}..." > /dev/null 2>&1
mkdir -p ${LIB_DIR}
echo "Preparing ${LIB_DIR}...done" > /dev/null 2>&1

echo "Copying ${SITE_PACKAGES_DIR} contents to ${LAMBDA_PACKAGE_DIR}..." > /dev/null 2>&1
cp -rf ${SITE_PACKAGES_DIR}/* ${LAMBDA_PACKAGE_DIR}
echo "Copying ${SITE_PACKAGES_DIR} contents to ${LAMBDA_PACKAGE_DIR}...done" > /dev/null 2>&1

echo "Copying compiled libraries to ${LIB_DIR}..." > /dev/null 2>&1
cp /usr/lib64/atlas/* ${LIB_DIR}
cp /usr/lib64/libquadmath.so.0 ${LIB_DIR}
cp /usr/lib64/libgfortran.so.3 ${LIB_DIR}
echo "Copying compiled libraries to ${LIB_DIR}...done" > /dev/null 2>&1

echo "Reducing package size..." > /dev/null 2>&1
echo "Original unzipped package size: $(du -sh ${LAMBDA_PACKAGE_DIR} | cut -f1)" > /dev/null 2>&1
# Remove README
rm ${LAMBDA_PACKAGE_DIR}/README
# Remove distribution info directories
rm -rf ${LAMBDA_PACKAGE_DIR}/*.egg-info
rm -rf ${LAMBDA_PACKAGE_DIR}/*.dist-info
# Remove all testing directories
find ${LAMBDA_PACKAGE_DIR} -name tests | xargs rm -rf
# strip excess from compiled .so files
find ${LAMBDA_PACKAGE_DIR} -name "*.so" | xargs strip
echo "Final unzipped package size: $(du -sh ${LAMBDA_PACKAGE_DIR} | cut -f1)" > /dev/null 2>&1
echo "Reducing package size...done" > /dev/null 2>&1

echo "Compressing packages into ${LAMBDA_PACKAGE_ZIP}..." > /dev/null 2>&1
pushd ${LAMBDA_PACKAGE_DIR} > /dev/null 2>&1 && zip -r9q /${LAMBDA_PACKAGE_ZIP_RELPATH} * ; popd > /dev/null 2>&1
echo "lambda-package.zip size: $(du -sh ${LAMBDA_PACKAGE_ZIP_RELPATH} | cut -f1)" > /dev/null 2>&1
echo "Compressing packages into lambda-package.zip...done" > /dev/null 2>&1

echo "SUCCESS!!!" > /dev/null 2>&1

do_pip () {
pip install --upgrade pip wheel
pip install --use-wheel --no-binary numpy numpy
pip install --use-wheel --no-binary scipy scipy
pip install --use-wheel sklearn
}

strip_virtualenv () {
echo "venv original size $(du -sh $VIRTUAL_ENV | cut -f1)"
find $VIRTUAL_ENV/lib64/python2.7/site-packages/ -name "*.so" | xargs strip
echo "venv stripped size $(du -sh $VIRTUAL_ENV | cut -f1)"

pushd $VIRTUAL_ENV/lib64/python2.7/site-packages/ && zip -r -9 -q /outputs/venv.zip * ; popd
echo "site-packages compressed size $(du -sh /outputs/venv.zip | cut -f1)"

pushd $VIRTUAL_ENV && zip -r -q /outputs/full-venv.zip * ; popd
echo "venv compressed size $(du -sh /outputs/full-venv.zip | cut -f1)"
}

shared_libs () {
libdir="$VIRTUAL_ENV/lib64/python2.7/site-packages/lib/"
mkdir -p $VIRTUAL_ENV/lib64/python2.7/site-packages/lib || true
cp /usr/lib64/atlas/* $libdir
cp /usr/lib64/libquadmath.so.0 $libdir
cp /usr/lib64/libgfortran.so.3 $libdir
}

main () {
/usr/bin/virtualenv \
--python /usr/bin/python /sklearn_build \
--always-copy \
--no-site-packages
source /sklearn_build/bin/activate

do_pip

shared_libs

strip_virtualenv
}
main
echo "USAGE TIPS:" > /dev/null 2>&1
echo " Add your lambda function handler module to the top level of ${LAMBDA_PACKAGE_ZIP_RELPATH} (optionally including the .pyc file in __pycache__)" > /dev/null 2>&1
echo " --OR--" > /dev/null 2>&1
echo " Add your lambda function handler module to the top level of ${LAMBDA_PACKAGE_DIR} (optionally including the .pyc file in __pycache__) and zip with maximum compression" > /dev/null 2>&1
Binary file added lambda-package.zip
Binary file not shown.
Binary file added lambda-package/lib/libatlas.a
Binary file not shown.
Binary file added lambda-package/lib/libatlas.so
Binary file not shown.
Binary file added lambda-package/lib/libatlas.so.3
Binary file not shown.
Binary file added lambda-package/lib/libatlas.so.3.0
Binary file not shown.
Binary file added lambda-package/lib/libcblas.a
Binary file not shown.
Binary file added lambda-package/lib/libcblas.so
Binary file not shown.
Binary file added lambda-package/lib/libcblas.so.3
Binary file not shown.
Binary file added lambda-package/lib/libcblas.so.3.0
Binary file not shown.
Binary file added lambda-package/lib/libclapack.so
Binary file not shown.
Binary file added lambda-package/lib/libclapack.so.3
Binary file not shown.
Binary file added lambda-package/lib/libclapack.so.3.0
Binary file not shown.
Binary file added lambda-package/lib/libf77blas.a
Binary file not shown.
Binary file added lambda-package/lib/libf77blas.so
Binary file not shown.
Binary file added lambda-package/lib/libf77blas.so.3
Binary file not shown.
Binary file added lambda-package/lib/libf77blas.so.3.0
Binary file not shown.
Binary file added lambda-package/lib/libgfortran.so.3
Binary file not shown.
Binary file added lambda-package/lib/liblapack.a
Binary file not shown.
Binary file added lambda-package/lib/liblapack.so
Binary file not shown.
Binary file added lambda-package/lib/liblapack.so.3
Binary file not shown.
Binary file added lambda-package/lib/liblapack.so.3.0
Binary file not shown.
Binary file added lambda-package/lib/libptcblas.a
Binary file not shown.
Binary file added lambda-package/lib/libptcblas.so
Binary file not shown.
Binary file added lambda-package/lib/libptcblas.so.3
Binary file not shown.
Binary file added lambda-package/lib/libptcblas.so.3.0
Binary file not shown.
Binary file added lambda-package/lib/libptf77blas.a
Binary file not shown.
Binary file added lambda-package/lib/libptf77blas.so
Binary file not shown.
Binary file added lambda-package/lib/libptf77blas.so.3
Binary file not shown.
Binary file added lambda-package/lib/libptf77blas.so.3.0
Binary file not shown.
Binary file added lambda-package/lib/libquadmath.so.0
Binary file not shown.
34 changes: 34 additions & 0 deletions lambda-package/numpy/__config__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file is generated by /tmp/pip-build-8zjfp4t_/numpy/-c
# It contains system_info results at the time of building this package.
__all__ = ["get_info","show"]

blas_mkl_info={}
blis_info={}
openblas_info={}
atlas_3_10_blas_threads_info={}
atlas_3_10_blas_info={}
atlas_blas_threads_info={'include_dirs': ['/usr/include'], 'language': 'c', 'define_macros': [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.8.4\\""')], 'libraries': ['ptf77blas', 'ptcblas', 'atlas', 'ptf77blas', 'ptcblas'], 'library_dirs': ['/usr/lib64/atlas']}
blas_opt_info={'include_dirs': ['/usr/include'], 'language': 'c', 'define_macros': [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.8.4\\""')], 'libraries': ['ptf77blas', 'ptcblas', 'atlas', 'ptf77blas', 'ptcblas'], 'library_dirs': ['/usr/lib64/atlas']}
lapack_mkl_info={}
openblas_lapack_info={}
atlas_3_10_threads_info={}
atlas_3_10_info={}
atlas_threads_info={'include_dirs': ['/usr/include'], 'language': 'f77', 'libraries': ['lapack', 'ptf77blas', 'ptcblas', 'atlas', 'ptf77blas', 'ptcblas'], 'library_dirs': ['/usr/lib64/atlas'], 'define_macros': [('ATLAS_INFO', '"\\"3.8.4\\""')]}
lapack_opt_info={'include_dirs': ['/usr/include'], 'language': 'f77', 'libraries': ['lapack', 'ptf77blas', 'ptcblas', 'atlas', 'ptf77blas', 'ptcblas'], 'library_dirs': ['/usr/lib64/atlas'], 'define_macros': [('ATLAS_INFO', '"\\"3.8.4\\""')]}

def get_info(name):
g = globals()
return g.get(name, g.get(name + "_info", {}))

def show():
for name,info_dict in globals().items():
if name[0] == "_" or type(info_dict) is not type({}): continue
print(name + ":")
if not info_dict:
print(" NOT AVAILABLE")
for k,v in info_dict.items():
v = str(v)
if k == "sources" and len(v) > 200:
v = v[:60] + " ...\n... " + v[-60:]
print(" %s = %s" % (k,v))

199 changes: 199 additions & 0 deletions lambda-package/numpy/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
"""
NumPy
=====

Provides
1. An array object of arbitrary homogeneous items
2. Fast mathematical operations over arrays
3. Linear Algebra, Fourier Transforms, Random Number Generation

How to use the documentation
----------------------------
Documentation is available in two forms: docstrings provided
with the code, and a loose standing reference guide, available from
`the NumPy homepage <http://www.scipy.org>`_.

We recommend exploring the docstrings using
`IPython <http://ipython.scipy.org>`_, an advanced Python shell with
TAB-completion and introspection capabilities. See below for further
instructions.

The docstring examples assume that `numpy` has been imported as `np`::

>>> import numpy as np

Code snippets are indicated by three greater-than signs::

>>> x = 42
>>> x = x + 1

Use the built-in ``help`` function to view a function's docstring::

>>> help(np.sort)
... # doctest: +SKIP

For some objects, ``np.info(obj)`` may provide additional help. This is
particularly true if you see the line "Help on ufunc object:" at the top
of the help() page. Ufuncs are implemented in C, not Python, for speed.
The native Python help() does not know how to view their help, but our
np.info() function does.

To search for documents containing a keyword, do::

>>> np.lookfor('keyword')
... # doctest: +SKIP

General-purpose documents like a glossary and help on the basic concepts
of numpy are available under the ``doc`` sub-module::

>>> from numpy import doc
>>> help(doc)
... # doctest: +SKIP

Available subpackages
---------------------
doc
Topical documentation on broadcasting, indexing, etc.
lib
Basic functions used by several sub-packages.
random
Core Random Tools
linalg
Core Linear Algebra Tools
fft
Core FFT routines
polynomial
Polynomial tools
testing
NumPy testing tools
f2py
Fortran to Python Interface Generator.
distutils
Enhancements to distutils with support for
Fortran compilers support and more.

Utilities
---------
test
Run numpy unittests
show_config
Show numpy build configuration
dual
Overwrite certain functions with high-performance Scipy tools
matlib
Make everything matrices.
__version__
NumPy version string

Viewing documentation using IPython
-----------------------------------
Start IPython with the NumPy profile (``ipython -p numpy``), which will
import `numpy` under the alias `np`. Then, use the ``cpaste`` command to
paste examples into the shell. To see which functions are available in
`numpy`, type ``np.<TAB>`` (where ``<TAB>`` refers to the TAB key), or use
``np.*cos*?<ENTER>`` (where ``<ENTER>`` refers to the ENTER key) to narrow
down the list. To view the docstring for a function, use
``np.cos?<ENTER>`` (to view the docstring) and ``np.cos??<ENTER>`` (to view
the source code).

Copies vs. in-place operation
-----------------------------
Most of the functions in `numpy` return a copy of the array argument
(e.g., `np.sort`). In-place versions of these functions are often
available as array methods, i.e. ``x = np.array([1,2,3]); x.sort()``.
Exceptions to this rule are documented.

"""
from __future__ import division, absolute_import, print_function

import sys
import warnings

from ._globals import ModuleDeprecationWarning, VisibleDeprecationWarning
from ._globals import _NoValue

# We first need to detect if we're being called as part of the numpy setup
# procedure itself in a reliable manner.
try:
__NUMPY_SETUP__
except NameError:
__NUMPY_SETUP__ = False

if __NUMPY_SETUP__:
sys.stderr.write('Running from numpy source directory.\n')
else:
try:
from numpy.__config__ import show as show_config
except ImportError:
msg = """Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there."""
raise ImportError(msg)

from .version import git_revision as __git_revision__
from .version import version as __version__

from ._import_tools import PackageLoader

def pkgload(*packages, **options):
loader = PackageLoader(infunc=True)
return loader(*packages, **options)

from . import add_newdocs
__all__ = ['add_newdocs',
'ModuleDeprecationWarning',
'VisibleDeprecationWarning']

pkgload.__doc__ = PackageLoader.__call__.__doc__

# We don't actually use this ourselves anymore, but I'm not 100% sure that
# no-one else in the world is using it (though I hope not)
from .testing import Tester
test = testing.nosetester._numpy_tester().test
bench = testing.nosetester._numpy_tester().bench

# Allow distributors to run custom init code
from . import _distributor_init

from . import core
from .core import *
from . import compat
from . import lib
from .lib import *
from . import linalg
from . import fft
from . import polynomial
from . import random
from . import ctypeslib
from . import ma
from . import matrixlib as _mat
from .matrixlib import *
from .compat import long

# Make these accessible from numpy name-space
# but not imported in from numpy import *
if sys.version_info[0] >= 3:
from builtins import bool, int, float, complex, object, str
unicode = str
else:
from __builtin__ import bool, int, float, complex, object, unicode, str

from .core import round, abs, max, min

__all__.extend(['__version__', 'pkgload', 'PackageLoader',
'show_config'])
__all__.extend(core.__all__)
__all__.extend(_mat.__all__)
__all__.extend(lib.__all__)
__all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])


# Filter annoying Cython warnings that serve no good purpose.
warnings.filterwarnings("ignore", message="numpy.dtype size changed")
warnings.filterwarnings("ignore", message="numpy.ufunc size changed")
warnings.filterwarnings("ignore", message="numpy.ndarray size changed")

# oldnumeric and numarray were removed in 1.9. In case some packages import
# but do not use them, we define them here for backward compatibility.
oldnumeric = 'removed'
numarray = 'removed'
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 10 additions & 0 deletions lambda-package/numpy/_distributor_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""" Distributor init file
Distributors: you can add custom code here to support particular distributions
of numpy.
For example, this is a good place to put any checks for hardware requirements.
The numpy standard source distribution will not put code in this file, so you
can safely replace this file with your own version.
"""
Loading