From 33bf735fb61ae5a94a2a531fa14a03632ee7ca42 Mon Sep 17 00:00:00 2001 From: Dilawar Singh <dilawars@ncbs.res.in> Date: Fri, 2 Mar 2018 16:48:47 +0530 Subject: [PATCH] Squashed 'moose-core/' changes from f1dcea8..f38dc5d f38dc5d On tumbleweed, cmake returns python3 default but python-numpy is python2 version. Won't fix it. Its a upstream problem. REVERT: f1dcea8 Install in debian layout in packages. Added option in setup.cfg file Its delicate solution. Added a note. REVERT: 5a73acb Finally. Needs to write setup.cfg file to make /usr/local and /usr prefix consistent. REVERT: d7c41e4 bdist_egg is more consistent on both RPM and DEB based systems. REVERT: be42fd2 Merge commit 'bcf5c52d54409a89f9af1cf08e5d369d9e9e0d7f' into chennapoda REVERT: d27db9c Do not use -p switch. its not easy to get required info from all linux-distributions. REVERT: e667953 Fixed message to set in cmake. REVERT: 8523290 Fixed typo in command. REVERT: 0b125f6 Fixed typo in cmake file. REVERT: f3118f0 multiple fix to build system. - dont use python setup.py install . It does not work anymore if --prefix directory is not in PYTHONPATH. - Use python setup.py bdist -d INSTALL_DIR and let cmake unarchive and copy it to desired location. This is much better solution. REVERT: 03d5899 Use bdist instead of install for creating binay distrution. During installation, untar this to destination. REVERT: a08658e Tweaks to setup.cmake.py file. REVERT: c5f1d91 Test on travis. REVERT: 6b32fde Merge commit '6d651b6013e1093a1cdb2541bb8615bbc3a66021' REVERT: 324a20c Merge commit 'e0b8959ccefd77195b7eac2edc1db7cdcaa40fe6' REVERT: 59f6e9e On debian/ubuntu install-layout option is set to deb. [skip ci] REVERT: 62201d9 Merge commit 'f80ae40d5b1e1b63eb9849b9699d76f33e4f2572' REVERT: 9b81dfc This fixes moose but a better solution to install pymoose in moose-core must be found. REVERT: 7e27f80 Merge commit '6f7697fb3256626a6d57bda24ae0a7bb5c0e90cc' REVERT: 939c734 Merge commit '627f1ce1cc73b0e1f6b4fe9051d3597e3a9113a5' REVERT: 4775933 Merge commit '7b3c355a04d22f279a88bfae4097e9cf3f62439b' REVERT: 43c0674 Squashed 'moose-core/' changes from d4417dcffd..2657e3345e (#222) REVERT: 8c9ad49 Fixed the syntax causing failure. REVERT: 397efaf Handling MOOSE_VERSION is better way. git-subtree-dir: moose-core git-subtree-split: f38dc5d6b2d6a3bcb5439a2f5ba680adad754ec7 --- CMakeLists.txt | 45 ++++------------------------------- cmake_modules/FindNumPy.cmake | 16 ++++--------- pymoose/CMakeLists.txt | 3 ++- python/moose/moose_test.py | 3 +-- python/setup.cmake.py | 40 +++++++++++++++---------------- 5 files changed, 31 insertions(+), 76 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a513d76e..0541457f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) cmake_minimum_required(VERSION 2.8 FATAL_ERROR) -project(pymoose) +project(moose-core) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) @@ -245,14 +245,6 @@ if(HDF5_LIBRARY_DIRS) set_target_properties( libmoose PROPERTIES LINK_FLAGS "-L${HDF5_LIBRARY_DIRS}" ) endif() -find_package(Termcap) -find_package(Readline) - -if(READLINE_FOUND AND TERMCAP_FOUND) - add_definitions(-DUSE_READLINE) - include_directories(${Readline_INCLUDE_DIR}) -endif() - # Openmpi if(WITH_MPI) find_package(MPI REQUIRED) @@ -393,7 +385,6 @@ endif() ######################### BUILD PYMOOSE ######################################## add_subdirectory( pymoose ) - ######################### INSTALL ############################################## if(DEBUG) @@ -422,25 +413,18 @@ execute_process( 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}") +set(EXTRA_ARGS "--prefix ${CMAKE_INSTALL_PREFIX}") -# On Debian/Ubuntu install using debian layout. -# NOTE: Also create setup.cfg file which setup prefix and install-layout -# suitable for DEBIAN systems. +# On Debian/Ubuntu install using debian layout 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( ) # 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 -f ${EXTRA_ARGS} ${PYMOOSE_EXTRA_INSTALL_ARGS} + COMMAND ${PYTHON_EXECUTABLE} setup.cmake.py install ${EXTRA_ARGS} ${PYMOOSE_EXTRA_INSTALL_ARGS} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python )" ) @@ -455,27 +439,6 @@ if(${CMAKE_BUILD_TOOL} MATCHES "make") ) endif() -# Target for creating bdist. This is handy for creating bdist for packaging. -# Save the binary distribution (tar.gz) to PYMOOSE_BDIST_DIR. Note that this -# target is only useful when creating packages on Open Build Service i.e. if you -# use this target on distribution X, it may not work on distrbutions other than -# X. See python-wheels for making portable distributions. -if(NOT PYMOOSE_BDIST_DIR) - set(PYMOOSE_BDIST_DIR ${CMAKE_BINARY_DIR}/pymoose_bdist) -endif( ) - -# get platform and arch using python. -# NOTE: creating bdist or bdist_dump uses /usr and /usr/local on rpm and deb -# based unix respectively. Not a great situation to be in. Need to write a -# setup.cfg file to fix the prefix in all cases. -find_package( PythonInterp REQUIRED) -add_custom_target( bdist - COMMAND ${PYTHON_EXECUTABLE} setup.cmake.py bdist_dumb -d ${PYMOOSE_BDIST_DIR} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python - COMMENT "Genearating bdist using setup.cmake.py." - VERBATIM - ) - ############################ CTEST ###################################### include( CTest ) diff --git a/cmake_modules/FindNumPy.cmake b/cmake_modules/FindNumPy.cmake index f14142f1..5de7901e 100644 --- a/cmake_modules/FindNumPy.cmake +++ b/cmake_modules/FindNumPy.cmake @@ -39,23 +39,15 @@ #============================================================================ # Finding NumPy involves calling the Python interpreter -if(NumPy_FIND_REQUIRED) - find_package(PythonInterp REQUIRED) -else() - find_package(PythonInterp) -endif() - -if(NOT PYTHONINTERP_FOUND) - set(NUMPY_FOUND FALSE) - return() -endif() -execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" +message( STATUS "Using python ${PYTHON_EXECUTABLE} to locate numpy" ) +execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy as n; print(n.__version__); print(n.get_include());" RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS OUTPUT_VARIABLE _NUMPY_VALUES_OUTPUT ERROR_VARIABLE _NUMPY_ERROR_VALUE - OUTPUT_STRIP_TRAILING_WHITESPACE) + OUTPUT_STRIP_TRAILING_WHITESPACE +) if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) if(NumPy_FIND_REQUIRED) diff --git a/pymoose/CMakeLists.txt b/pymoose/CMakeLists.txt index 713ade07..adf4176b 100644 --- a/pymoose/CMakeLists.txt +++ b/pymoose/CMakeLists.txt @@ -10,10 +10,11 @@ set(PYMOOSE_SRCS test_moosemodule.cpp PyRun.cpp ) -add_library( _moose MODULE ${PYMOOSE_SRCS} ) +add_library( _moose MODULE ${PYMOOSE_SRCS} ) set(PYMOOSE_OUTPUT_DIRECTORY "${CMAKE_BINARY_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" diff --git a/python/moose/moose_test.py b/python/moose/moose_test.py index 9d5ad245..9cda2b80 100644 --- a/python/moose/moose_test.py +++ b/python/moose/moose_test.py @@ -26,12 +26,11 @@ import logging from collections import defaultdict import time -logfile_ = tempfile.NamedTemporaryFile( ) logging.basicConfig( level=logging.DEBUG, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%m-%d %H:%M', - filename = logfile_.name, + filename='tests.log', filemode='w' ) console = logging.StreamHandler() diff --git a/python/setup.cmake.py b/python/setup.cmake.py index b1761f99..94787ff7 100644 --- a/python/setup.cmake.py +++ b/python/setup.cmake.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -""" -setup.cmake.py: +"""setup.py: +Script to install python targets. -Script to install python targets by cmake. +NOTE: This script is to be called by CMake. Not intended to be used standalone. -DO NOT USE IT DIRECTLY. Only `cmake` build system should use it directly. """ __author__ = "Dilawar Singh" @@ -21,30 +20,33 @@ import os import sys try: - from setuptools import setup + from setuptools import setup except Exception as e: - from distutils.core import setup - + from distutils.core import setup -# Read version from VERSION created by cmake file. This file must be present for -# setup.cmake.py to work perfectly. script_dir = os.path.dirname( os.path.abspath( __file__ ) ) -version = None -with open( os.path.join( script_dir, 'VERSION'), 'r' ) as f: - version = f.read( ) +version = '3.2pre1' + + +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 ) try: import importlib.machinery - suffix = importlib.machinery.EXTENSION_SUFFIXES[0] + suffix = importlib.machinery.EXTENSION_SUFFIXES[0].split('.')[-1] except Exception as e: - print( '[WARN] Failed to determine importlib suffix due to %s' % 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='See AUTHORS.md at https://github.com/BhallaLab/moose', + author='MOOSERes', author_email='bhalla@ncbs.res.in', maintainer='Dilawar Singh', maintainer_email='dilawars@ncbs.res.in', @@ -59,11 +61,9 @@ setup( , 'moose.chemUtil' , 'moose.chemMerge' ], - install_requires = [ 'python-libsbml', 'numpy' ], + install_requires = [ 'python-libsbml', 'numpy' ], package_dir = { 'moose' : 'moose', 'rdesigneur' : 'rdesigneur' }, - package_data = { - 'moose' : ['_moose' + suffix, 'neuroml2/schema/NeuroMLCoreDimensions.xml'] - }, - ) + package_data = { 'moose' : ['_moose' + suffix, 'neuroml2/schema/NeuroMLCoreDimensions.xml'] }, + ) -- GitLab