Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
2c39cb5e
"vscode:/vscode.git/clone" did not exist on "662eb730d42ce64807b618fb5b0b7a4c810c3c52"
Commit
2c39cb5e
authored
Mar 23, 2011
by
Peter Eastman
Browse files
Cleaning up Python build process
parent
1a50d0c1
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
134 additions
and
63616 deletions
+134
-63616
wrappers/python/CMakeLists.txt
wrappers/python/CMakeLists.txt
+133
-136
wrappers/python/README.txt
wrappers/python/README.txt
+0
-113
wrappers/python/pysetup.cmake.in
wrappers/python/pysetup.cmake.in
+1
-1
wrappers/python/src/swig_doxygen/OpenMMSwig.cxx
wrappers/python/src/swig_doxygen/OpenMMSwig.cxx
+0
-63240
wrappers/python/src/swig_doxygen/README.txt
wrappers/python/src/swig_doxygen/README.txt
+0
-56
wrappers/python/src/swig_doxygen/buildSwigWrapper.sh
wrappers/python/src/swig_doxygen/buildSwigWrapper.sh
+0
-70
No files found.
wrappers/python/CMakeLists.txt
View file @
2c39cb5e
...
...
@@ -55,58 +55,58 @@ foreach(INIT_FILE ${STAGING_INPUT_FILES})
# message("STAGING_OUTPUT_FILE = " ${outfile})
endforeach
(
INIT_FILE
${
STAGING_INPUT_FILES
}
)
#
Swig wrapper need to be rebuilt if the API has changed
set
(
OPENMM_PYTHON_BUILD_SWIG ON CACHE BOOL
"Whether to r
ebuild
s
wig wrappers
vs using the premade ones."
)
if
(
OPENMM_PYTHON_BUILD_SWIG
)
# Look in ~/bin/swig first, more likely to be latest version on build machines
find_program
(
SWIG_EXECUTABLE swig PATHS
#
#######################################################
### R
ebuild
the S
wig wrappers
if the API has changed ###
########################################################
# Look in ~/bin/swig first, more likely to be latest version on build machines
find_program
(
SWIG_EXECUTABLE swig PATHS
"$ENV{HOME}/bin"
"/Users/builder/bin"
"/home/builder/bin"
NO_DEFAULT_PATH
)
find_program
(
SWIG_EXECUTABLE swig
)
if
(
SWIG_EXECUTABLE
)
find_program
(
SWIG_EXECUTABLE swig
)
if
(
SWIG_EXECUTABLE
)
execute_process
(
COMMAND
${
SWIG_EXECUTABLE
}
-version
OUTPUT_VARIABLE SWIG_VERSION_output ERROR_VARIABLE SWIG_VERSION_output
)
string
(
REGEX REPLACE
".*SWIG Version[^0-9.]*
\(
[0-9.]+
\)
.*"
"
\\
1"
SWIG_VERSION_output
"
${
SWIG_VERSION_output
}
"
)
set
(
SWIG_VERSION
${
SWIG_VERSION_output
}
CACHE STRING
"Swig version"
FORCE
)
else
(
SWIG_EXECUTABLE
)
else
(
SWIG_EXECUTABLE
)
set
(
SWIG_VERSION
"0.0.0"
CACHE STRING
"Swig version"
FORCE
)
endif
(
SWIG_EXECUTABLE
)
# Enforce swig version
string
(
COMPARE LESS
"
${
SWIG_VERSION
}
"
"1.3.39"
SWIG_VERSION_ERROR
)
if
(
SWIG_VERSION_ERROR
)
endif
(
SWIG_EXECUTABLE
)
# Enforce swig version
string
(
COMPARE LESS
"
${
SWIG_VERSION
}
"
"1.3.39"
SWIG_VERSION_ERROR
)
if
(
SWIG_VERSION_ERROR
)
message
(
"Swig version must be 1.3.39 or greater! (You have
${
SWIG_VERSION
}
)"
)
endif
(
SWIG_VERSION_ERROR
)
endif
(
SWIG_VERSION_ERROR
)
find_package
(
Doxygen REQUIRED
)
mark_as_advanced
(
CLEAR DOXYGEN_EXECUTABLE
)
find_package
(
Doxygen REQUIRED
)
mark_as_advanced
(
CLEAR DOXYGEN_EXECUTABLE
)
find_package
(
Java REQUIRED
)
mark_as_advanced
(
CLEAR JAVA_RUNTIME
)
find_package
(
Java REQUIRED
)
mark_as_advanced
(
CLEAR JAVA_RUNTIME
)
# SWIG_OPENMM_DIR is package area where swig files will be created/used
set
(
SWIG_OPENMM_DIR
"
${
OPENMM_PYTHON_STAGING_DIR
}
/src/swig_doxygen"
)
file
(
MAKE_DIRECTORY
${
SWIG_OPENMM_DIR
}
/swig_lib/python
)
# SWIG_OPENMM_DIR is package area where swig files will be created/used
set
(
SWIG_OPENMM_DIR
"
${
OPENMM_PYTHON_STAGING_DIR
}
/src/swig_doxygen"
)
file
(
MAKE_DIRECTORY
${
SWIG_OPENMM_DIR
}
/swig_lib/python
)
### Create OpenMM_headers.xml ###
# Step 1 - Create Doxyfile to point to OpenMM headers
configure_file
(
### Create OpenMM_headers.xml ###
# Step 1 - Create Doxyfile to point to OpenMM headers
configure_file
(
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/swig_doxygen/doxygen/Doxyfile.in
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/Doxyfile
@ONLY
)
)
# Step 2 - Run doxygen in non-package area
add_custom_command
(
# Step 2 - Run doxygen in non-package area
add_custom_command
(
OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/xml/index.xml"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/xml/combine.xslt"
COMMAND
"
${
DOXYGEN_EXECUTABLE
}
"
DEPENDS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/Doxyfile"
WORKING_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen"
COMMENT
"Parsing OpenMM header files with doxygen..."
)
)
# Step 3 - Run xslt to create combined xml file
add_custom_command
(
# Step 3 - Run xslt to create combined xml file
add_custom_command
(
OUTPUT
"
${
SWIG_OPENMM_DIR
}
/OpenMM_headers.xml"
COMMAND
${
JAVA_RUNTIME
}
-jar
"
${
CMAKE_SOURCE_DIR
}
/wrappers/saxonb9-1-0-7j/saxon9.jar"
...
...
@@ -117,27 +117,27 @@ if(OPENMM_PYTHON_BUILD_SWIG)
DEPENDS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/xml/index.xml"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/xml/combine.xslt"
WORKING_DIRECTORY
"
${
SWIG_OPENMM_DIR
}
"
COMMENT
"Creating combined OpenMM API xml file..."
)
add_custom_target
(
CreateCombinedXmlFile DEPENDS
)
add_custom_target
(
CreateCombinedXmlFile DEPENDS
"
${
SWIG_OPENMM_DIR
}
/OpenMM_headers.xml"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/xml/index.xml"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/xml/combine.xslt"
${
CMAKE_CURRENT_BINARY_DIR
}
/src/swig_doxygen/doxygen/Doxyfile
)
# OpenMM REFERENCE platform first
# OpenMM REFERENCE platform first
# Files which will be created by python script and used by swig (dynamically generated)
set
(
SWIG_INPUT_FILES_REF
# Files which will be created by python script and used by swig (dynamically generated)
set
(
SWIG_INPUT_FILES_REF
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/pythonprepend.i"
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/pythonappend.i"
"
${
SWIG_OPENMM_DIR
}
/OpenMM_docstring.i"
"
${
SWIG_OPENMM_DIR
}
/OpenMM_headers.i"
# "${SWIG_OPENMM_DIR}/OpenMM.i"
)
)
# Swig input files which should have been copied from source tree
# file(GLOB SWIG_INPUT_FILES2 "${SWIG_OPENMM_DIR}/swig_lib/python/*.i")
set
(
SWIG_INPUT_FILES2
# Swig input files which should have been copied from source tree
# file(GLOB SWIG_INPUT_FILES2 "${SWIG_OPENMM_DIR}/swig_lib/python/*.i")
set
(
SWIG_INPUT_FILES2
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/exceptions.i"
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/extend.i"
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/features.i"
...
...
@@ -145,10 +145,10 @@ if(OPENMM_PYTHON_BUILD_SWIG)
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/pythoncode.i"
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/typemaps.i"
"
${
SWIG_OPENMM_DIR
}
/swig_lib/python/pythonprepend_all.i"
)
)
# Create input files for swig
add_custom_command
(
# Create input files for swig
add_custom_command
(
OUTPUT
${
SWIG_INPUT_FILES_REF
}
COMMAND
${
PYTHON_EXECUTABLE
}
"
${
SWIG_OPENMM_DIR
}
/swigInputBuilder.py"
-i OpenMM_headers.xml
...
...
@@ -163,15 +163,15 @@ if(OPENMM_PYTHON_BUILD_SWIG)
"
${
SWIG_OPENMM_DIR
}
/swigInputBuilder.py"
"
${
SWIG_OPENMM_DIR
}
/OpenMM_headers.xml"
COMMENT
"Creating OpenMM Python swig input files..."
)
)
#~ swig -python -c++ \
#~ -outdir $PYTHON_PACKAGE_DIR \
#~ -o OpenMMSwig.cxx \
#~ OpenMM.i
#~ swig -python -c++ \
#~ -outdir $PYTHON_PACKAGE_DIR \
#~ -o OpenMMSwig.cxx \
#~ OpenMM.i
# Run swig
add_custom_command
(
# Run swig
add_custom_command
(
OUTPUT
"
${
SWIG_OPENMM_DIR
}
/OpenMMSwig.cxx"
"
${
OPENMM_PYTHON_STAGING_DIR
}
/simtk/openmm/openmm.py"
COMMAND
${
SWIG_EXECUTABLE
}
-python -c++
...
...
@@ -184,17 +184,14 @@ if(OPENMM_PYTHON_BUILD_SWIG)
${
SWIG_INPUT_FILES_REF
}
${
SWIG_INPUT_FILES2
}
COMMENT
"Creating OpenMM Python module sources with swig..."
)
add_custom_target
(
RunSwig DEPENDS
)
add_custom_target
(
RunSwig DEPENDS
"
${
SWIG_OPENMM_DIR
}
/OpenMMSwig.cxx"
"
${
OPENMM_PYTHON_STAGING_DIR
}
/simtk/openmm/openmm.py"
)
set
(
STAGING_OUTPUT_FILES
${
STAGING_OUTPUT_FILES
}
set
(
STAGING_OUTPUT_FILES
${
STAGING_OUTPUT_FILES
}
"
${
OPENMM_PYTHON_STAGING_DIR
}
/src/swig_doxygen/OpenMMSwig.cxx"
"
${
OPENMM_PYTHON_STAGING_DIR
}
/simtk/openmm/openmm.py"
)
else
(
OPENMM_PYTHON_BUILD_SWIG
)
add_custom_target
(
RunSwig
)
endif
(
OPENMM_PYTHON_BUILD_SWIG
)
##################################################################################################
### Make a list of all folders containing include files the wrappers must be compiled against. ###
...
...
wrappers/python/README.txt
deleted
100644 → 0
View file @
1a50d0c1
===========================================
PyOpenMM: Python wrappers for OpenMM
===========================================
URL: https://simtk.org/home/pyopenmm
PyOpenMM is a python API that allows access to OpenMM, which is a library
that provides tools for performing GPU accelerated molecular simulations.
See the OpenMM project home page for more details:
https://simtk.org/home/openmm
Note that you do *not* need to download the OpenMM package. This
package includes all requried OpenMM libraries for Windows, Mac OS X,
Linux, and 64 bit Linux. However, if you wish to make use of the
GPU acceleration, you will need to have a supported GPU, and you will
need to install the associated CUDA Toolkit and drivers.
INTENDED AUDIENCE:
This README is intended for people who downloaded the PyOpenMM package
from the simtk.org website.
ADVANCED USERS:
if you are building or installing your own OpenMM libraries, you will also
need to rebuild the python wrappers. Note that most users will not
need (or want) to do this. If you really do need to rebuild the python
wrappers, change to the following subdirectory and read its README.txt file,
then return here to finish the installation:
cd src/swig_doxygen
REQUIREMENTS
1) Python 2.6 (Pythons 2.4 and 2.5 no longer supported; Python 2.7 might work)
2) One of the OS types supported by OpenMM:
a) Windows XP or better
b) Mac Leopard
c) Snow Leopard, assuming 32-bit python. See the README_MAC_64bit.txt file.
d) Linux (we test using CentOS 5, but others also should work)
e) Linux64 (we test using CentOS 5, but others should work)
3) A C/C++ compiler.
a) For Windows, we suggest Visual Studio 2008
b) For Mac Leopard and Snow Leopard, you may need to install Apple's Xcode
development environment (this will install otool and install_name_tool
which might also be needed).
c) For Linux, we use gcc-c++ 4.1
INSTALL
First unzip the package, change to the new directory, and run
the following two commands from a command line:
python setup.py build
python setup.py install
TEST INSTALL
Next run the following test to see if the install worked (it
should report "OK"):
python test/test_openmm.py
This should return "OK"
USING A GPU
If you would like to make use of OpenMM's GPU acceleration, you
will have to have one of the supported GPU's, and you will need
to install the Cuda libraries. To download the Cuda libraries,
check the NVIDIA website (try
http://www.nvidia.com/object/cuda_get.html).
For more help, see the OpenMM discussion forums at the following URL:
https://simtk.org/forum/?group_id=161)
Once the Cuda librareis are installed, python may need help finding
them. One easy way to do this on Unix type machines is to set the
LD_LIBRARY_PATH to point to the Cuda installation.
On my Bash system, I could do the following at the command line:
export LD_LIBRARY_PATH=/usr/local/cuda/lib
On a windows machine, adding the Cuda installation path to
your system PATH variable should work.
After installing you may need to reboot.
TEST GPU
If you have a GPU, run the following to see if PyOpenMM is accessing it:
python scripts/pluginLoadingCheck.py
If you do not have a GPU, or it is not found, you should get the following:
OpenMM found no plugins
If you have a GPU and it's found, you will see a list of GPU libraries that
have been loaded. For example, on my system I see the following:
OpenMM loaded the following plugin(s)
$PYTHONPATH/simtk/chem/OpenMM/plugins/libOpenMMCuda.so
If you are unable to load the GPU (Cuda) plugins, check that you installed
the Cuda drivers and Toolkit correctly.
PYOPENMM USAGE EXAMPLES
Once you have tested the installation, switch to the example
directory (cd examples), and try running one of the simulations.
For example, run the argon simulation by changing to the examples/argon
directory and typing the following:
python runArgon.py argon.pdb
If all goes well, this will produce a PDB formatted file called argon.pdb,
which can be visualized using a program such as VMD.
FEEDBACK
Please address all comments, criticisms, suggestions, etc to one of us:
Mark Friedrichs at friedrim@stanford.edu
Peter Eastman at cmbruns@stanford.edu
Randy Radmer at radmer@stanford.edu
wrappers/python/pysetup.cmake.in
View file @
2c39cb5e
set(ENV{OPENMM_INCLUDE_PATH} "@WRAPPER_INCLUDE_DIRS@")
file(TO_NATIVE_PATH "@
CMAKE_BINARY_DIR@
" OPENMM_LIB_PATH)
file(TO_NATIVE_PATH "@
OPENMM_INSTALL_PREFIX@/lib
" OPENMM_LIB_PATH)
set(ENV{OPENMM_LIB_PATH} "${OPENMM_LIB_PATH}")
message("OPENMM_LIB_PATH = " $ENV{OPENMM_LIB_PATH})
message("OPENMM_INCLUDE_PATH = " $ENV{OPENMM_INCLUDE_PATH})
...
...
wrappers/python/src/swig_doxygen/OpenMMSwig.cxx
deleted
100644 → 0
View file @
1a50d0c1
This diff is collapsed.
Click to expand it.
wrappers/python/src/swig_doxygen/README.txt
deleted
100644 → 0
View file @
1a50d0c1
This swig based, wrapper code only works from a Bash shell.
You *must* have the following installed:
1) Python 2.5 or 2.6
2) swig 2.0.0 or better (earlier versions are likely to fail)
3) Some type of XSLT processor (xsltproc, saxon, etc)
4) Doxygen (tested with version 1.4.7, but others should also work)
5) py-dom-xpath (tested with version 0.1, but others should also work):
http://code.google.com/p/py-dom-xpath
To build the wrapper codes, the following must be done
1) Run doxygen to generate xml files containing OpenMM API info (doxygen
uses the OpenMM header files to do this).
2) Run a python script that builds SWIG input files based on info in the
doxygen xml files
3) Run SWIG to generate python and C code that wraps the OpenMM libraries
We have created a single Bash script that does the full build for you.
But before running it, you must create and export environment variables
containing the OpenMM lib path (OPENMM_LIB_PATH) and the include directory
path (OPENMM_INCLUDE_PATH). The include directory should contain the "OpenMM.h"
file and an "openmm" directory. The lib directory should contain
the OpenMM dynamic library (OpenMM.dll, libOpenMM.so or libOpenMM.dylib) and
plugins. For example, when I build OpenMM on a Bash system, I set the
install dir to $HOME (in ccmake). Then I type the following two lines at
the command line:
export OPENMM_LIB_PATH=$HOME/lib
export OPENMM_INCLUDE_PATH=$HOME/include
Next run the Bash build script as follows:
/bin/bash buildSwigWrapper.sh
You may need to edit this script to work on your system
If all went well, the wrapper code is now updated; cd ../.. and follow
instuctions for building the PyOpenMM libraries.
1. Edit swigInputConfig.py to add new classes, ...
2. Add template <class T> to XmlSerializer (serialize/deserialize)
class XmlSerializer {
public:
%apply std::ostream & OUTPUT { std::ostream & stream };
template <class T>static void serialize(const T *object, const std::string
&rootName, std::ostream &stream) ;
%clear std::ostream & stream;
%apply std::istream & OUTPUT { std::istream & stream };
template <class T>static T* deserialize(std::istream &stream) ;
%clear std::istream & stream;
};
wrappers/python/src/swig_doxygen/buildSwigWrapper.sh
deleted
100755 → 0
View file @
1a50d0c1
#!/bin/bash
rm
-f
*
.xml
rm
-f
OpenMM_headers
*
rm
-f
*
.cxx
SWIG_REV_FILE_OPENMM
=
RevisionNumber_OpenMM.txt
SWIG_REV_FILE_PYOPENMM
=
RevisionNumber_pyopenmm.txt
PYTHON_PACKAGE_DIR
=
../../simtk/openmm
if
[
-n
"
$OPENMM_SVN_PATH
"
]
;
then
SVN_INFO
=
$(
svn info
$OPENMM_SVN_PATH
2>/dev/null |
awk
'$0~/^Revision:/{print $2}'
)
if
[
-n
"
$SVN_INFO
"
]
;
then
echo
$SVN_INFO
>
|
$SWIG_REV_FILE_OPENMM
fi
fi
if
[
-z
"
$OPENMM_INCLUDE_PATH
"
]
;
then
OPENMM_INCLUDE_PATH
=
../../OpenMM/include
fi
SVN_INFO
=
$(
svn info 2>/dev/null |
awk
'$0~/^Revision:/{print $2}'
)
if
[
-n
"
$SVN_INFO
"
]
;
then
echo
$SVN_INFO
>
|
$SWIG_REV_FILE_PYOPENMM
fi
cd
doxygen
rm
-rf
xml/ html/
echo
"Calling doxygen >| doxygen.out 2>| doxygen.err"
doxygen
>
| doxygen.out 2>| doxygen.err
if
[
"
$?
"
-ne
"0"
]
;
then
echo
"ERROR: doxygen did not run"
echo
" See doxygen/doxygen.out and doxygen/doxygen.err!"
echo
"Exiting!"
exit
1
fi
cd
xml
echo
"Calling xsltproc combine.xslt index.xml >| ../../OpenMM_headers.xml"
xsltproc combine.xslt index.xml
>
| ../../OpenMM_headers.xml
cd
../../
#Build ref platform only
echo
"Calling swigInputBuilder.py -i OpenMM_headers.xml -c swigInputConfig.py -o OpenMM_headers.i -d OpenMM_docstring.i -a swig_lib/python/pythonprepend.i -z swig_lib/python/pythonappend.i "
python swigInputBuilder.py
-i
OpenMM_headers.xml
\
-c
swigInputConfig.py
\
-o
OpenMM_headers.i
\
-d
OpenMM_docstring.i
\
-a
swig_lib/python/pythonprepend.i
\
-z
swig_lib/python/pythonappend.i
\
>
| swigInputBuilder.out
USING_SWIG_VERSION
=
$(
swig
-version
|
awk
'/^SWIG Version/{print $3}'
)
USING_SWIG_VERSION_NUM
=
$(
echo
$USING_SWIG_VERSION
|
awk
-F
.
'{print 1000*(1000*$1+$2)+$3}'
)
if
((
$USING_SWIG_VERSION_NUM
< 2000000
))
;
then
echo
"ERROR: Using swig
$USING_SWIG_VERSION
. Must use 2.0.0 or better"
exit
1
fi
echo
"calling swig -python -c++ -Wall -outdir
$PYTHON_PACKAGE_DIR
-o OpenMMSwig.cxx OpenMM.i"
swig
-python
-c
++
-Wall
\
-outdir
$PYTHON_PACKAGE_DIR
\
-o
OpenMMSwig.cxx
\
OpenMM.i
echo
"Done: swig -python -c++
\n
"
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