mirror of
https://github.com/TREX-CoE/qmckl.git
synced 2024-11-19 20:42:50 +01:00
Rename the imported functions and get rid of Python package for now
This commit is contained in:
parent
04367c1824
commit
c9450bb1a7
@ -9,15 +9,15 @@ set -e
|
||||
cd src/
|
||||
|
||||
# compile the wrapper code
|
||||
cc -c -fPIC `pkg-config --cflags qmckl` -I/usr/include/python3.8 pyqmckl_wrap.c -o pyqmckl_wrap.o
|
||||
cc -c -fPIC `pkg-config --cflags qmckl` -I/usr/include/python3.8 qmckl_wrap.c -o qmckl_wrap.o
|
||||
|
||||
# link against the previously installed QMCkl library (as detected by pkg-config)
|
||||
cc -shared pyqmckl_wrap.o `pkg-config --libs qmckl` -o _pyqmckl.so
|
||||
cc -shared pyqmckl_wrap.o `pkg-config --libs qmckl` -o _qmckl.so
|
||||
|
||||
cd ..
|
||||
|
||||
# copy the produced files into the test dir
|
||||
cp src/_pyqmckl.so src/pyqmckl.py test/
|
||||
cp src/_qmckl.so src/qmckl.py test/
|
||||
|
||||
# run tests
|
||||
cd test/
|
||||
|
@ -6,8 +6,12 @@ set -e
|
||||
./build_pyqmckl.sh
|
||||
|
||||
# copy swig-produced pyqmckl.py module into the pyqmckl/ folder
|
||||
cp src/pyqmckl.py pyqmckl/
|
||||
#cp src/qmckl.py qmckl/
|
||||
cp src/qmckl.py ./
|
||||
|
||||
# install using pip
|
||||
pip install .
|
||||
|
||||
cd test
|
||||
python test_api.py
|
||||
cd ..
|
||||
|
@ -1,2 +0,0 @@
|
||||
from .pyqmckl import *
|
||||
from ._version import __version__
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
setup.py file for pyqmckl package
|
||||
setup.py file for qmckl package
|
||||
"""
|
||||
|
||||
from setuptools import setup, Extension
|
||||
@ -11,49 +11,33 @@ from os.path import join
|
||||
with open("README.md", "r") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
# Read the version string from the file
|
||||
VERSIONFILE = "pyqmckl/_version.py"
|
||||
try:
|
||||
exec(open(VERSIONFILE).read())
|
||||
except:
|
||||
raise IOError("Could not open the version file %s." % (VERSIONFILE, ))
|
||||
|
||||
version_r = __version__
|
||||
if not version_r:
|
||||
raise RuntimeError("Unable to find a version string in %s." % (VERSIONFILE, ))
|
||||
|
||||
|
||||
# Define the name of the Python package
|
||||
mod_name = 'pyqmckl'
|
||||
|
||||
MODULE_NAME = "qmckl"
|
||||
|
||||
# Define pyqmckl extension module based on SWIG interface file (requires qmckl.h)
|
||||
pyqmckl_module = Extension(name = mod_name + '._' + mod_name,
|
||||
sources = [ join('src', mod_name + '_wrap.c') ],
|
||||
pyqmckl_module = Extension(name = "._" + MODULE_NAME,
|
||||
sources = [ join("src", MODULE_NAME + "_wrap.c") ],
|
||||
#include_dirs = [numpy_includedir],
|
||||
#library_dirs = [],
|
||||
#runtime_library_dirs = [],
|
||||
libraries = ['qmckl'],
|
||||
extra_compile_args = ['-Wall'],
|
||||
libraries = ["qmckl"],
|
||||
extra_compile_args = ["-Wall"],
|
||||
#extra_link_args = [h5_ldflags],
|
||||
#swig_opts = ['-py3' , '-builtin'],
|
||||
depends = [ join('src', 'qmckl.h') ],
|
||||
language = 'c'
|
||||
depends = [ join("src", "qmckl.h") ],
|
||||
language = "c"
|
||||
)
|
||||
|
||||
|
||||
setup(name = mod_name,
|
||||
version = version_r,
|
||||
setup(name = MODULE_NAME,
|
||||
version = "0.2.0",
|
||||
author = "TREX-CoE",
|
||||
author_email = "posenitskiy@irsamc.ups-tlse.fr",
|
||||
description = """Python API of the QMCkl library""",
|
||||
long_description = long_description,
|
||||
long_description_content_type = "text/markdown",
|
||||
ext_modules = [pyqmckl_module],
|
||||
py_modules = [mod_name],
|
||||
packages = [mod_name],
|
||||
url = 'https://github.com/TREX-CoE/qmckl',
|
||||
license = 'BSD',
|
||||
py_modules = [MODULE_NAME],
|
||||
url = "https://github.com/TREX-CoE/qmckl",
|
||||
license = "BSD",
|
||||
classifiers=[
|
||||
"Intended Audience :: Science/Research",
|
||||
"Intended Audience :: Developers",
|
||||
@ -69,5 +53,5 @@ setup(name = mod_name,
|
||||
"Operating System :: MacOS"
|
||||
],
|
||||
python_requires = ">=3.0",
|
||||
install_requires = ['numpy>=1.17.3']
|
||||
install_requires = ["numpy>=1.17.3"]
|
||||
)
|
||||
|
@ -1,4 +1,4 @@
|
||||
%module pyqmckl
|
||||
%module qmckl
|
||||
/* Define SWIGWORDSIZE in order to properly align long integers on 64-bit system */
|
||||
#define SWIGWORDSIZE64
|
||||
%{
|
||||
@ -7,6 +7,11 @@
|
||||
#include "qmckl.h"
|
||||
%}
|
||||
|
||||
/*
|
||||
* Get rid of the function prefixes, as the scripting language will use
|
||||
* the module's namespace.
|
||||
*/
|
||||
%rename("%(strip:[qmckl_])s") "";
|
||||
|
||||
/* Include stdint to recognize types from stdint.h */
|
||||
%include <stdint.i>
|
||||
|
@ -1,13 +1,13 @@
|
||||
"""
|
||||
This is the test of the Python API of the QMCkl library.
|
||||
It is the `bench_mos.c` C code adapted from the `qmckl_bench`
|
||||
It is the `bench_mos.c` C code adapted from the `bench`
|
||||
repo and translated into Python with some modifications.
|
||||
"""
|
||||
|
||||
from os.path import join
|
||||
import time
|
||||
|
||||
import pyqmckl as pq
|
||||
import qmckl as pq
|
||||
from data.data import coord
|
||||
|
||||
|
||||
@ -16,34 +16,34 @@ elec_num = 158
|
||||
|
||||
ITERMAX = 10
|
||||
|
||||
ctx = pq.qmckl_context_create()
|
||||
ctx = pq.context_create()
|
||||
|
||||
try:
|
||||
pq.qmckl_trexio_read(ctx, 'fake.h5')
|
||||
pq.trexio_read(ctx, 'fake.h5')
|
||||
except RuntimeError:
|
||||
print('Error handling check: passed')
|
||||
|
||||
fname = join('data', 'Alz_small.h5')
|
||||
|
||||
pq.qmckl_trexio_read(ctx, fname)
|
||||
pq.trexio_read(ctx, fname)
|
||||
print('trexio_read: passed')
|
||||
|
||||
pq.qmckl_set_electron_walk_num(ctx, walk_num)
|
||||
pq.set_electron_walk_num(ctx, walk_num)
|
||||
|
||||
mo_num = pq.qmckl_get_mo_basis_mo_num(ctx)
|
||||
mo_num = pq.get_mo_basis_mo_num(ctx)
|
||||
assert mo_num == 404
|
||||
|
||||
pq.qmckl_set_electron_coord(ctx, 'T', coord)
|
||||
pq.set_electron_coord(ctx, 'T', coord)
|
||||
|
||||
size_max = 5*walk_num*elec_num*mo_num
|
||||
|
||||
mo_vgl = pq.qmckl_get_mo_basis_mo_vgl(ctx, size_max)
|
||||
mo_vgl = pq.get_mo_basis_mo_vgl(ctx, size_max)
|
||||
assert mo_vgl.size == size_max
|
||||
|
||||
start = time.clock_gettime_ns(time.CLOCK_REALTIME)
|
||||
|
||||
for _ in range(ITERMAX):
|
||||
mo_vgl_in = pq.qmckl_get_mo_basis_mo_vgl_inplace(ctx, size_max)
|
||||
mo_vgl_in = pq.get_mo_basis_mo_vgl_inplace(ctx, size_max)
|
||||
|
||||
end = time.clock_gettime_ns(time.CLOCK_REALTIME)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user