Commit 700f0420 authored by Berk Onat's avatar Berk Onat
Browse files

Pack all functions under OpenMolfile

parent 954ddf92
from __future__ import absolute_import
import warnings
try:
from .molfile import libpymolfile
except ImportError:
warnings.warn("libpymolfile package not available, pymolfile does not work without its library!")
from . import plugin_list
from . import pymolfile
__all__ = [ "pymolfile" ]
MAX_NUM_PLUGINS = 200
C_MOLFILE_PLUGINS = libpymolfile.molfile_plugin_list(MAX_NUM_PLUGINS)
MOLFILE_PLUGINS = pymolfile.plugins()
# Stand-alone python bindings for libvmdmolfile
# Stand-alone python bindings for libpymolfile
# Copyright (c) 2017 Berk Onat <b.onat@warwick.ac.uk>
# Published under the BSD LICENSE
# Published under the UIUC OpenSource LICENSE
"""libpymolfile library.
"""
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
swig -py3 -Wall -c++ -python libpymolfile.i
echo "'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'"
g++-7 -fPIC -Wall -Wextra -shared -g -Wunused-function -Wunused-parameter \
-I/labEnv3/lib/python3.6/site-packages/numpy/core/include/ \
-I./include \
-I./include/molfile_plugin/include \
-I./lib/molfile_plugin/lib \
-I./include/plugin_src/include \
-I./include/netcdf/include \
-I./include/expat/include \
-I./include/tng/include \
libpymolfile_wrap.cxx pymolfile.c -o _libpymolfile.so -L. \
-L./lib/molfile_plugin/lib \
-L./lib/netcdf/lib \
-L./lib/expat/lib \
-L./lib/tng/lib \
lib/molfile_plugin/lib/libmolfile_plugin.a -I/labEnv3/include/python3.6m/ \
-L/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib \
-lpython3.6 -lnetcdf
echo "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<"
#swig -py3 -Wall -c++ -python libpymolfile.i
swig -Wall -c++ -python libpymolfile.i
echo "'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'-._.-'"
g++-7 -fPIC -Wall -Wextra -Xlinker -export-dynamic -shared -g -Wunused-function -Wunused-parameter \
-I/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/ \
-I./include \
-I./include/molfile_plugin/include \
-I./lib/molfile_plugin/lib \
-I./include/plugin_src/include \
-I./include/netcdf/include \
-I./include/expat/include \
-I./include/tng/include \
libpymolfile_wrap.cxx pymolfile.c -o _libpymolfile.so -L. \
-L./lib/molfile_plugin/lib \
-L./lib/netcdf/lib \
-L./lib/expat/lib \
-L./lib/tng/lib \
lib/molfile_plugin/lib/libmolfile_plugin.a \
-I/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/include/python2.7/ \
-L/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib \
-lpython2.7 -ltng_io -lnetcdf -lexpat
......@@ -165,9 +165,10 @@ PyObject * my_close_file_read(PyObject* molpack) {
plugin = plugin_handle->plugin;
file_handle = plugin_handle->file_handle;
numatoms = plugin_handle->natoms;
plugin->close_file_read(file_handle);
Py_INCREF(plugin_handle);
plugin->close_file_read(file_handle);
Py_DECREF(plugin_handle);
Py_DECREF(molpack);
/*Py_DECREF(molpack);*/
Py_RETURN_NONE;
}
%}
......
......@@ -3445,9 +3445,10 @@ PyObject * my_close_file_read(PyObject* molpack) {
plugin = plugin_handle->plugin;
file_handle = plugin_handle->file_handle;
numatoms = plugin_handle->natoms;
plugin->close_file_read(file_handle);
Py_INCREF(plugin_handle);
plugin->close_file_read(file_handle);
Py_DECREF(plugin_handle);
Py_DECREF(molpack);
/*Py_DECREF(molpack);*/
Py_RETURN_NONE;
}
......
......@@ -61,7 +61,7 @@ void del_molfile_plugin_list(PyObject* molcapsule);
static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj)
{
void *ret = PyCapsule_GetPointer(obj, NULL);
void *ret = PyCapsule_GetPointer(obj, "plugin_handle");
if (ret == NULL) {
PyErr_Clear();
}
......@@ -70,7 +70,7 @@ static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj)
static PyObject * PyMolfileCapsule_FromVoidPtr(void *ptr, void (*destr)(PyObject *))
{
PyObject *ret = PyCapsule_New(ptr, NULL, destr);
PyObject *ret = PyCapsule_New(ptr, "plugin_handle", destr);
if (ret == NULL) {
PyErr_Clear();
}
......
......@@ -29,6 +29,8 @@ make-arch-help:
@echo " MACOSX"
@echo " MACOSXX86"
@echo " MACOSXX86_64"
@echo " MACOSXX86_64GCC"
@echo " MACOSXX86_64GCCTNG"
@echo " NETBSD"
@echo " OPENPOWER"
@echo " SOLARIS2"
......@@ -499,6 +501,27 @@ MACOSXX86_64:
"TCLSHLD = c++ -dynamiclib"
MACOSXX86_64GCC:
$(MAKE) dynlibs staticlibs bins \
"ARCH = MACOSXX86_64GCC" \
"COPTO = -m64 -fPIC -o " \
"LOPTO = -m64 -fPIC -o " \
"CC = gcc-7" \
"CXX = g++-7" \
"DEF = -D" \
"CCFLAGS = -m64 -Os -Wall -fPIC -dynamic" \
"CXXFLAGS = -m64 -Os -Wall -fPIC -dynamic" \
"TCLLDFLAGS = -ltcl8.5" \
"NETCDFLDFLAGS = -lnetcdf" \
"NETCDFLIB = -L/usr/local/Cellar/netcdf/4.4.1.1_6/lib " \
"NETCDFINC = -I/usr/local/Cellar/netcdf/4.4.1.1_6/include " \
"AR = ar" \
"NM = nm -p" \
"RANLIB = ranlib" \
"LIBTOOL = libtool -dynamic" \
"SHLD = g++-7 -shared" \
"TCLSHLD = g++-7 -dynamiclib"
MACOSXX86_64GCCTNG:
$(MAKE) dynlibs staticlibs bins \
"ARCH = MACOSXX86_64GCC" \
"COPTO = -m64 -fPIC -o " \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment