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

Merge commit '5dd6acfa' into chamcham

parents 584bdafa 5dd6acfa
No related branches found
No related tags found
No related merge requests found
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(pymoose)
if(COMMAND cmake_policy)
......@@ -21,24 +22,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.1.3-${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
......@@ -418,8 +424,11 @@ 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 -p ${_platform} -d ${PYMOOSE_BDIST_DIR}
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
......@@ -429,7 +438,19 @@ add_custom_command(TARGET bdist POST_BUILD
COMMENT "Unarchiving bdist file ${PYMOOSE_BDIST_FILE} to ${PYMOOSE_BDIST_INSTALL_DIR}"
VERBATIM
)
add_dependencies( bdist _moose )
# 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
)
add_dependencies( bdist copy_pymoose )
add_dependencies( copy_pymoose _moose )
######################### INSTALL ##############################################
......@@ -486,7 +507,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( )
......
......@@ -49,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 ""))
......@@ -77,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}
......@@ -87,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
"""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,47 +15,45 @@ __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.1.3'
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 )
# 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 )
# importlib is available only for python3.
suffix = '.so'
try:
import importlib.machinery
suffix = importlib.machinery.EXTENSION_SUFFIXES[-1]
except ImportError as e:
pass
suffix = importlib.machinery.EXTENSION_SUFFIXES[0].split('.')[-1]
except Exception as e:
print( '[WARN] Failed to determine importlib suffix' )
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.genesis'
, 'moose.chemUtil'
],
install_requires = [ 'python-libsbml', 'numpy' ],
package_dir = { 'moose' : 'moose', 'rdesigneur' : 'rdesigneur' },
package_data = { 'moose' : ['_moose%s' % suffix ] },
)
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'
],
install_requires = [ 'python-libsbml', 'numpy' ],
package_dir = { 'moose' : 'moose', 'rdesigneur' : 'rdesigneur' },
package_data = { 'moose' : ['_moose' + suffix ] },
)
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