Skip to content
Snippets Groups Projects
Commit a039fc3a authored by Dilawar Singh's avatar Dilawar Singh
Browse files

Squashed 'moose-core/' changes from f38dc5d..0cceb29

0cceb29 packaging related changes (#262)
dc861b2 Prepare binary distribution before installing  (#261)

git-subtree-dir: moose-core
git-subtree-split: 0cceb296d06cf021f4fb7120d3f4854c4b219143
parent 33bf735f
No related branches found
No related tags found
No related merge requests found
......@@ -2,8 +2,6 @@ language: cpp
sudo: required
group: edge
services:
- docker
os:
- linux
......@@ -17,6 +15,13 @@ notifications:
on_success: change
on_failure: always
before_script:
- echo "OSX related"
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nvm get head || true; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_prepare_osx.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh; fi
before_script:
- echo "OSX related"
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then nvm get head || true; fi
......@@ -24,8 +29,8 @@ before_script:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo ./.travis/travis_prepare_linux.sh;
fi
script:
-
- python2 -m compileall -q .
- python2 -m compileall -q . || echo "Python2 not found"
- if type python3 > /dev/null; then python3 -m compileall -q . ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./.travis/travis_build_osx.sh; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./.travis/travis_build_linux.sh; fi
......
#!/usr/bin/env bash
#===============================================================================
#
# FILE: travis_build_linux.sh
......@@ -17,44 +18,58 @@
# REVISION: ---
#===============================================================================
set -o nounset # Treat unset variables as an error
set -e
set -e -x
PYTHON2="/usr/bin/python2"
PYTHON3="/usr/bin/python3"
MAKEFLAGS="-j4"
MAKEFLAGS="-j`nproc`"
if [ ! -n "$MAKE" ]; then
MAKE="make -j`nproc`"
else
MAKE="$MAKE -j`nproc`"
fi
unset PYTHONPATH
# Bug: `which python` returns /opt/bin/python* etc on travis. For which numpy
# many not be available. Therefore, it is neccessary to use fixed path for
# python executable.
$PYTHON2 -m compileall -q .
if type $PYTHON3 > /dev/null; then $PYTHON3 -m compileall -q . ; fi
echo "Currently in `pwd`"
(
$PYTHON2 -m compileall -q .
if type $PYTHON3 > /dev/null; then $PYTHON3 -m compileall -q . ; fi
mkdir -p _GSL_BUILD && cd _GSL_BUILD
cmake -DDEBUG=ON -DPYTHON_EXECUTABLE="$PYTHON2" ..
$MAKE && ctest --output-on-failure
)
mkdir -p _GSL_BUILD && cd _GSL_BUILD && \
cmake -DDEBUG=ON -DPYTHON_EXECUTABLE="$PYTHON2" ..
make && ctest --output-on-failure
cd .. # Now with boost.
(
# Now with boost.
mkdir -p _BOOST_BUILD && cd _BOOST_BUILD && \
cmake -DWITH_BOOST=ON -DDEBUG=ON -DQUIET_MODE=ON -DPYTHON_EXECUTABLE="$PYTHON2" ..
make && ctest --output-on-failure
cd ..
# This is only applicable on linux build.
echo "Python3: Removed python2-networkx and install python3"
if type $PYTHON3 > /dev/null; then
sudo apt-get remove -qq python-networkx
sudo apt-get install -qq python3-networkx
$MAKE && ctest --output-on-failure
)
# This is only applicable on linux build.
echo "Python3: Removed python2-networkx and install python3"
if type $PYTHON3 > /dev/null; then
sudo apt-get remove -qq python-networkx
sudo apt-get install -qq python3-networkx
(
mkdir -p _GSL_BUILD2 && cd _GSL_BUILD2 && \
cmake -DDEBUG=ON -DPYTHON_EXECUTABLE="$PYTHON3" ..
make && ctest --output-on-failure
cd .. # Now with BOOST and python3
$MAKE && ctest --output-on-failure
)
(
mkdir -p _BOOST_BUILD2 && cd _BOOST_BUILD2 && \
cmake -DWITH_BOOST=ON -DDEBUG=ON -DPYTHON_EXECUTABLE="$PYTHON3" ..
make && ctest --output-on-failure
cd .. && echo "All done"
else
echo "Python3 is not found. Build disabled"
fi
)
$MAKE && ctest --output-on-failure
)
echo "All done"
else
echo "Python3 is not found. Build disabled"
fi
......@@ -21,19 +21,23 @@ set -o nounset # Treat unset variables as an error
set -e
(
# Make sure not to pick up python from /opt.
PATH=/usr/bin:/usr/local/bin:$PATH
mkdir -p _GSL_BUILD && cd _GSL_BUILD \
&& cmake -DQUIET_MODE=ON -DDEBUG=ON \
-DPYTHON_EXECUTABLE=`which python` ..
make && ctest --output-on-failure
make -j3 && ctest --output-on-failure
cd .. # Now with boost.
mkdir -p _BOOST_BUILD && cd _BOOST_BUILD \
&& cmake -DWITH_BOOST=ON -DDEBUG=ON \
-DPYTHON_EXECUTABLE=`which python` ..
make && ctest --output-on-failure
make -j3 && ctest --output-on-failure
cd ..
set +e
# Now test the brew formula
cd ~
brew tap BhallaLab/moose
brew install moose
)
set +e
......@@ -30,6 +30,6 @@ apt-get install -qq libgsl0-dev
apt-get install -qq python-pip python3-pip
apt-get install -qq libgraphviz-dev
# Dependencies for NML2
# Dependencies for NML2
apt-get install -qq python-scipy python3-scipy
pip install pyNeuroML libNeuroML
#pip install pyNeuroML libNeuroML
......@@ -26,14 +26,19 @@ brew install gsl
brew install hdf5
brew install python
brew install numpy
brew install boost
#brew outdated python || brew install python
#brew outdated numpy || brew install homebrew/python/numpy
brew unlink numpy && brew link numpy || echo "Failed to link numpy"
# Numpy caveats
mkdir -p $HOME/Library/Python/2.7/lib/python/site-packages
echo 'import sys; sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")' >> $HOME/Library/Python/2.7/lib/python/site-packages/homebrew.pth
# To make sure that we do not pick python from /opt etc.
PATH=/usr/local/bin:/usr/bin:$PATH
# ensurepip
#python -m ensurepip
pip2 install matplotlib --user
pip2 install pyNeuroML libNeuroML --user
pip2 install scipy --user
python -m ensurepip
python -m pip install matplotlib --user
python -m pip install pyNeuroML libNeuroML --user
python -m pip install scipy --user
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(moose-core)
project(pymoose)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
......@@ -12,7 +13,7 @@ if(COMMAND cmake_policy)
endif(COMMAND cmake_policy)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
include(CheckCXXCompiler.cmake)
include(CheckIncludeFileCXX)
include(FindPkgConfig)
......@@ -20,24 +21,29 @@ include(FindPkgConfig)
# getgit revision number
find_program( GIT_EXEC git )
if(GIT_EXEC)
execute_process(COMMAND ${GIT_EXEC} rev-parse --short HEAD
execute_process(
COMMAND ${GIT_EXEC} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_HEAD
OUTPUT_STRIP_TRAILING_WHITESPACE
)
)
else(GIT_EXEC)
set(GIT_HEAD 'HEAD')
message(STATUS "Couldn't fetch version from git repo" )
endif()
# If from command line, version info is not passed, use the git to generate a
# version file. If GIT fails, use the previous known version.
if(NOT VERSION_MOOSE)
set(VERSION_MOOSE "3.2.0-${GIT_HEAD}")
endif( )
endif()
add_definitions( -DMOOSE_VERSION="${VERSION_MOOSE}")
message( STATUS "MOOSE Version ${VERSION_MOOSE}" )
# Write VERSION to a file VERSION so that setup.cmake.py can use it.
set(VERSION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/python/VERSION)
message(STATUS "+ Writing ${VERSION_MOOSE} to ${VERSION_FILE}" )
file(WRITE ${VERSION_FILE} ${VERSION_MOOSE} )
message(STATUS "| Writing ${VERSION_MOOSE} to ${VERSION_FILE}" )
# This snippet is from LLVM project.
# Sanity check our source directory to make sure that we are not trying to
......@@ -121,10 +127,7 @@ endif()
################################### TARGETS ####################################
add_library(libmoose SHARED basecode/main.cpp)
if(DEBUG)
add_executable(moose.bin basecode/main.cpp)
endif( )
add_executable(moose.bin basecode/main.cpp)
################################### SETUP BUILD ################################
......@@ -373,61 +376,94 @@ ELSE(MACOSX)
)
endif(MACOSX)
if(DEBUG)
add_dependencies(moose.bin libmoose)
target_link_libraries(moose.bin moose ${CMAKE_DL_LIBS})
if( WITH_BOOST )
target_link_libraries( moose.bin ${Boost_LIBRARIES} )
endif( WITH_BOOST )
endif()
add_dependencies(moose.bin libmoose)
target_link_libraries(moose.bin moose ${CMAKE_DL_LIBS})
if( WITH_BOOST )
target_link_libraries( moose.bin ${Boost_LIBRARIES} )
endif( WITH_BOOST )
######################### BUILD PYMOOSE ########################################
# This target is built by pymoose/CMakeLists.txt file.
add_subdirectory( pymoose )
######################### INSTALL ##############################################
if(DEBUG)
install(TARGETS moose.bin
DESTINATION bin
)
install(TARGETS libmoose
DESTINATION lib
)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/moose
DESTINATION bin
)
endif( )
# INSTALL python module.
# This target is built by pymoose/CMakeLists.txt file. Using the --prefix option
# always override debian default installation directory. It will be installed in
# site-packages instead of dist-packages.
# See https://bugs.launchpad.net/ubuntu/+source/python2.6/+bug/362570
# HACK: Get platform information from python and use it to fix the layout.
execute_process(
COMMAND ${PYTHON_EXECUTABLE} -mplatform OUTPUT_VARIABLE _platform_desc
execute_process(COMMAND ${PYTHON_EXECUTABLE} -mplatform OUTPUT_VARIABLE _platform_desc)
message(STATUS "Platform: ${_platform_desc}")
# DISTUTILS_EXTRA_ARGS may come of top-level cmake script. On DEBIAN/UBUNTU, it
# is most likely to be --install-layout=deb .
set(EXTRA_ARGS "--prefix ${CMAKE_INSTALL_PREFIX} ${DISTUTILS_EXTRA_ARGS}")
# On Debian/Ubuntu install using debian layout.
# NOTE: Also create setup.cfg file which setup prefix and install-layout
# suitable for DEBIAN systems.
if(${_platform_desc} MATCHES ".*(Ubuntu|Debian).*")
list(APPEND EXTRA_ARGS "--install-layout=deb")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/python/setup.cfg
"[install]\nprefix=/usr\ninstall-layout=deb"
)
endif()
# Set PYMOOSE binary distribution build and install directories.
# Target for creating bdist. This is handy for creating bdist for packaging.
# Save the binary distribution (tar.gz) to PYMOOSE_BDIST_DIR.
find_package(PythonInterp REQUIRED)
if(NOT PYMOOSE_BDIST_DIR)
set(PYMOOSE_BDIST_DIR ${CMAKE_BINARY_DIR}/bdist)
endif( )
set(PYMOOSE_BDIST_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/pymoose_bdist_install)
file(MAKE_DIRECTORY ${PYMOOSE_BDIST_INSTALL_DIR})
# We need a custom name for bdist; same on all platform.
set(_platform "CMAKE" )
set(PYMOOSE_BDIST_FILE ${PYMOOSE_BDIST_DIR}/pymoose-${VERSION_MOOSE}.${_platform}.tar.gz)
message(STATUS "binary distribution file ${PYMOOSE_BDIST_FILE}")
add_custom_target(bdist ALL DEPENDS ${PYMOOSE_BDIST_FILE} )
# Any command using setup.cmake.py must run in the same directory.
add_custom_command( OUTPUT ${PYMOOSE_BDIST_FILE}
COMMAND ${PYTHON_EXECUTABLE} setup.cmake.py bdist_dumb -p ${_platform}
-d ${PYMOOSE_BDIST_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python
COMMENT "bdist is saved to ${PYMOOSE_BDIST_DIR}"
VERBATIM
)
add_custom_command(TARGET bdist POST_BUILD
COMMAND ${CMAKE_COMMAND} -E chdir ${PYMOOSE_BDIST_INSTALL_DIR} tar xvf ${PYMOOSE_BDIST_FILE}
COMMENT "Unarchiving bdist file ${PYMOOSE_BDIST_FILE} to ${PYMOOSE_BDIST_INSTALL_DIR}"
VERBATIM
)
message( STATUS "Platform ${_platform_desc}" )
# Copy python files from source to current binary directory. Make sure to call
# this before building bdist.
file(GLOB_RECURSE PYTHON_SRCS "${CMAKE_SOURCE_DIR}/python/*")
add_custom_target(copy_pymoose DEPENDS ${PYTHON_SRCS}
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/python ${CMAKE_CURRENT_BINARY_DIR}/python
COMMENT "Copying required python files and other files to build directory"
VERBATIM
)
set(EXTRA_ARGS "--prefix ${CMAKE_INSTALL_PREFIX}")
add_dependencies( bdist copy_pymoose )
add_dependencies( copy_pymoose _moose )
# On Debian/Ubuntu install using debian layout
if( ${_platform_desc} MATCHES ".*(Ubuntu|Debian).*" )
list( APPEND EXTRA_ARGS "--install-layout=deb" )
endif( )
######################### INSTALL ##############################################
# If make is called with sudo, install in system directories. Otherwise use
# --user to install in user home.
install(CODE
"execute_process(
COMMAND ${PYTHON_EXECUTABLE} setup.cmake.py install ${EXTRA_ARGS} ${PYMOOSE_EXTRA_INSTALL_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python
)"
)
install(TARGETS moose.bin DESTINATION bin CONFIGURATIONS Debug)
install(TARGETS libmoose DESTINATION lib CONFIGURATIONS Debug)
install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/moose
DESTINATION bin CONFIGURATIONS Debug
)
# install pymoose bdist.
install(DIRECTORY ${PYMOOSE_BDIST_INSTALL_DIR}/
DESTINATION ${CMAKE_INSTALL_PREFIX}
CONFIGURATIONS Release
)
# Print message to start build process
if(${CMAKE_BUILD_TOOL} MATCHES "make")
......@@ -468,7 +504,7 @@ foreach( _test_script ${PY_TEST_SCRIPTS} )
WORKING_DIRECTORY ${PYMOOSE_TEST_DIRECTORY}
)
set_tests_properties( ${_test_name}
PROPERTIES ENVIRONMENT "PYTHONPATH=${PROJECT_BINARY_DIR}/python"
PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/python"
)
endforeach( )
......
......@@ -11,16 +11,22 @@ set(PYMOOSE_SRCS
PyRun.cpp
)
# Build _moose.so in source directory and them copy everything to
# current binary directory using cmake.
add_library( _moose MODULE ${PYMOOSE_SRCS} )
set(PYMOOSE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/python/moose")
set(PYMOOSE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/python/moose")
find_package(PythonInterp REQUIRED)
execute_process( COMMAND ${PYTHON_EXECUTABLE} -c
"try: import importlib.machinery; print(importlib.machinery.EXTENSION_SUFFIXES[0])
except Exception: pass"
execute_process( COMMAND
${PYTHON_EXECUTABLE} -c
"import importlib.machinery
print(importlib.machinery.EXTENSION_SUFFIXES[-1])"
OUTPUT_VARIABLE PYTHON_SO_EXTENSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PYTHON_SO_EXTENSION)
set(PYTHON_SO_EXTENSION ".so")
endif()
message( STATUS "Python so extension ${PYTHON_SO_EXTENSION}" )
find_package(NumPy REQUIRED)
......@@ -43,7 +49,7 @@ set_target_properties(_moose PROPERTIES
COMPILE_FLAGS "${PYTHON_INCLUDE_FLAGS}"
LIBRARY_OUTPUT_DIRECTORY ${PYMOOSE_OUTPUT_DIRECTORY}
PREFIX ""
SUFFIX ".so"
SUFFIX ${PYTHON_SO_EXTENSION}
)
if(NOT(PYTHON_SO_EXTENSION STREQUAL ""))
......@@ -71,7 +77,7 @@ if(MACOSX)
target_link_libraries(_moose
${SYSTEM_SHARED_LIBS}
)
ELSE(MACOSX)
else(MACOSX)
target_link_libraries(_moose
"-Wl,--whole-archive"
${MOOSE_LIBRARIES}
......@@ -81,25 +87,12 @@ ELSE(MACOSX)
${SYSTEM_SHARED_LIBS}
)
endif(MACOSX)
# Make this target dependant on all python files in python folder.
add_custom_target(copy_python_files
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/python ${CMAKE_BINARY_DIR}/python
COMMENT "Copying required python files and other files to build directory"
VERBATIM
)
add_dependencies(_moose copy_python_files)
# Print message at the end of build process.
add_custom_command( TARGET _moose POST_BUILD
add_custom_command(TARGET _moose POST_BUILD
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan
"MOOSE python extention is successfully built. Now "
" 1. Run 'make install' to install it for single user. "
" 2. Run 'sudo make install' to install it system-wide. "
" "
"NOTE: Run 'pip uninstall moose' to uninstall moose."
"MOOSE python extention is successfully built. Now "
" Run 'sudo make install' to install it. "
" "
"NOTE: Run 'pip uninstall moose' to uninstall moose."
VERBATIM
)
# -*- coding: utf-8 -*-
from __future__ import print_function, division, absolute_import
# Author: Subhasis Ray
# Maintainer: Dilawar Singh, Harsha Rani, Upi Bhalla
......
# -*- coding: utf-8 -*-
from __future__ import print_function
"""setup.py:
Script to install python targets.
NOTE: This script is to be called by CMake. Not intended to be used standalone.
"""
# NOTE: This script is to be called by CMake. Not intended to be used standalone.
__author__ = "Dilawar Singh"
__copyright__ = "Copyright 2013, Dilawar Singh and NCBS Bangalore"
......@@ -19,22 +15,23 @@ __status__ = "Development"
import os
import sys
try:
from setuptools import setup
except Exception as e:
from distutils.core import setup
# NOTE: Though setuptool is preferred we use distutils.
# 1. setuptool normalize VERSION even when it is compatible with PyPI
# guidelines. This caused havoc on our OBS build.
from distutils.core import setup
script_dir = os.path.dirname( os.path.abspath( __file__ ) )
version = '3.2pre1'
# Version file must be available. It MUST be written by cmake. Or create
# manually.
with open( os.path.join( script_dir, 'VERSION'), 'r' ) as f:
version = f.read( )
print( 'Got %s from VERSION file' % version )
try:
with open( os.path.join( script_dir, 'VERSION'), 'r' ) as f:
version = f.read( )
except Exception as e:
print( 'Failed to read VERSION %s' % e )
print( 'Using default %s' % version )
# importlib is available only for python3.
suffix = '.so'
try:
import importlib.machinery
suffix = importlib.machinery.EXTENSION_SUFFIXES[0].split('.')[-1]
......@@ -43,27 +40,20 @@ except Exception as e:
suffix = '.so'
setup(
name='pymoose',
version=version,
description='Python scripting interface of MOOSE Simulator (https://moose.ncbs.res.in)',
author='MOOSERes',
author_email='bhalla@ncbs.res.in',
maintainer='Dilawar Singh',
maintainer_email='dilawars@ncbs.res.in',
url='http://moose.ncbs.res.in',
packages=[
'rdesigneur'
, 'moose'
, 'moose.SBML'
, 'moose.neuroml'
, 'moose.neuroml2'
, 'moose.genesis'
, 'moose.chemUtil'
, 'moose.chemMerge'
],
install_requires = [ 'python-libsbml', 'numpy' ],
package_dir = {
'moose' : 'moose', 'rdesigneur' : 'rdesigneur'
},
package_data = { 'moose' : ['_moose' + suffix, 'neuroml2/schema/NeuroMLCoreDimensions.xml'] },
)
name = 'pymoose',
version = version,
description = 'Python scripting interface of MOOSE Simulator (https://moose.ncbs.res.in)',
author = 'MOOSERes',
author_email = 'bhalla@ncbs.res.in',
maintainer = 'Dilawar Singh',
maintainer_email = 'dilawars@ncbs.res.in',
url = 'http://moose.ncbs.res.in',
packages = [ 'rdesigneur', 'moose'
, 'moose.SBML', 'moose.genesis'
, 'moose.neuroml', 'moose.neuroml2'
, 'moose.chemUtil', 'moose.chemMerge'
],
install_requires = [ 'python-libsbml', 'numpy' ],
package_dir = { 'moose' : 'moose', 'rdesigneur' : 'rdesigneur' },
package_data = { 'moose' : ['_moose' + suffix, 'neuroml2/schema/NeuroMLCoreDimensions.xml'] },
)
# -*- coding: utf-8 -*-
from __future__ import print_function
"""setup.py: This
NOT COMPLETE.
scripts prepare MOOSE for PyPI.
Last modified: Mon Jul 28, 2014 12:52AM
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment