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
509373c6
Commit
509373c6
authored
Aug 01, 2013
by
Robert McGibbon
Browse files
create a simtk.openmm.version module that contains the git revision
parent
52c444c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
4 deletions
+75
-4
wrappers/python/CMakeLists.txt
wrappers/python/CMakeLists.txt
+16
-0
wrappers/python/setup.py
wrappers/python/setup.py
+59
-4
No files found.
wrappers/python/CMakeLists.txt
View file @
509373c6
...
@@ -24,6 +24,22 @@ file(GLOB STAGING_INPUT_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
...
@@ -24,6 +24,22 @@ file(GLOB STAGING_INPUT_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/*.py"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/*.py"
)
)
###########################################################
### Check the git revision of the source, and write it ###
### to a python file in the in the staging directory ###
###########################################################
execute_process
(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY
"
${
CMAKE_SOURCE_DIR
}
"
OUTPUT_VARIABLE rev_hash_str
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
if
(
NOT rev_hash_str
)
set
(
rev_hash_str
"'Unknown'"
)
endif
()
file
(
WRITE
"
${
OPENMM_PYTHON_STAGING_DIR
}
/simtk/openmm/version.py"
"git_revision = '
${
rev_hash_str
}
'
\n
"
)
# file(GLOB_RECURSE temp RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/src/*.i")
# file(GLOB_RECURSE temp RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/src/*.i")
# foreach(f ${temp})
# foreach(f ${temp})
# set(temp2 "${temp2}\n${f}")
# set(temp2 "${temp2}\n${f}")
...
...
wrappers/python/setup.py
View file @
509373c6
...
@@ -6,15 +6,18 @@ setup.py: Used for building python wrappers for Simbios' OpenMM library.
...
@@ -6,15 +6,18 @@ setup.py: Used for building python wrappers for Simbios' OpenMM library.
__author__
=
"Randall J. Radmer"
__author__
=
"Randall J. Radmer"
__version__
=
"1.0"
__version__
=
"1.0"
import
ast
import
os
,
sys
,
platform
,
glob
,
shutil
import
re
import
struct
import
os
import
sys
import
platform
from
distutils.core
import
setup
from
distutils.core
import
setup
MAJOR_VERSION_NUM
=
'5'
MAJOR_VERSION_NUM
=
'5'
MINOR_VERSION_NUM
=
'1'
MINOR_VERSION_NUM
=
'1'
BUILD_INFO
=
'0'
BUILD_INFO
=
'0'
IS_RELEASED
=
False
def
reportError
(
message
):
def
reportError
(
message
):
sys
.
stdout
.
write
(
"ERROR: "
)
sys
.
stdout
.
write
(
"ERROR: "
)
...
@@ -64,6 +67,57 @@ def uninstall(verbose=True):
...
@@ -64,6 +67,57 @@ def uninstall(verbose=True):
sys
.
path
=
save_path
sys
.
path
=
save_path
def
write_version_py
(
filename
=
"simtk/openmm/version.py"
,
major_version_num
=
MAJOR_VERSION_NUM
,
minor_version_num
=
MINOR_VERSION_NUM
,
build_info
=
BUILD_INFO
):
"""Write a version.py file into the python source directory before installation.
If a version.py file already exists, we assume that it contains only the git_revision
information, since from within this python session in the python staging directory, we're
not in the version controlled directory hierarchy.
When cmake is copying files into the PYTHON_STAGING_DIRECTORY, it will write the
git revision to version.py. We read that, and then overwrite it.
"""
cnt
=
"""
# THIS FILE IS GENERATED FROM OPENMM SETUP.PY
short_version = '%(version)s'
version = '%(version)s'
full_version = '%(full_version)s'
git_revision = '%(git_revision)s'
release = %(isrelease)s
if not release:
version = full_version
"""
if
os
.
path
.
exists
(
filename
):
# git_revision is written to the file by cmake
with
open
(
filename
)
as
f
:
text
=
f
.
read
()
match
=
re
.
search
(
r
"git_revision\s+=\s+(.*)"
,
text
,
re
.
MULTILINE
)
try
:
git_revision
=
ast
.
literal_eval
(
match
.
group
(
1
))
except
:
# except anything, including no re match or
# literal_eval failing
git_revision
=
'Unknown'
else
:
git_revision
=
'Unknown'
version
=
full_version
=
'%s.%s.%s'
%
(
major_version_num
,
minor_version_num
,
build_info
)
if
not
IS_RELEASED
:
full_version
+=
'.dev-'
+
git_revision
[:
7
]
a
=
open
(
filename
,
'w'
)
try
:
a
.
write
(
cnt
%
{
'version'
:
version
,
'full_version'
:
full_version
,
'git_revision'
:
git_revision
,
'isrelease'
:
str
(
IS_RELEASED
)})
finally
:
a
.
close
()
def
buildKeywordDictionary
(
major_version_num
=
MAJOR_VERSION_NUM
,
def
buildKeywordDictionary
(
major_version_num
=
MAJOR_VERSION_NUM
,
minor_version_num
=
MINOR_VERSION_NUM
,
minor_version_num
=
MINOR_VERSION_NUM
,
build_info
=
BUILD_INFO
):
build_info
=
BUILD_INFO
):
...
@@ -184,6 +238,7 @@ def main():
...
@@ -184,6 +238,7 @@ def main():
uninstall
()
uninstall
()
except
:
except
:
pass
pass
write_version_py
()
setupKeywords
=
buildKeywordDictionary
()
setupKeywords
=
buildKeywordDictionary
()
setup
(
**
setupKeywords
)
setup
(
**
setupKeywords
)
...
...
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