Skip to content

Commit

Permalink
remove need for cpyapi
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 committed Sep 27, 2023
1 parent 19a13a8 commit 02fe895
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion ci/conda_env_python.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ cloudpickle
fsspec
hypothesis
numpy>=1.16.6
pycapi
pytest
pytest-faulthandler
pytest-lazy-fixture
Expand Down
18 changes: 10 additions & 8 deletions python/pyarrow/tests/test_cffi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@

import gc

import pycapi

import pyarrow as pa
try:
from pyarrow.cffi import ffi
except ImportError:
ffi = None

import pytest
import ctypes

try:
import pandas as pd
Expand All @@ -38,7 +37,6 @@
needs_cffi = pytest.mark.skipif(ffi is None,
reason="test needs cffi package installed")


assert_schema_released = pytest.raises(
ValueError, match="Cannot import released ArrowSchema")

Expand All @@ -49,6 +47,10 @@
ValueError, match="Cannot import released ArrowArrayStream")


def PyCapsule_IsValid(capsule, name):
return ctypes.pythonapi.PyCapsule_IsValid(ctypes.py_object(capsule), name) == 1


class ParamExtType(pa.PyExtensionType):

def __init__(self, width):
Expand Down Expand Up @@ -423,7 +425,7 @@ def test_roundtrip_schema_capsule(obj):
old_allocated = pa.total_allocated_bytes()

capsule = obj.__arrow_c_schema__()
assert pycapi.PyCapsule_IsValid(capsule, b"arrow_schema") == 1
assert PyCapsule_IsValid(capsule, b"arrow_schema") == 1
obj_out = type(obj)._import_from_c_capsule(capsule)
assert obj_out == obj

Expand Down Expand Up @@ -452,8 +454,8 @@ def test_roundtrip_array_capsule(arr, schema_accessor, bad_type, good_type):
import_array = type(arr)._import_from_c_capsule

schema_capsule, capsule = arr.__arrow_c_array__()
assert pycapi.PyCapsule_IsValid(schema_capsule, b"arrow_schema") == 1
assert pycapi.PyCapsule_IsValid(capsule, b"arrow_array") == 1
assert PyCapsule_IsValid(schema_capsule, b"arrow_schema") == 1
assert PyCapsule_IsValid(capsule, b"arrow_array") == 1
arr_out = import_array(schema_capsule, capsule)
assert arr_out.equals(arr)

Expand Down Expand Up @@ -494,7 +496,7 @@ def test_roundtrip_reader_capsule(constructor):
obj = constructor(schema, batches)

capsule = obj.__arrow_c_stream__()
assert pycapi.PyCapsule_IsValid(capsule, b"arrow_array_stream") == 1
assert PyCapsule_IsValid(capsule, b"arrow_array_stream") == 1
imported_reader = pa.RecordBatchReader._import_from_c_capsule(capsule)
assert imported_reader.schema == schema
for batch, expected in zip(imported_reader, batches):
Expand Down Expand Up @@ -524,7 +526,7 @@ def test_roundtrip_batch_reader_capsule():
batch = make_batch()

capsule = batch.__arrow_c_stream__()
assert pycapi.PyCapsule_IsValid(capsule, b"arrow_array_stream") == 1
assert PyCapsule_IsValid(capsule, b"arrow_array_stream") == 1
imported_reader = pa.RecordBatchReader._import_from_c_capsule(capsule)
assert imported_reader.schema == batch.schema
assert imported_reader.read_next_batch().equals(batch)
Expand Down
1 change: 0 additions & 1 deletion python/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
cffi
hypothesis
pandas
pycapi
pytest
pytest-lazy-fixture
pytz

0 comments on commit 02fe895

Please sign in to comment.