Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Cython Dependency #2118

Merged
merged 9 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ __pycache__/
*.so
*.dylib

# Cython extensions
*.cpp

# Distribution / packaging
.Python
env/
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
requires = [
"scikit-build-core",
"pybind11",
"Cython>=3",
"numpy>=2.0.1"
]
build-backend = "scikit_build_core.build"
Expand Down
37 changes: 2 additions & 35 deletions tiledb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
# Cython

add_custom_command(
OUTPUT libtiledb.cc
COMMAND Python::Interpreter -m cython
"${CMAKE_CURRENT_SOURCE_DIR}/libtiledb.pyx" --output-file libtiledb.cc
DEPENDS libtiledb.pyx
VERBATIM
)

python_add_library(
libtiledb
MODULE
libtiledb.cc
WITH_SOABI
)

target_link_libraries(
libtiledb
PUBLIC
Python::NumPy
TileDB::tiledb_shared
)

target_compile_features(
libtiledb
PUBLIC
cxx_std_20
)

# Pybind11

pybind11_add_module(
Expand Down Expand Up @@ -64,7 +34,7 @@ if (TILEDB_SERIALIZATION)
)
endif()

install(TARGETS main libtiledb DESTINATION tiledb)
install(TARGETS main DESTINATION tiledb)

if(TILEDB_DOWNLOADED)
message(STATUS "Adding \"libtiledb\" into install group")
Expand All @@ -73,18 +43,15 @@ if(TILEDB_DOWNLOADED)

if (APPLE)
set_target_properties(main PROPERTIES INSTALL_RPATH "@loader_path")
set_target_properties(libtiledb PROPERTIES INSTALL_RPATH "@loader_path")
elseif(UNIX)
set_target_properties(main PROPERTIES INSTALL_RPATH "\$ORIGIN")
set_target_properties(libtiledb PROPERTIES INSTALL_RPATH "\$ORIGIN")
endif()
else()
# If using external TileDB core library force it to be linked at runtime using RPATH
get_property(TILEDB_LOCATION TARGET TileDB::tiledb_shared PROPERTY LOCATION)
get_filename_component(TILEDB_LOCATION ${TILEDB_LOCATION} DIRECTORY)
message(STATUS "Setting RPATH for targets \"main\" and \"libtiledb\" to ${TILEDB_LOCATION}")
set_target_properties(main PROPERTIES INSTALL_RPATH ${TILEDB_LOCATION})
set_target_properties(libtiledb PROPERTIES INSTALL_RPATH ${TILEDB_LOCATION})
endif()

add_subdirectory(cc)
add_subdirectory(libtiledb)
20 changes: 9 additions & 11 deletions tiledb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
import os
import sys

# un-comment this section to fix Cython backtrace line-numbers in
# IPython/Jupyter. see https://bugs.python.org/issue32797#msg323167
# ---
# try:
# from importlib.machinery import ExtensionFileLoader
# else:
# del ExtensionFileLoader.get_source
# ---

if os.name == "posix":
if sys.platform == "darwin":
lib_name = "libtiledb.dylib"
Expand All @@ -19,6 +10,14 @@
else:
lib_name = "tiledb"

import numpy as np

# TODO: get rid of this - It is currently used for unified numpy printing accross numpy versions
np.set_printoptions(
legacy="1.21" if np.lib.NumpyVersion(np.__version__) >= "1.22.0" else False
)
del np

from tiledb.libtiledb import version as libtiledb_version

if libtiledb_version()[0] == 2 and libtiledb_version()[1] >= 26:
Expand All @@ -30,7 +29,6 @@
from .array import Array
from .array_schema import ArraySchema
from .attribute import Attr
from .cc import TileDBError
from .consolidation_plan import ConsolidationPlan
from .ctx import Config, Ctx, default_ctx, scope_ctx
from .dataframe_ import from_csv, from_pandas, open_dataframe
Expand Down Expand Up @@ -88,7 +86,7 @@
vacuum,
walk,
)
from .libtiledb import Ctx
from .libtiledb import TileDBError
from .multirange_indexing import EmptyRange
from .object import Object
from .parquet_ import from_parquet
Expand Down
2 changes: 1 addition & 1 deletion tiledb/aggregation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tiledb.cc as lt
import tiledb.libtiledb as lt


class Aggregation:
Expand Down
2 changes: 1 addition & 1 deletion tiledb/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np

import tiledb
import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Config, Ctx, default_ctx
from .datatypes import DataType
Expand Down
7 changes: 3 additions & 4 deletions tiledb/array_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@

import numpy as np

import tiledb.cc as lt
from tiledb.libtiledb import version as libtiledb_version
import tiledb.libtiledb as lt

from .attribute import Attr
from .ctx import Ctx, CtxMixin, default_ctx
from .dimension_label import DimLabel
from .domain import Domain
from .filter import Filter, FilterList

if libtiledb_version()[0] == 2 and libtiledb_version()[1] >= 26:
if lt.version()[0] == 2 and lt.version()[1] >= 25:
from .current_domain import CurrentDomain

_tiledb_order_to_string = {
Expand Down Expand Up @@ -388,7 +387,7 @@ def has_dim_label(self, name: str) -> bool:
"""
return self._has_dim_label(self._ctx, name)

if libtiledb_version()[0] == 2 and libtiledb_version()[1] >= 26:
if lt.version()[0] == 2 and lt.version()[1] >= 25:

@property
def current_domain(self) -> CurrentDomain:
Expand Down
2 changes: 1 addition & 1 deletion tiledb/attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, CtxMixin
from .datatypes import DataType
Expand Down
62 changes: 0 additions & 62 deletions tiledb/common.pxi

This file was deleted.

2 changes: 1 addition & 1 deletion tiledb/consolidation_plan.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pprint

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .array import Array
from .ctx import Ctx, CtxMixin, default_ctx
Expand Down
2 changes: 1 addition & 1 deletion tiledb/ctx.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Union

import tiledb
import tiledb.cc as lt
import tiledb.libtiledb as lt

_ctx_var = ContextVar("ctx")

Expand Down
2 changes: 1 addition & 1 deletion tiledb/current_domain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, CtxMixin
from .domain import Domain
Expand Down
2 changes: 1 addition & 1 deletion tiledb/data_order.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from enum import Enum

import tiledb.cc as lt
import tiledb.libtiledb as lt


class DataOrder(Enum):
Expand Down
2 changes: 1 addition & 1 deletion tiledb/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np

import tiledb.cc as lt
import tiledb.libtiledb as lt


@dataclass(frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion tiledb/dense_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

import tiledb
import tiledb.cc as lt
import tiledb.libtiledb as lt

from .array import (
Array,
Expand Down
2 changes: 1 addition & 1 deletion tiledb/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, CtxMixin
from .datatypes import DataType
Expand Down
2 changes: 1 addition & 1 deletion tiledb/dimension_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import CtxMixin
from .data_order import DataOrder
Expand Down
2 changes: 1 addition & 1 deletion tiledb/dimension_label_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, default_ctx
from .data_order import DataOrder
Expand Down
2 changes: 1 addition & 1 deletion tiledb/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, CtxMixin
from .datatypes import DataType
Expand Down
2 changes: 1 addition & 1 deletion tiledb/domain_indexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

import tiledb
import tiledb.cc as lt
import tiledb.libtiledb as lt


def _index_as_tuple(idx):
Expand Down
2 changes: 1 addition & 1 deletion tiledb/enumeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
from numpy.typing import NDArray

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, CtxMixin
from .datatypes import DataType
Expand Down
2 changes: 1 addition & 1 deletion tiledb/filestore.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings
from typing import ByteString, Optional

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, default_ctx

Expand Down
2 changes: 1 addition & 1 deletion tiledb/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np

import tiledb.cc as lt
import tiledb.libtiledb as lt

from .ctx import Ctx, CtxMixin
from .datatypes import DataType
Expand Down
7 changes: 5 additions & 2 deletions tiledb/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import tiledb
from tiledb.libtiledb import version as libtiledb_version

from .main import PyFragmentInfo

"""
Classes and functions relating to TileDB fragments.
"""
Expand Down Expand Up @@ -105,6 +103,8 @@ def __init__(self, array_uri, include_mbrs=False, ctx=None):

self.array_uri = array_uri

from .main import PyFragmentInfo

fi = PyFragmentInfo(self.array_uri, schema, include_mbrs, ctx)

self.__nums = fi.get_num_fragments()
Expand Down Expand Up @@ -188,6 +188,9 @@ def __init__(self, fragments):
self._fragments = fragments
self._index = 0

def __iter__(self):
return self

def __next__(self):
if self._index < len(self._fragments):
fi = FragmentInfo(self._fragments, self._index)
Expand Down
Loading
Loading