Commit d397d505 authored by Berk Onat's avatar Berk Onat
Browse files

First compiling version with setup.py without libmolfile_plugins.a

parent 291525d0
No preview for this file type
......@@ -10,7 +10,7 @@ g++-7 -fPIC -Wall -Wextra -shared -g -Wunused-function -Wunused-parameter \
-I./include/netcdf/include \
-I./include/expat/include \
-I./include/tng/include \
libpymolfile_wrap.cxx pymolfile.c -o _libpymolfile.so -L. \
libpymolfile_wrap.cxx pymolfile.cxx -o _libpymolfile.so -L. \
-L./lib/molfile_plugin/lib \
-L./lib/netcdf/lib \
-L./lib/expat/lib \
......
This diff is collapsed.
This diff is collapsed.
......@@ -52,10 +52,6 @@ struct MolObject {
};
*/
static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj);
static PyObject * PyMolfileCapsule_FromVoidPtr(void *ptr, void (*data)(PyObject *));
void del_molfile_plugin_list(PyObject* molcapsule);
void del_molfile_file_handle(PyObject* molcapsule);
#if PY_VERSION_HEX >= 0x03000000
#define PyInt_AsSsize_t PyLong_AsSsize_t
......@@ -69,6 +65,11 @@ void del_molfile_file_handle(PyObject* molcapsule);
#define PyString_Type PyBytes_Type
#define PyInt_Type PyLong_Type
void del_molfile_plugin_list(PyObject* molcapsule);
void del_molfile_file_handle(PyObject* molcapsule);
static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj);
static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj)
{
void *ret = PyCapsule_GetPointer(obj, "plugin_handle");
......@@ -78,6 +79,7 @@ static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj)
return ret;
}
static PyObject * PyMolfileCapsule_FromVoidPtr(void *ptr, void (*destr)(PyObject *));
static PyObject * PyMolfileCapsule_FromVoidPtr(void *ptr, void (*destr)(PyObject *))
{
PyObject *ret = PyCapsule_New(ptr, "plugin_handle", destr);
......@@ -90,11 +92,18 @@ static PyObject * PyMolfileCapsule_FromVoidPtr(void *ptr, void (*destr)(PyObject
#else
#define PyBytes_FromString PyString_FromString
void del_molfile_plugin_list(void* molcapsule);
void del_molfile_file_handle(void* molcapsule);
static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj);
static void * PyMolfileCapsule_AsVoidPtr(PyObject *obj)
{
return PyCObject_AsVoidPtr(obj);
}
static PyObject * PyMolfileCapsule_FromVoidPtr(void *ptr, void (*destr)(void *));
static PyObject * PyMolfileCapsule_FromVoidPtr(void *ptr, void (*destr)(void *))
{
return PyCObject_FromVoidPtr(ptr, destr);
......
#!/usr/bin/env python
import os
import sysconfig
import sys
try:
from setuptools.command.build_ext import build_ext
from setuptools import setup, Extension, Command, find_packages
from Cython.Build import cythonize
from Cython.Distutils import build_ext
except:
from distutils.command.build_ext import build_ext
from distutils import setup, Extension, Command, find_packages
from Cython.Build import cythonize
from Cython.Distutils import build_ext
def get_ext_filename_without_platform_suffix(filename):
name, ext = os.path.splitext(filename)
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
if ext_suffix == ext:
return filename
ext_suffix = ext_suffix.replace(ext, '')
idx = name.find(ext_suffix)
if idx == -1:
return filename
else:
return name[:idx] + ext
class BuildExtWithoutPlatformSuffix(build_ext):
def get_ext_filename(self, ext_name):
filename = super().get_ext_filename(ext_name)
return get_ext_filename_without_platform_suffix(filename)
VERSION = "0.0.1"
CLASSIFIERS = [
......@@ -96,36 +121,46 @@ largefile_macros = [
]
if __name__ == '__main__':
libpymolfile_module = Extension(
'pymolfile/molfile/_libpymolfile',
sources=[
'pymolfile/molfile/libpymolfile.i' ,
'pymolfile/molfile/pymolfile.c'
'pymolfile/molfile/pymolfile.cxx'
],
swig_opts=['-py3 -c++ -python'],
swig_opts=['-py3', '-Wall', '-c++'],
library_dirs=[
'/usr/lib',
'lib/'
'pymolfile/molfile/lib/',
'pymolfile/molfile/lib/tng/lib/'
],
libraries=['libmolfile_plugin.a'],
libraries=['netcdf','tng_io','expat'],
include_dirs = [
get_numpy_include,
'/usr/include',
get_numpy_include(),
'pymolfile/molfile',
'pymolfile/molfile/lib/'
'pymolfile/molfile/include/',
'pymolfile/molfile/include/molfile_plugin/include',
'pymolfile/molfile/lib/molfile_plugin/lib',
'pymolfile/molfile/include/plugin_src/include',
'pymolfile/molfile/include/netcdf/include',
'pymolfile/molfile/include/expat/include',
#'pymolfile/molfile/include/netcdf/include',
#'pymolfile/molfile/include/expat/include',
'pymolfile/molfile/include/tng/include',
],
extra_compile_args = [
'-DNDEBUG', '-DUNIX', '-D__UNIX', '-m64',
'-fPIC', '-O2', '-w', '-fmessage-length=0'
]
'-fPIC', '-shared', '-O2', '-w'
#'-DNDEBUG', '-DUNIX', '-D__UNIX', '-m64',
#'-fPIC', '-O2', '-w', '-fmessage-length=0'
],
extra_link_args = [
'pymolfile/molfile/lib/molfile_plugin/lib/libmolfile_plugin.a'
],
define_macros = largefile_macros
)
#if sys.version_info > (3,):
# command_extension={'build_ext': BuildExtWithoutPlatformSuffix}
#else:
# command_extension={}
command_extension={}
setup(
name = "pymolfile",
......@@ -138,29 +173,10 @@ if __name__ == '__main__':
url = "https://gitlab.mpcdf.mpg.de/berko/pymolfile",
zip_safe = False,
packages = find_packages(),
cmdclass= command_extension,
ext_modules = [
#libmolfile_plugin_compile(cmake_libmolfile_plugin_compile),
libpymolfile_module,
# NumpyExtension(
# "pymolfile/molfile/_libpymolfile",
# "pymolfile"
# sources = [
# "pymolfile/molfile/libpymolfile_wrap.cxx",
# "pymolfile/molfile/pymolfile.c",
# "pymolfile/molfile/lib/libmolfile_plugin.a",
# ],
# include_dirs = [
# get_numpy_include,
# "pymolfile/molfile/include/",
# "pymolfile/molfile/include/molfile_plugin/include",
# "pymolfile/molfile/lib/molfile_plugin/lib",
# "pymolfile/molfile/include/plugin_src/include",
# "pymolfile/molfile/include/netcdf/include",
# "pymolfile/molfile/include/expat/include",
# "pymolfile/molfile/include/tng/include",
# ],
# define_macros = largefile_macros
# ),
],
py_modules=["pymolfile"],
requires = [ "numpy" ],
......
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