Skip to content

Commit

Permalink
ADD: made package ready for PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
arose committed Nov 20, 2015
1 parent 2946d24 commit ba3feb7
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 33 deletions.
6 changes: 6 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
global-include *.c
global-include *.h
include MDAnalysis/coordinates/xdrfile/src/*
include LICENSE
include setup.py
global-exclude *.pyc
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@


Lightweight coordinate-only trajectory reader based on code from [GROMACS](http://www.gromacs.org/), [MDAnalysis](http://www.mdanalysis.org/) and [VMD](http://www.ks.uiuc.edu/Research/vmd/).

Used for coordinate retrieval in [MDSrv](https://github.com/arose/mdsrv) and [nglview](https://github.com/arose/nglview).

Should work with Python 2 and 3. If you experience problems, please file an [issue](https://github.com/arose/simpletraj/issues).


Installation
============

From PyPI:

pip install simpletraj


netCDF4
-------

Some libraries need to be installed. First, make sure you have the Python development files installed, e.g.
If you use `conda` as your Python package manager:

sudo apt-get install python-dev python-numpy
conda install netcdf4


Then install the NetCDF libraries and its Python package
To install the NetCDF libraries and its Python package on debian/ubuntu:

sudo apt-get install libhdf5-serial-dev libnetcdf-dev
sudo pip install netCDF4
pip install netCDF4


In case you get "ValueError: did not find HDF5 headers" try:
Expand All @@ -29,18 +37,13 @@ In case you get "ValueError: did not find HDF5 headers" try:
pip install netCDF4


Finally install simpletraj itself:

sudo python setup.py install


Changelog
=========

Version 0.2dev
--------------

* WIP: preparing packaging
* ADD: package ready for PyPI
* CODE: Python 3 compatibility
* CODE: handle errors during offsets file reading/writing

Expand Down
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
103 changes: 81 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,84 @@
#!/usr/bin/env python

"""
Setup script for trajectory file reading modules.
import sys
from setuptools import setup, Extension, find_packages

A working installation of NumPy <http://numpy.scipy.org> is required.

For a basic installation just type the command::
VERSION = "0.2.dev4"
CLASSIFIERS = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
"Programming Language :: C",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Chemistry",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX",
"Operating System :: Unix",
"Operating System :: MacOS",
]

python setup.py build_ext --inplace

Based on setup.py from MDAnalysis:
# from MDAnalysis setup.py (http://www.mdanalysis.org/)
class NumpyExtension(Extension, object):
"""Derived class to cleanly handle setup-time (numpy) dependencies.
"""
# The only setup-time numpy dependency comes when setting up its
# include dir.
# The actual numpy import and call can be delayed until after pip
# has figured it must install numpy.
# This is accomplished by passing the get_numpy_include function
# as one of the include_dirs. This derived Extension class takes
# care of calling it when needed.
def __init__(self, *args, **kwargs):
self._np_include_dirs = []
super(NumpyExtension, self).__init__(*args, **kwargs)

http://www.mdanalysis.org/
"""
@property
def include_dirs(self):
if not self._np_include_dirs:
for item in self._np_include_dir_args:
try:
self._np_include_dirs.append(item()) # The numpy callable
except TypeError:
self._np_include_dirs.append(item)
return self._np_include_dirs

@include_dirs.setter
def include_dirs(self, val):
self._np_include_dir_args = val

from setuptools import setup, Extension

import numpy
try:
numpy_include = numpy.get_include()
except AttributeError:
numpy_include = numpy.get_numpy_include()
include_dirs = [ numpy_include ]
# from MDAnalysis setup.py (http://www.mdanalysis.org/)
def get_numpy_include():
try:
# Obtain the numpy include directory. This logic works across numpy
# versions.
# setuptools forgets to unset numpy's setup flag and we get a crippled
# version of it unless we do it ourselves.
try:
import __builtin__ # py2
__builtin__.__NUMPY_SETUP__ = False
except:
import builtins # py3
builtins.__NUMPY_SETUP__ = False
import numpy as np
except ImportError as e:
print(e)
print('*** package "numpy" not found ***')
print('Simpletraj requires a version of NumPy, even for setup.')
print('Please get it from http://numpy.scipy.org/ or install it through '
'your package manager.')
sys.exit(-1)
try:
numpy_include = np.get_include()
except AttributeError:
numpy_include = np.get_numpy_include()
return numpy_include


# Needed for large-file seeking under 32bit systems (for xtc/trr indexing and access).
Expand All @@ -36,29 +92,32 @@
setup(
name = "simpletraj",
author = "Alexander S. Rose",
description = "Simple coordinate-only trajectory reader based on code from GROMACS, MDAnalysis, VMD.",
version = "0.2dev",
author_email = "[email protected]",
description = "Lightweight coordinate-only trajectory reader based on code from GROMACS, MDAnalysis, VMD.",
version = VERSION,
classifiers = CLASSIFIERS,
license = "GPL2",
url = "https://github.com/arose/simpletraj",
packages = [ "simpletraj", "simpletraj.xdrfile", "simpletraj.dcd" ],
zip_safe = False,
packages = find_packages(),
ext_modules = [
Extension(
NumpyExtension(
"simpletraj/xdrfile._libxdrfile2",
sources = [
"simpletraj/xdrfile/libxdrfile2_wrap.c",
"simpletraj/xdrfile/xdrfile.c",
"simpletraj/xdrfile/xdrfile_trr.c",
"simpletraj/xdrfile/xdrfile_xtc.c"
],
include_dirs = include_dirs,
include_dirs = [ get_numpy_include ],
define_macros = largefile_macros
),
Extension(
NumpyExtension(
"simpletraj/dcd._dcdmodule",
sources = [
"simpletraj/dcd/dcd.c"
],
include_dirs = include_dirs + [ "simpletraj/dcd/include" ],
include_dirs = [ get_numpy_include, "simpletraj/dcd/include" ],
),
],
setup_requires = [ "numpy" ],
Expand Down

0 comments on commit ba3feb7

Please sign in to comment.