Cleaned up setup.py & Readme
This commit is contained in:
28
README.md
28
README.md
@ -21,16 +21,18 @@ If gromacs is installed as a module in your system, run
|
|||||||
|
|
||||||
and skip to the section *Installing pygmx*.
|
and skip to the section *Installing pygmx*.
|
||||||
|
|
||||||
#### Manual setup
|
#### Through package manager
|
||||||
|
|
||||||
The shared library of GROMACS 5.1and the corresponding c++ header files need to be present on the system.
|
Pygmx requires the shared library and header files of Gromacs 5.1 or higher to be installed.
|
||||||
If the shared library is installed globally, the environment variable `LD_LIBRARY_PATH` must be set.
|
On many Unix distributions Gromacs may be installed through the package manager.
|
||||||
The installation process will look for the header files by replacing any `lib` folder
|
The required packages, which provide the headers, are usually named `gromacs-devel` or `gromcas-dev`.
|
||||||
in `LD_LIBRARY_PATH` with `include`.
|
|
||||||
|
|
||||||
If no header files are present, simply pull the submodule `gromacs` in this repository.
|
#### Manual build
|
||||||
To build the shared library, follow the [official installation instructions](http://manual.gromacs.org/documentation/5.1.2/install-guide/index.html),
|
|
||||||
starting with step 4 (creating a build directory).
|
To build the shared library manually, follow the [official installation instructions](http://manual.gromacs.org/documentation/5.1.2/install-guide/index.html).
|
||||||
|
Make sure to source the `GMXRC` script, which sets the environment variable `LD_LIBRARY_PATH` to the correct location or set this variable manually.
|
||||||
|
Don't bother with advanced features like GPU support if the Gromacs installation will only be used for pygmx,
|
||||||
|
since the file io functions do not use these features.
|
||||||
|
|
||||||
### Installing pygmx
|
### Installing pygmx
|
||||||
|
|
||||||
@ -40,13 +42,3 @@ Navigate to the top folder of the repository and run the command
|
|||||||
python setup.py install
|
python setup.py install
|
||||||
|
|
||||||
This builds the cython modules and installs them into the local python distribution.
|
This builds the cython modules and installs them into the local python distribution.
|
||||||
|
|
||||||
|
|
||||||
### Deploy on intranet
|
|
||||||
|
|
||||||
For any installed version of mdevaluate modules do:
|
|
||||||
|
|
||||||
version=dev # or maybe: version=$(python ../mdevaluate/setup.py --version)
|
|
||||||
module load gromacs/5.1
|
|
||||||
module load mdevaluate/$version
|
|
||||||
python setup.py install --prefix=/autohome/niels/modules/mdevaluate-$version
|
|
||||||
|
88
setup.py
88
setup.py
@ -5,54 +5,53 @@ from Cython.Build import cythonize
|
|||||||
import numpy
|
import numpy
|
||||||
|
|
||||||
|
|
||||||
def locate_lib(directory, lib):
|
def check_header_version(include_path):
|
||||||
flib = 'lib{}.so'.format(lib)
|
with open(os.path.join(include_path, 'version.h')) as f:
|
||||||
for root, dirs, files in os.walk(directory):
|
for l in f.readlines():
|
||||||
if flib in files:
|
if '#define GMX_API_VERSION' in l:
|
||||||
return root
|
print(l)
|
||||||
|
version = int(l.split()[-1])
|
||||||
|
assert version >= 50100, 'Installed gromacs version is too low!'
|
||||||
|
return
|
||||||
|
print('Gromacs version could not be checked.')
|
||||||
|
|
||||||
|
include_dirs = [numpy.get_include()]
|
||||||
|
|
||||||
include_dirs = [numpy.get_include(), 'gromacs/src', 'gromacs/src/external/tng_io/include']
|
if 'gromacs' in os.environ.get('LD_LIBRARY_PATH', ''):
|
||||||
library_dirs = []
|
for p in os.environ['LD_LIBRARY_PATH'].split(':'):
|
||||||
if 'LD_LIBRARY_PATH' in os.environ:
|
if 'gromacs' in p:
|
||||||
lib = os.environ['LD_LIBRARY_PATH'].split(':')[0]
|
lib = p
|
||||||
library_dirs.insert(0, locate_lib(lib, 'gromacs'))
|
gmx_root = lib.split('lib')[0]
|
||||||
include = lib.replace('/lib', '/include')
|
include = os.path.join(gmx_root, 'include')
|
||||||
if os.path.exists(include):
|
if os.path.exists(include):
|
||||||
include_dirs.insert(0, include)
|
include_dirs.append(include)
|
||||||
elif os.path.exists('gromacs/build/lib'):
|
check_header_version(include)
|
||||||
library_dirs.insert(0, 'gromacs/build/lib')
|
|
||||||
|
|
||||||
if not library_dirs:
|
|
||||||
raise OSError("""
|
|
||||||
Gromacs library not found.
|
|
||||||
Activate a gromacs module or set environment variable LD_LIBRARY_PATH.
|
|
||||||
""")
|
|
||||||
|
|
||||||
library_dirs.append('gromacs/src/external/tng_io/build/lib')
|
|
||||||
|
|
||||||
library_dirs = [os.path.abspath(p) for p in library_dirs]
|
|
||||||
|
|
||||||
|
|
||||||
extensions = [
|
extensions = [
|
||||||
Extension('pygmx.gromacs.coordinates', [
|
Extension(
|
||||||
'pygmx/gromacs/coordinates.pyx'], include_dirs=include_dirs),
|
'pygmx.gromacs.coordinates',
|
||||||
Extension('pygmx.gromacs.logarithmic', [
|
['pygmx/gromacs/coordinates.pyx'],
|
||||||
'pygmx/gromacs/logarithmic.pyx'], include_dirs=include_dirs),
|
include_dirs=include_dirs
|
||||||
Extension('pygmx.tpxio',
|
),
|
||||||
sources=['pygmx/tpxio.pyx'],
|
Extension(
|
||||||
include_dirs=include_dirs,
|
'pygmx.gromacs.logarithmic',
|
||||||
libraries=['gromacs'],
|
['pygmx/gromacs/logarithmic.pyx'],
|
||||||
library_dirs=library_dirs,
|
include_dirs=include_dirs
|
||||||
runtime_library_dirs=library_dirs,
|
),
|
||||||
language='c++'),
|
Extension(
|
||||||
Extension('pygmx.xtcio',
|
'pygmx.tpxio',
|
||||||
sources=['pygmx/xtcio.pyx'],
|
sources=['pygmx/tpxio.pyx'],
|
||||||
include_dirs=include_dirs,
|
include_dirs=include_dirs,
|
||||||
libraries=['gromacs'],
|
libraries=['gromacs'],
|
||||||
library_dirs=library_dirs,
|
language='c++'
|
||||||
runtime_library_dirs=library_dirs,
|
),
|
||||||
language='c++'),
|
Extension(
|
||||||
|
'pygmx.xtcio',
|
||||||
|
sources=['pygmx/xtcio.pyx'],
|
||||||
|
include_dirs=include_dirs,
|
||||||
|
libraries=['gromacs'],
|
||||||
|
language='c++'
|
||||||
|
),
|
||||||
# Extension('pygmx.enxio',
|
# Extension('pygmx.enxio',
|
||||||
# sources=['pygmx/enxio.pyx'],
|
# sources=['pygmx/enxio.pyx'],
|
||||||
# include_dirs=include_dirs,
|
# include_dirs=include_dirs,
|
||||||
@ -69,12 +68,11 @@ extensions = [
|
|||||||
# runtime_library_dirs=library_dirs,
|
# runtime_library_dirs=library_dirs,
|
||||||
#language='c++'
|
#language='c++'
|
||||||
# ),
|
# ),
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='pygmx',
|
name='pygmx',
|
||||||
description='Python wrapper for gromacs library.',
|
description='Python wrapper around the gromacs library for file io.',
|
||||||
author_email='niels.mueller@physik.tu-darmstadt.de',
|
author_email='niels.mueller@physik.tu-darmstadt.de',
|
||||||
packages=['pygmx', 'pygmx.gromacs'],
|
packages=['pygmx', 'pygmx.gromacs'],
|
||||||
version='0.1',
|
version='0.1',
|
||||||
|
Reference in New Issue
Block a user