Skip to content

Commit

Permalink
Update path to C library and API definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf committed Aug 27, 2022
1 parent 45b8a02 commit 60c6ec1
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 14 deletions.
File renamed without changes.
7 changes: 3 additions & 4 deletions chemfiles/clib.py → chemfiles/_c_lib.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -* coding: utf-8 -*
import os
import sys
from ctypes import cdll, c_double, POINTER
from ctypes import POINTER, c_double, cdll

try:
from .external import EXTERNAL_CHEMFILES
Expand All @@ -18,8 +18,7 @@ def __call__(self):
path = _lib_path()
self._cache = cdll.LoadLibrary(path)

from .ffi import set_interface
from .ffi import CHFL_FRAME, CHFL_ATOM, chfl_vector3d
from ._c_api import CHFL_ATOM, CHFL_FRAME, chfl_vector3d, set_interface

set_interface(self._cache)
# We update the arguments here, as ctypes can not pass a NULL value
Expand Down Expand Up @@ -60,8 +59,8 @@ def _lib_path():


def _check_dll(path):
import struct
import platform
import struct

IMAGE_FILE_MACHINE_I386 = 332
IMAGE_FILE_MACHINE_AMD64 = 34404
Expand Down
2 changes: 1 addition & 1 deletion chemfiles/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from .utils import CxxPointer, ChemfilesError
from .ffi import chfl_cellshape, chfl_vector3d
from ._c_api import chfl_cellshape, chfl_vector3d


class CellShape(IntEnum):
Expand Down
2 changes: 1 addition & 1 deletion chemfiles/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from .utils import CxxPointer, string_type
from .misc import ChemfilesError
from .ffi import chfl_vector3d, chfl_bond_order
from ._c_api import chfl_vector3d, chfl_bond_order
from .atom import Atom
from .topology import Topology
from .cell import UnitCell
Expand Down
6 changes: 3 additions & 3 deletions chemfiles/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ctypes import c_uint64, POINTER, create_string_buffer

from .clib import _get_c_library
from ._c_lib import _get_c_library


class ChemfilesWarning(UserWarning):
Expand Down Expand Up @@ -128,7 +128,7 @@ def formats_list():
:rtype: list(FormatMetadata)
"""
from .ffi import chfl_format_metadata
from ._c_api import chfl_format_metadata

lib = _get_c_library()

Expand Down Expand Up @@ -156,7 +156,7 @@ def set_warnings_callback(function):
By default, warnings are send to python ``warnings`` module.
"""
from .ffi import chfl_warning_callback
from ._c_api import chfl_warning_callback

def callback(message):
try:
Expand Down
2 changes: 1 addition & 1 deletion chemfiles/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
from ctypes import c_double, c_bool

from .ffi import chfl_property_kind, chfl_vector3d
from ._c_api import chfl_property_kind, chfl_vector3d
from .misc import ChemfilesError
from .utils import CxxPointer, _call_with_growing_buffer, string_type

Expand Down
2 changes: 1 addition & 1 deletion chemfiles/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from .utils import CxxPointer, _call_with_growing_buffer
from .ffi import chfl_match
from ._c_api import chfl_match


class Selection(CxxPointer):
Expand Down
2 changes: 1 addition & 1 deletion chemfiles/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from .utils import CxxPointer
from .ffi import chfl_bond_order
from ._c_api import chfl_bond_order
from .atom import Atom
from .residue import Residue

Expand Down
2 changes: 1 addition & 1 deletion chemfiles/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import sys
from ctypes import create_string_buffer, c_uint64

from .clib import _get_c_library
from ._c_lib import _get_c_library
from .misc import ChemfilesError, _last_error


Expand Down
2 changes: 1 addition & 1 deletion tests/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __exit__(self, *args):

class TestVersion(unittest.TestCase):
def test_version(self):
version = chemfiles.clib._get_c_library().chfl_version()
version = chemfiles._c_lib._get_c_library().chfl_version()
self.assertEqual(chemfiles.__version__, version.decode("utf8"))


Expand Down

0 comments on commit 60c6ec1

Please sign in to comment.