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*.
|
||||
|
||||
#### Manual setup
|
||||
#### Through package manager
|
||||
|
||||
The shared library of GROMACS 5.1and the corresponding c++ header files need to be present on the system.
|
||||
If the shared library is installed globally, the environment variable `LD_LIBRARY_PATH` must be set.
|
||||
The installation process will look for the header files by replacing any `lib` folder
|
||||
in `LD_LIBRARY_PATH` with `include`.
|
||||
Pygmx requires the shared library and header files of Gromacs 5.1 or higher to be installed.
|
||||
On many Unix distributions Gromacs may be installed through the package manager.
|
||||
The required packages, which provide the headers, are usually named `gromacs-devel` or `gromcas-dev`.
|
||||
|
||||
If no header files are present, simply pull the submodule `gromacs` in this repository.
|
||||
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).
|
||||
#### Manual build
|
||||
|
||||
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
|
||||
|
||||
@ -40,13 +42,3 @@ Navigate to the top folder of the repository and run the command
|
||||
python setup.py install
|
||||
|
||||
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
|
||||
|
||||
|
||||
def locate_lib(directory, lib):
|
||||
flib = 'lib{}.so'.format(lib)
|
||||
for root, dirs, files in os.walk(directory):
|
||||
if flib in files:
|
||||
return root
|
||||
def check_header_version(include_path):
|
||||
with open(os.path.join(include_path, 'version.h')) as f:
|
||||
for l in f.readlines():
|
||||
if '#define GMX_API_VERSION' in l:
|
||||
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']
|
||||
library_dirs = []
|
||||
if 'LD_LIBRARY_PATH' in os.environ:
|
||||
lib = os.environ['LD_LIBRARY_PATH'].split(':')[0]
|
||||
library_dirs.insert(0, locate_lib(lib, 'gromacs'))
|
||||
include = lib.replace('/lib', '/include')
|
||||
if 'gromacs' in os.environ.get('LD_LIBRARY_PATH', ''):
|
||||
for p in os.environ['LD_LIBRARY_PATH'].split(':'):
|
||||
if 'gromacs' in p:
|
||||
lib = p
|
||||
gmx_root = lib.split('lib')[0]
|
||||
include = os.path.join(gmx_root, 'include')
|
||||
if os.path.exists(include):
|
||||
include_dirs.insert(0, include)
|
||||
elif os.path.exists('gromacs/build/lib'):
|
||||
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]
|
||||
|
||||
include_dirs.append(include)
|
||||
check_header_version(include)
|
||||
|
||||
extensions = [
|
||||
Extension('pygmx.gromacs.coordinates', [
|
||||
'pygmx/gromacs/coordinates.pyx'], include_dirs=include_dirs),
|
||||
Extension('pygmx.gromacs.logarithmic', [
|
||||
'pygmx/gromacs/logarithmic.pyx'], include_dirs=include_dirs),
|
||||
Extension('pygmx.tpxio',
|
||||
sources=['pygmx/tpxio.pyx'],
|
||||
include_dirs=include_dirs,
|
||||
libraries=['gromacs'],
|
||||
library_dirs=library_dirs,
|
||||
runtime_library_dirs=library_dirs,
|
||||
language='c++'),
|
||||
Extension('pygmx.xtcio',
|
||||
sources=['pygmx/xtcio.pyx'],
|
||||
include_dirs=include_dirs,
|
||||
libraries=['gromacs'],
|
||||
library_dirs=library_dirs,
|
||||
runtime_library_dirs=library_dirs,
|
||||
language='c++'),
|
||||
Extension(
|
||||
'pygmx.gromacs.coordinates',
|
||||
['pygmx/gromacs/coordinates.pyx'],
|
||||
include_dirs=include_dirs
|
||||
),
|
||||
Extension(
|
||||
'pygmx.gromacs.logarithmic',
|
||||
['pygmx/gromacs/logarithmic.pyx'],
|
||||
include_dirs=include_dirs
|
||||
),
|
||||
Extension(
|
||||
'pygmx.tpxio',
|
||||
sources=['pygmx/tpxio.pyx'],
|
||||
include_dirs=include_dirs,
|
||||
libraries=['gromacs'],
|
||||
language='c++'
|
||||
),
|
||||
Extension(
|
||||
'pygmx.xtcio',
|
||||
sources=['pygmx/xtcio.pyx'],
|
||||
include_dirs=include_dirs,
|
||||
libraries=['gromacs'],
|
||||
language='c++'
|
||||
),
|
||||
# Extension('pygmx.enxio',
|
||||
# sources=['pygmx/enxio.pyx'],
|
||||
# include_dirs=include_dirs,
|
||||
@ -69,12 +68,11 @@ extensions = [
|
||||
# runtime_library_dirs=library_dirs,
|
||||
#language='c++'
|
||||
# ),
|
||||
|
||||
]
|
||||
|
||||
setup(
|
||||
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',
|
||||
packages=['pygmx', 'pygmx.gromacs'],
|
||||
version='0.1',
|
||||
|
Reference in New Issue
Block a user