Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pymolfile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nomad-lab
pymolfile
Commits
4a835052
Commit
4a835052
authored
Oct 30, 2017
by
Berk Onat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Python installer with setup.py is provided
parent
282efaa4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
78 deletions
+48
-78
pymolfile/molfile/CMakeLists.txt
pymolfile/molfile/CMakeLists.txt
+1
-2
pymolfile/molfile/external/CMakeLists.txt
pymolfile/molfile/external/CMakeLists.txt
+2
-10
pymolfile/molfile/molfile_plugins/compile/CMakeLists.txt
pymolfile/molfile/molfile_plugins/compile/CMakeLists.txt
+8
-8
pymolfile/molfile/molfile_plugins/compile/FindNetCDF.cmake
pymolfile/molfile/molfile_plugins/compile/FindNetCDF.cmake
+0
-0
setup.py
setup.py
+37
-58
No files found.
pymolfile/molfile/CMakeLists.txt
View file @
4a835052
...
...
@@ -5,8 +5,7 @@ project(molfile)
add_subdirectory
(
external
)
add_subdirectory
(
molfile_plugins/compile
)
#set_source_files_properties( tng/include/tng/tng_io.h PROPERTIES GENERATED TRUE
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_CURRENT_BINARY_DIR
}
/molfile_plugins/compile/"
)
add_dependencies
(
molfile_plugins_comp tngio_comp
)
#add_dependencies( molfile_plugins_comp TNGBuilder )
pymolfile/molfile/external/CMakeLists.txt
View file @
4a835052
...
...
@@ -14,21 +14,13 @@ message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
ExternalProject_Add
(
tng
PREFIX
${
TNG_PREFIX
}
GIT_REPOSITORY https://github.com/gromacs/tng.git
GIT_TAG v1.7.6
INSTALL_DIR
${
TNG_INSTALL_DIR
}
CMAKE_ARGS
${
TNG_CMAKE_ARGS
}
)
#set(LIB_TNGIO_FILES
# "${TNG_INSTALL_DIR}/include/tng/tng_io.h")
#
#if (APPLE)
# set(LIB_TNGIO_FILES ${LIB_TNGIO_FILES} "${TNG_INSTALL_DIR}/lib/libtng_io.dylib")
#else()
# set(LIB_TNGIO_FILES ${LIB_TNGIO_FILES} "${TNG_INSTALL_DIR}/lib/libtng_io.so")
#endif()
#
add_custom_target
(
tngio_comp ALL
DEPENDS
${
TNG_INSTALL_DIR
}
DEPENDS
${
CMAKE_CURRENT_BINARY_DIR
}
/tng
)
pymolfile/molfile/molfile_plugins/compile/CMakeLists.txt
View file @
4a835052
...
...
@@ -2,10 +2,11 @@ cmake_minimum_required(VERSION 2.8.12)
project
(
molfileplugins
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
${
CMAKE_CURRENT_BINARY_DIR
}
)
find_package
(
EXPAT
)
find_package
(
TCL
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/molfile_plugins/compile/cmake/Modules/"
)
find_package
(
NetCDF
)
find_package
(
NETCDF
)
if
(
EXISTS
"
${
TNG_INSTALL_DIR
}
/lib/libtng_io.dylib"
OR EXISTS
"
${
TNG_INSTALL_DIR
}
/lib/libtng_io.so"
...
...
@@ -33,8 +34,8 @@ if(TARGET_ARCH MATCHES "^.*64.*$")
endif
()
set
(
LIB_MOLFILE_FILES
"
${
CMAKE_
SOURCE_DIR
}
/molfile_plugins/compile
/lib/libmolfile_plugins.a"
"
${
CMAKE_
SOURCE_DIR
}
/molfile_plugins/compile/lib/libmolfile_plugins.h"
)
"
${
CMAKE_
CURRENT_BINARY_DIR
}
/lib/libmolfile_plugins.a"
"
${
CMAKE_
CURRENT_BINARY_DIR
}
/lib/libmolfile_plugins.h"
)
if
(
UNIX AND NOT APPLE
)
set
(
LINUX TRUE
)
...
...
@@ -124,6 +125,8 @@ if(UNIX)
add_custom_command
(
OUTPUT
${
LIB_MOLFILE_FILES
}
COMMAND make dynlibs staticlibs bins \"ARCH =
${
TARGET_ARCH
}
\" \"COPTO =
${
TARGET_COPT
}
\" \"LOPTO =
${
TARGET_LOPT
}
\" \"CC =
${
CMAKE_C_COMPILER
}
\" \"CXX =
${
CMAKE_CXX_COMPILER
}
\" \"DEF =
${
TARGET_DEF
}
\" \"CCFLAGS =
${
TARGET_CFLAGS
}
\" \"CXXFLAGS =
${
TARGET_CXXFLG
}
\" \"AR =
${
TARGET_AR
}
\" \"NM =
${
TARGET_NM
}
\" \"RANLIB =
${
TARGET_RANLIB
}
\" \"LIBTOOL =
${
TARGET_LIBTOOL
}
\"
${
TARGET_MOL_LIBS
}
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_SOURCE_DIR
}
/molfile_plugins/compile/lib
${
CMAKE_CURRENT_BINARY_DIR
}
/lib
COMMAND
${
CMAKE_COMMAND
}
-E remove_directory
${
CMAKE_SOURCE_DIR
}
/molfile_plugins/compile/lib
COMMENT
"Compiling libmolfile_plugin.a"
WORKING_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
/molfile_plugins/molfile_plugin"
)
...
...
@@ -151,6 +154,8 @@ if(WINCOMP)
add_custom_command
(
OUTPUT
${
LIB_MOLFILE_FILES
}
COMMAND
${
MYMAKE
}
dynlibs win32staticlibs
"
\"
ARCH =
${
TARGET_ARCH
}
\"
"
"
\"
COPTO = /Fo
\"
"
"
\"
LOPTO = /OUT:
\"
"
"
\"
${
TARGET_MOL_SETTINGS
}
\"
"
"
\"
DEF =
${
TARGET_DEF
}
\"
"
"
\"
AR =
${
TARGET_AR
}
\"
"
"
\"
NM =
${
TARGET_NM
}
\"
"
"
\"
RANLIB =
${
TARGET_RANLIB
}
\"
"
"
\"
SHLDFLAGS =
${
TARGET_SHLDFLAGS
}
\"
"
"
\"
${
TARGET_MOL_LIBS
}
\"
"
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CMAKE_SOURCE_DIR
}
/molfile_plugins/compile/lib
${
CMAKE_CURRENT_BINARY_DIR
}
/molfile_plugins/compile/lib
COMMAND
${
CMAKE_COMMAND
}
-E remove_directory
${
CMAKE_SOURCE_DIR
}
/molfile_plugins/compile/lib
COMMENT
"Compiling libmolfile_plugin.a"
WORKING_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
/molfile_plugins/molfile_plugin"
)
...
...
@@ -160,10 +165,5 @@ add_custom_target(molfile_plugins_comp ALL
DEPENDS
${
LIB_MOLFILE_FILES
}
)
#add_library(molfile_plugins INTERFACE)
#target_include_directories(molfile_plugins INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/lib/")
#target_link_libraries(molfile_plugins INTERFACE ${MOLFILE_LIBRARIES})
pymolfile/molfile/molfile_plugins/compile/
cmake/Modules/
FindNetCDF.cmake
→
pymolfile/molfile/molfile_plugins/compile/FindNetCDF.cmake
View file @
4a835052
File moved
setup.py
View file @
4a835052
...
...
@@ -6,46 +6,38 @@ import sys
import
sysconfig
import
platform
import
subprocess
from
distutils.version
import
LooseVersion
try
:
from
distutils.version
import
LooseVersion
from
setuptools.command.build_ext
import
build_ext
from
setuptools
import
setup
,
Extension
,
Command
,
find_packages
#from Cython.Build import cythonize
#from Cython.Distutils import build_ext
from
setuptools.command.install
import
install
except
:
from
distutils.version
import
LooseVersion
from
distutils.command.build_ext
import
build_ext
from
distutils
import
setup
,
Extension
,
Command
,
find_packages
#from Cython.Build import cythonize
#from Cython.Distutils import build_ext
from
distutils.command.install
import
install
try
:
from
setuptools.command.build_clib
import
build_clib
as
_build_clib
except
:
from
distutils.command.build_clib
import
build_clib
as
_build_clib
# from http://www.benjack.io/2017/06/12/python-cpp-tests.html
class
CMakeExtension
(
Extension
):
def
__init__
(
self
,
name
,
sourcedir
=
''
):
Extension
.
__init__
(
self
,
name
,
sources
=
[])
self
.
sourcedir
=
os
.
path
.
abspath
(
sourcedir
)
class
CMakeBuild
(
build_ext
):
class
build_clib
(
_build_clib
):
def
run
(
self
):
try
:
out
=
subprocess
.
check_output
([
'cmake'
,
'--version'
])
except
OSError
:
raise
RuntimeError
(
"CMake must be installed to build the following extensions: "
+
", "
.
join
(
e
.
name
for
e
in
self
.
extensions
))
if
platform
.
system
()
==
"Windows"
:
cmake_version
=
LooseVersion
(
re
.
search
(
r'version\s*([\d.]+)'
,
out
.
decode
()).
group
(
1
))
if
cmake_version
<
'3.1.0'
:
raise
RuntimeError
(
"CMake >= 3.1.0 is required on Windows"
)
for
ext
in
self
.
extensions
:
self
.
build_extension
(
ext
)
buildflag
=
True
if
buildflag
:
ext
=
CMakeExtension
(
'molfile'
,
sourcedir
=
'pymolfile/molfile/'
),
self
.
my_build_extension
(
ext
)
def
build_extension
(
self
,
ext
):
def
my_
build_extension
(
self
,
ext
):
extdir
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
self
.
get_ext_fullpath
(
ext
.
name
)
))
os
.
path
.
dirname
(
'pymolfile/molfile'
))
cmake_args
=
[
'-DCMAKE_LIBRARY_OUTPUT_DIRECTORY='
+
extdir
,
'-DPYTHON_EXECUTABLE='
+
sys
.
executable
]
...
...
@@ -69,12 +61,14 @@ class CMakeBuild(build_ext):
self
.
distribution
.
get_version
())
if
not
os
.
path
.
exists
(
self
.
build_temp
):
os
.
makedirs
(
self
.
build_temp
)
subprocess
.
check_call
([
'cmake'
,
ext
.
sourcedir
]
+
cmake_args
,
cwd
=
self
.
build_temp
,
env
=
env
)
subprocess
.
check_call
([
'cmake'
,
'../pymolfile/molfile'
]
+
cmake_args
,
cwd
=
self
.
build_temp
+
'/../'
,
env
=
env
)
subprocess
.
check_call
([
'cmake'
,
'--build'
,
'.'
]
+
build_args
,
cwd
=
self
.
build_temp
)
cwd
=
self
.
build_temp
+
'/../'
)
print
()
# Add an empty line for cleaner output
def
get_ext_filename_without_platform_suffix
(
filename
):
name
,
ext
=
os
.
path
.
splitext
(
filename
)
ext_suffix
=
sysconfig
.
get_config_var
(
'EXT_SUFFIX'
)
...
...
@@ -104,6 +98,7 @@ CLASSIFIERS = [
"Programming Language :: C"
,
"Programming Language :: C++"
,
"Programming Language :: Python"
,
"Programming Language :: Python :: 2"
,
"Programming Language :: Python :: 3"
,
"Topic :: Scientific/Engineering :: Physics"
,
"Topic :: Scientific/Engineering :: Chemistry"
,
...
...
@@ -173,52 +168,38 @@ def get_numpy_include():
numpy_include
=
np
.
get_numpy_include
()
return
numpy_include
# from SimpleTraj setup.py (https://github.com/arose/simpletraj)
# Needed for large-file seeking under 32bit systems (migth need for indexing and access).
largefile_macros
=
[
(
"_LARGEFILE_SOURCE"
,
None
),
(
"_LARGEFILE64_SOURCE"
,
None
),
(
"_FILE_OFFSET_BITS"
,
"64"
)
]
if
__name__
==
'__main__'
:
libpymolfile_module
=
Extension
(
'pymolfile/molfile/_libpymolfile'
,
sources
=
[
'pymolfile/molfile/libpymolfile.i'
,
'pymolfile/molfile/pymolfile.cxx'
'pymolfile/molfile/pymolfile.cxx'
,
'build/molfile_plugins/compile/lib/libmolfile_plugin.a'
,
'build/molfile_plugins/compile/lib/libmolfile_plugin.h'
,
'build/external/tng/lib'
,
],
swig_opts
=
[
'-py3'
,
'-Wall'
,
'-c++'
],
library_dirs
=
[
'
pymolfile/molfile/external/tng/lib/
'
,
'
pymolfile/molfile
/molfile_plugins/compile/lib/'
'
build/external/tng/lib
'
,
'
build
/molfile_plugins/compile/lib/'
],
libraries
=
[
'netcdf'
,
'tng_io'
,
'expat'
],
include_dirs
=
[
get_numpy_include
(),
#get_cmake_includes(),
'pymolfile/molfile'
,
'pymolfile/molfile/molfile_plugins/include'
,
'pymolfile/molfile/molfile_plugins/molfile_plugin/include'
,
'
pymolfile/molfile
/molfile_plugins/compile/lib/'
,
'
pymolfile/molfile
/external/tng/include'
,
'
build
/molfile_plugins/compile/lib/'
,
'
build
/external/tng/include'
,
],
extra_compile_args
=
[
'-fPIC'
,
'-shared'
,
'-O2'
,
'-w'
#'-DNDEBUG', '-DUNIX', '-D__UNIX', '-m64',
#'-fPIC', '-O2', '-w', '-fmessage-length=0'
],
extra_link_args
=
[
'
pymolfile/molfile
/molfile_plugins/compile/lib/libmolfile_plugin.a'
'
build
/molfile_plugins/compile/lib/libmolfile_plugin.a'
],
define_macros
=
largefile_macros
)
#if sys.version_info > (3,):
# command_extension={'build_ext': BuildExtWithoutPlatformSuffix}
#else:
# command_extension={}
command_extension
=
dict
(
build_ext
=
CMakeBuild
)
setup
(
name
=
"pymolfile"
,
...
...
@@ -231,18 +212,16 @@ if __name__ == '__main__':
url
=
"https://gitlab.mpcdf.mpg.de/berko/pymolfile"
,
zip_safe
=
False
,
packages
=
find_packages
(),
cmdclass
=
command_extension
,
cmdclass
=
{
'build_clib'
:
build_clib
,
'build_ext'
:
BuildExtWithoutPlatformSuffix
,
},
ext_modules
=
[
CMakeExtension
(
'molfile'
,
sourcedir
=
'pymolfile/molfile/'
),
libpymolfile_module
,
],
py_modules
=
[
"pymolfile"
],
requires
=
[
"numpy"
],
setup_requires
=
[
"numpy"
],
install_requires
=
[
"numpy"
],
extras_require
=
{
#?do we need this? "netcdf": [ "netCDF Library" ],
#?and this? "tng_io": [ "TNG Library" ],
#?and this? "expat": [ "Expat XML Library" ]
}
extras_require
=
{}
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment