-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
105 lines (91 loc) · 3.87 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
from setuptools import setup, find_packages
from setuptools.extension import Extension
# To use a consistent encoding
from codecs import open
from os import path
# https://stackoverflow.com/questions/2379898/make-distutils-look-for-numpy-header-files-in-the-correct-place
try:
from Cython.Distutils import build_ext as _build_ext
except:
# If we couldn't import Cython, use the normal setuptools
# and look for a pre-compiled .c file instead of a .pyx file
from setuptools.command.build_ext import build_ext as _build_ext
ext_modules = [Extension("lammps.core", sources=['lammps/core.cpp'], language='c++')]
else:
# If we successfully imported Cython, look for a .pyx file
ext_modules = [Extension("lammps.core", sources=['lammps/core.pyx'], language='c++')]
# https://stackoverflow.com/questions/2379898/make-distutils-look-for-numpy-header-files-in-the-correct-place
class build_ext(_build_ext):
"""needed to import numpy and mpi4py includes"""
def run(self):
import numpy
import mpi4py
# not sure if necissary
from configparser import ConfigParser
import os
lammps_config = ConfigParser()
# Give precedence to config file in user home config directory
if os.path.isfile(os.path.expanduser('~/.config/lammps-site.cfg')):
lammps_config.read(os.path.expanduser('~/.config/lammps-site.cfg'))
else:
lammps_config.read('lammps.cfg')
def config_to_list(key1, key2):
return [s.strip() for s in lammps_config.get(key1, key2).split(',')]
# Add mpi4py, numpy, and custom headers to include_dirs
self.include_dirs.extend([
numpy.get_include(),
mpi4py.get_include()
])
self.include_dirs.extend(config_to_list('lammps', 'lammps_include_dir'))
self.include_dirs.extend(config_to_list('mpi', 'mpi_include_dir'))
self.library_dirs.extend(config_to_list('lammps', 'lammps_library_dir'))
self.library_dirs.extend(config_to_list('mpi', 'mpi_library_dir'))
self.libraries.extend(config_to_list('lammps', 'lammps_library'))
self.libraries.extend(config_to_list('mpi', 'mpi_library'))
# Call original build_ext command
_build_ext.run(self)
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
version = '0.6.2'
setup(
name='lammps-cython',
version=version,
description='Pythonic Wrapper to LAMMPS using cython',
long_description=long_description,
long_description_content_type="text/markdown",
author='Christopher Ostrouchov',
author_email='[email protected]',
license="MIT",
classifiers=[
'Development Status :: 3 - Alpha',
'Natural Language :: English',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
url='https://github.com/costrouc/lammps-cython',
download_url='https://github.com/costrouc/lammps-cython/archive/v%s.zip' % version,
keywords=['lammps', 'molecular dynamics', 'cython', 'wrapper', 'mpi'],
cmdclass={'build_ext': build_ext},
ext_modules=ext_modules,
packages=find_packages(exclude=['docs', 'tests']),
entry_points={
'console_scripts': [
'pylammps=lammps.__main__:main'
]
},
setup_requires=['pytest-runner', 'setuptools>=38.6.0'],
tests_require=['pytest', 'pytest-cov'],
install_requires=['mpi4py', 'numpy'],
extras_require={
'all': ['pymatgen', 'ase', 'gsd'],
'docs': ['sphinx', 'sphinx-rtd-theme'],
'pymatgen': 'pymatgen',
'ase': 'ase',
'gsd': 'gsd'
}
)