Skip to content

Commit 9f475b3

Browse files
dilawarDilawar Singh
authored andcommitted
Added centos build docker file.
Docker build was successful. Needs to improve test function... setup.py is working just fine. CMake and python's setup.py can use each other. Time to remove pymoose/setup.cmake.py file. Removed the cmake helper script. It has been moved to topmost directory where it can be used on its own. Squashed commit of the following: commit 374bf50 Author: Dilawar Singh <[email protected]> Date: Tue Feb 4 14:22:29 2020 +0530 This seems to work just fine. commit 4746ec4 Author: Dilawar Singh <[email protected]> Date: Mon Feb 3 21:54:25 2020 +0530 testing is required. commit d2ddaf7 Author: Dilawar Singh <[email protected]> Date: Mon Feb 3 21:34:59 2020 +0530 Seems to be just fine now. commit 63dceb4 Merge: c743aed 5499353 Author: Dilawar <[email protected]> Date: Mon Feb 3 15:32:41 2020 +0000 Merge branch 'setup.py_and_cmake' of https://github.com/dilawar/moose-core into setup.py_and_cmake commit c743aed Author: Dilawar <[email protected]> Date: Mon Feb 3 15:32:05 2020 +0000 Some more changes. commit 5499353 Author: Dilawar Singh <[email protected]> Date: Mon Feb 3 20:52:43 2020 +0530 Use cmake2.8 commit c8b365a Author: Dilawar Singh <[email protected]> Date: Mon Feb 3 20:37:54 2020 +0530 Lets test it in fresh docker image. removed uninstall target, use pip to uninstall moose. Added path in target_link_directories macro for target moose.bin. MOOSE's python module.
1 parent 5777ede commit 9f475b3

22 files changed

+166
-232
lines changed

.docker/centos/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM centos:7
2+
MAINTAINER Dilawar Singh <[email protected]>
3+
4+
# Install dependencies.
5+
RUN yum -y update && yum -y install epel-release && yum -y update \
6+
&& yum -y clean all --enablerepo='*'
7+
RUN yum install -y git cmake gcc gcc-c++ make \
8+
python3 python3-devel python3-setuptools python3-numpy \
9+
&& yum -y clean all --enablerepo='*'
10+
RUN yum install -y gsl-devel \
11+
&& yum -y clean all --enablerepo='*'
12+
# These are required to run tests.
13+
RUN yum install -y python3-matplotlib python3-networkx graphviz python3-scipy \
14+
&& yum -y clean all --enablerepo='*'
15+
WORKDIR /home/root
16+
# RUN git clone https://github.com/dilawar/moose-core -b devel
17+
# Run docker build from outside
18+
COPY . moose-core
19+
RUN cd moose-core && python3 setup.py build && python3 setup.py install
20+
RUN python3 -c 'import moose;moose.test()'

.docker/centos/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
NAME:=dilawars/centos-moose
2+
VERSION:=$(shell date +%Y.%m.%d)
3+
4+
PROJECT_ROOT_DIR:=(PWD)/../..
5+
6+
all : build
7+
8+
build : Dockerfile
9+
cd ../../ && docker build -t $(NAME):$(VERSION) -f $(PWD)/Dockerfile .
10+
cd ../../ && docker build -t $(NAME):latest -f $(PWD)/Dockerfile .
11+
12+
upload :
13+
docker push $(NAME):$(VERSION)
14+
docker push $(NAME):latest
15+
16+
run :
17+
docker run -ti $(NAME):$(VERSION) bash
18+

CMakeLists.txt

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,22 @@
11
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
2-
project(MOOSE)
32

4-
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules")
3+
project(PyMOOSE DESCRIPTION "MOOSE Python Module")
4+
5+
# cmake related macros.
6+
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
57
include(CheckCXXCompiler.cmake)
68
include(CheckIncludeFileCXX)
9+
include(FindPythonModule)
710

8-
# getgit revision number
9-
find_program( GIT_EXEC git )
10-
if(GIT_EXEC)
11-
execute_process(
12-
COMMAND ${GIT_EXEC} rev-parse --short HEAD
13-
OUTPUT_VARIABLE GIT_HEAD
14-
OUTPUT_STRIP_TRAILING_WHITESPACE
15-
)
16-
else(GIT_EXEC)
17-
set(GIT_HEAD 'HEAD')
18-
message(STATUS "Couldn't fetch version from git repo" )
19-
endif()
2011

21-
# If from command line, version info is not passed, use the git to generate a
22-
# version file. If GIT fails, use the previous known version.
12+
# If moose version is not given, then create a default version.
13+
string(TIMESTAMP STAMP "%Y%m%d")
2314
if(NOT VERSION_MOOSE)
24-
set(VERSION_MOOSE "3.2.0-${GIT_HEAD}")
15+
set(VERSION_MOOSE "3.2.dev${STAMP}")
2516
endif()
2617

27-
add_definitions( -DMOOSE_VERSION="${VERSION_MOOSE}")
28-
message( STATUS "MOOSE Version ${VERSION_MOOSE}" )
29-
30-
# Write VERSION to a file VERSION so that setup.cmake.py can use it.
31-
set(VERSION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/python/VERSION)
32-
file(WRITE ${VERSION_FILE} ${VERSION_MOOSE} )
33-
message(STATUS "| Writing ${VERSION_MOOSE} to ${VERSION_FILE}" )
18+
add_definitions(-DMOOSE_VERSION="${VERSION_MOOSE}")
19+
message(STATUS "MOOSE Version ${VERSION_MOOSE}")
3420

