forked from mosdef-hub/mbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·166 lines (145 loc) · 5.64 KB
/
setup.py
File metadata and controls
executable file
·166 lines (145 loc) · 5.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"""mBuild: A hierarchical, component based molecule builder
With just a few lines of mBuild code, you can assemble reusable components into
complex molecular systems for molecular dynamics simulations. mBuild is
designed to minimize or even eliminate the need to explicitly translate and
orient components when building systems: you simply tell it to connect two
pieces! mBuild also keeps track of the system's topology so you don't have to
worry about manually defining bonds when constructing chemically bonded
structures from smaller components.
"""
import os
import subprocess
from pathlib import Path
from setuptools import setup, find_packages
from distutils.spawn import find_executable
#####################################
NAME = 'mbuild'
VERSION = "0.10.5"
ISRELEASED = True
if ISRELEASED:
__version__ = VERSION
else:
__version__ = VERSION + '.dev0'
#####################################
def git_version():
# Return the git revision as a string
# copied from numpy setup.py
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
out = subprocess.Popen(
cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
return out
try:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
GIT_REVISION = out.strip().decode('ascii')
except OSError:
GIT_REVISION = 'Unknown'
return GIT_REVISION
def write_version_py(version, isreleased, filename):
cnt = """
# This file is generated in setup.py at build time.
version = '{version}'
short_version = '{short_version}'
full_version = '{full_version}'
git_revision = '{git_revision}'
release = {release}
"""
base_path = Path(__file__).parent
file_path = (base_path / filename)
# git_revision
if os.path.exists('.git'):
git_revision = git_version()
else:
git_revision = 'Unknown'
# short_version, full_version
if isreleased:
full_version = version
short_version = version
else:
full_version = ("{version}+{git_revision}"
.format(version=version, git_revision=git_revision))
short_version = version
with file_path.open('w') as f:
f.write(cnt.format(version=version,
short_version=short_version,
full_version=full_version,
git_revision=git_revision,
release=isreleased))
def proto_procedure():
# Find the Protocol Compiler and compile protocol buffers
# Taken from https://github.com/protocolbuffers/protobuf/blob/fcfc47d405113b59bd43c2e54daf5d9fe5c44593/python/setup.py
# Only compile if a protocompiler is found, otherwise don't do anything
if 'PROTOC' in os.environ and os.path.exists(os.environ['PROTOC']):
protoc = os.environ['PROTOC']
elif os.path.exists("../src/protoc"):
protoc = "../src/protoc"
elif os.path.exists("../src/protoc.exe"):
protoc = "../src/protoc.exe"
elif os.path.exists("../vsprojects/Debug/protoc.exe"):
protoc = "../vsprojects/Debug/protoc.exe"
elif os.path.exists("../vsprojects/Release/protoc.exe"):
protoc = "../vsprojects/Release/protoc.exe"
else:
protoc = find_executable("protoc")
if protoc is None:
protoc = find_executable("protoc.exe")
if protoc is not None:
compile_proto(protoc)
def compile_proto(protoc):
protoc_command = [protoc, '-I=mbuild/formats/',
'--python_out=mbuild/formats/', 'compound.proto']
subprocess.call(protoc_command)
if __name__ == '__main__':
write_version_py(VERSION, ISRELEASED, 'mbuild/version.py')
proto_procedure()
setup(
name=NAME,
version=__version__,
description=__doc__.split('\n'),
long_description=__doc__,
author='Janos Sallai, Christoph Klein',
author_email='janos.sallai@vanderbilt.edu, christoph.klein@vanderbilt.edu',
url='https://github.com/mosdef-hub/mbuild',
download_url='https://github.com/mosdef-hub/mbuild/tarball/{}'.format(__version__),
packages=find_packages(),
package_data={'mbuild': ['utils/reference/*.{pdb,mol2}',
'lib/*.{pdb,mol2}',
]},
entry_points={
'mbuild.plugins':[
"Alkane = mbuild.lib.recipes.alkane:Alkane",
"Monolayer = mbuild.lib.recipes.monolayer:Monolayer",
"Polymer = mbuild.lib.recipes.polymer:Polymer",
"SilicaInterface = mbuild.lib.recipes.silica_interface:SilicaInterface",
"TiledCompound = mbuild.lib.recipes.tiled_compound:TiledCompound",
]
},
package_dir={'mbuild': 'mbuild'},
include_package_data=True,
license="MIT",
zip_safe=False,
keywords='mbuild',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Topic :: Scientific/Engineering :: Chemistry',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX',
'Operating System :: Unix',
'Operating System :: MacOS',
],
)