forked from ParmEd/ParmEd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
113 lines (100 loc) · 4.33 KB
/
setup.py
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
from distutils.core import setup, Extension
import os
import sys
if sys.version_info < (2, 7):
sys.stderr.write('You must have at least Python 2.7 for ParmEd to work '
'correctly.\n')
sys.exit(0)
is_pypy = '__pypy__' in sys.builtin_module_names
# parmed package and all its subpackages
packages = ['parmed', 'parmed.amber', 'parmed.modeller',
'parmed.tinker', 'parmed.unit', 'parmed.amber.mdin',
'parmed.charmm', 'parmed.formats.pdbx', 'parmed.rosetta',
'parmed.formats', 'parmed.utils.fortranformat', 'parmed.openmm',
'parmed.utils', 'parmed.gromacs', 'parmed.tools',
'parmed.tools.gui', 'parmed.tools.simulations']
# Optimized readparm
if is_pypy:
sources = depends = include_dirs = extensions = []
else:
sources = [os.path.join('src', '_rdparm.cpp'),
os.path.join('src', 'readparm.cpp')]
depends = [os.path.join('src', 'CompatabilityMacros.h'),
os.path.join('src', 'readparm.h')]
include_dirs = [os.path.join(os.path.abspath('.'), 'src')]
extensions = [Extension('parmed.amber._rdparm',
sources=sources,
include_dirs=include_dirs,
depends=depends)
]
if __name__ == '__main__':
from distutils.command.build_py import build_py
from distutils.command.build_scripts import build_scripts
import shutil
import parmed
# See if we have the Python development headers. If not, don't build the
# optimized prmtop parser extension
from distutils import sysconfig
if is_pypy or not os.path.exists(
os.path.join(sysconfig.get_config_vars()['INCLUDEPY'], 'Python.h')):
extensions = []
# Delete old versions with old names of scripts and packages (chemistry and
# ParmedTools for packages, parmed.py and xparmed.py for scripts)
def deldir(folder):
try:
shutil.rmtree(folder)
except OSError:
sys.stderr.write(
'Could not remove old package %s; you should make sure\n'
'this is completely removed in order to make sure you\n'
'do not accidentally use the old version of ParmEd\n' %
folder
)
def delfile(file):
try:
os.unlink(file)
except OSError:
sys.stderr.write(
'Could not remove old script %s; you should make sure\n'
'this is completely removed in order to make sure you\n'
'do not accidentally use the old version of ParmEd\n' %
file
)
for folder in sys.path:
folder = os.path.realpath(os.path.abspath(folder))
if folder == os.path.realpath(os.path.abspath('.')): continue
chem = os.path.join(folder, 'chemistry')
pmdtools = os.path.join(folder, 'ParmedTools')
pmd = os.path.join(folder, 'parmed.py')
xpmd = os.path.join(folder, 'xparmed.py')
pmdc = os.path.join(folder, 'parmed.pyc')
xpmdc = os.path.join(folder, 'xparmed.pyc')
if os.path.isdir(chem): deldir(chem)
if os.path.isdir(pmdtools): deldir(pmdtools)
if os.path.exists(pmd): delfile(pmd)
if os.path.exists(xpmd): delfile(xpmd)
if os.path.exists(pmdc): delfile(pmdc)
if os.path.exists(xpmdc): delfile(xpmdc)
for folder in os.getenv('PATH').split(os.pathsep):
pmd = os.path.join(folder, 'parmed.py')
xpmd = os.path.join(folder, 'xparmed.py')
pmdc = os.path.join(folder, 'parmed.pyc')
xpmdc = os.path.join(folder, 'xparmed.pyc')
if os.path.exists(pmd): delfile(pmd)
if os.path.exists(xpmd): delfile(xpmd)
if os.path.exists(pmdc): delfile(pmdc)
if os.path.exists(xpmdc): delfile(xpmdc)
scripts = [os.path.join('scripts', 'parmed'),
os.path.join('scripts', 'xparmed')]
setup(name='ParmEd',
version=parmed.__version__,
description='Amber parameter file editor',
author='Jason Swails',
author_email='jason.swails -at- gmail.com',
url='http://jswails.wikidot.com/parmed',
license='GPL v2 or later',
packages=packages,
ext_modules=extensions,
cmdclass={'build_py' : build_py},
scripts=scripts,
)