3521
# This snippet is from LLVM project.
3622
# Sanity check our source directory to make sure that we are not trying to
@@ -50,21 +36,6 @@ if( CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
5036
)
5137
endif()
5238

53-
# uninstall target
54-
configure_file(
55-
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
56-
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
57-
IMMEDIATE @ONLY
58-
)
59-
60-
add_custom_target(uninstall
61-
COMMAND ${CMAKE_COMMAND} -P
62-
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
63-
)
64-
65-
# This is for testing purpose.
66-
link_directories(${CMAKE_CURRENT_BINARY_DIR})
67-
6839
################################ CMAKE OPTIONS ##################################
6940
option(WITH_NSDF "Enable NSDF support. Requires hdf5" OFF )
7041

@@ -327,6 +298,8 @@ endif(APPLE)
327298

328299
add_dependencies(moose.bin libmoose)
329300
target_link_libraries(moose.bin moose ${CMAKE_DL_LIBS})
301+
target_link_directories(moose.bin PUBLIC ${CMAKE_BINARY_DIR})
302+
330303
if( WITH_BOOST )
331304
target_link_libraries( moose.bin ${Boost_LIBRARIES} )
332305
endif( WITH_BOOST )
@@ -341,12 +314,14 @@ endif( WITH_BOOST )
341314
# See the cmake doc.
342315
# Till then, stay with the old macro.
343316
set(Python_ADDITIONAL_VERSIONS 2.7)
344-
find_package(PythonInterp 3.4)
317+
find_package(PythonInterp 3.5)
318+
if(NOT PYTHONINTERP_FOUND)
319+
find_package(PythonInterp 2.7)
320+
endif()
345321

346322
# This target is built by pymoose/CMakeLists.txt file.
347323
add_subdirectory(pymoose)
348324

349-
350325
# always override debian default installation directory. It will be installed in
351326
# site-packages instead of dist-packages.
352327
# See https://bugs.launchpad.net/ubuntu/+source/python2.6/+bug/362570
@@ -363,20 +338,19 @@ set(EXTRA_ARGS "--prefix ${CMAKE_INSTALL_PREFIX} ${DISTUTILS_EXTRA_ARGS}")
363338
# suitable for DEBIAN systems.
364339
if(${_platform_desc} MATCHES ".*(Ubuntu|debian).*")
365340
list(APPEND EXTRA_ARGS "--install-layout=deb")
366-
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/python/setup.cfg
341+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/setup.cfg
367342
"[install]\nprefix=/usr\ninstall-layout=deb"
368343
)
369344
endif()
370345

371346

372347
######################### INSTALL ##############################################
348+
373349
install(TARGETS moose.bin DESTINATION bin CONFIGURATIONS Debug)
374350
install(TARGETS libmoose DESTINATION lib CONFIGURATIONS Debug)
375351

376-
# install pymoose bdist.
377-
install(DIRECTORY ${PYMOOSE_BDIST_INSTALL_DIR}/
378-
DESTINATION ${CMAKE_INSTALL_PREFIX}
379-
CONFIGURATIONS Release Debug)
352+
# NOTE: Install macro for _moose (pymoose) has been moved to
353+
# pymoose/CMakeLists.txt file.
380354

381355
# Print message to start build process
382356
if(${CMAKE_BUILD_TOOL} MATCHES "make")
@@ -409,6 +383,7 @@ set(PYMOOSE_TEST_DIRECTORY ${CMAKE_SOURCE_DIR}/tests/python)
409383
# Collect all python script in tests folder and run them.
410384
file(GLOB PY_TEST_SCRIPTS "${PYMOOSE_TEST_DIRECTORY}/test_*.py" )
411385

386+
412387
# Run python tests.
413388
foreach( _test_script ${PY_TEST_SCRIPTS} )
414389
get_filename_component( _test_name ${_test_script} NAME_WE)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

cmake/FindPythonModule.cmake

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This is from https://cmake.org/pipermail/cmake/2011-January/041666.html
2+
function(find_python_module module)
3+
string(TOUPPER ${module} module_upper)
4+
if(NOT PY_${module_upper})
5+
if(ARGC GREATER 1 AND ARGV1 STREQUAL "REQUIRED")
6+
set(${module}_FIND_REQUIRED TRUE)
7+
endif()
8+
# A module's location is usually a directory, but for binary modules
9+
# it's a .so file.
10+
execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
11+
"import re, ${module}; print re.compile('/__init__.py.*').sub('',${module}.__file__)"
12+
RESULT_VARIABLE _${module}_status
13+
OUTPUT_VARIABLE _${module}_location
14+
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
15+
if(NOT _${module}_status)
16+
set(PY_${module_upper} ${_${module}_location} CACHE STRING
17+
"Location of Python module ${module}")
18+
endif(NOT _${module}_status)
19+
endif(NOT PY_${module_upper})
20+
find_package_handle_standard_args(PY_${module} DEFAULT_MSG PY_${module_upper})
21+
endfunction(find_python_module)
File renamed without changes.

0 commit comments

Comments
 (0)