Skip to content

Commit

Permalink
Merge pull request #139 from effigies/mnt/cp312
Browse files Browse the repository at this point in the history
MNT: Enable cp312 wheels
  • Loading branch information
pauldmccarthy authored Nov 2, 2023
2 parents 8de9fc7 + 359844a commit e258c68
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .ci/build_dev_indexed_gzip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ source $thisdir/activate_env.sh "$envdir"
# modules - see setup.py
export INDEXED_GZIP_TESTING=1

pip install -e .
pip install --no-build-isolation --editable .
19 changes: 8 additions & 11 deletions .ci/build_wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,16 @@ export CIBW_TEST_REQUIRES="cython pytest numpy nibabel coverage cython-coverage

# Disable pypy builds (reasons for doing this have been lost to
# history [GHA logs of failing builds deleted]).
#
# Disable musllinux builds until numpy binaries are available (as
# compiling numpy takes too long, and causes GHA jobs to time out).
#
# Disable py312 builds until numpy is available
export CIBW_SKIP="pp* *musllinux* *312*"
export CIBW_SKIP="pp*"

# Skip i686/aarch64 tests - I have experienced hangs on these
# Skip i686 tests - I have experienced hangs on these
# platforms, which I traced to a trivial numpy operation -
# "numpy.linalg.det(numpy.eye(3))". This occurs when numpy has
# to be compiled from source during the build, so can be
# re-visited if/when numpy is avaialble on all platforms.
export CIBW_TEST_SKIP="*i686* *aarch64*"
# "numpy.linalg.det(numpy.eye(3))". This occurs when numpy
# has to be compiled from source during the build, so can
# be re-visited if/when numpy is avaialble on all platforms.
#
# Skip py312 tests on Windows due to unresolved test failures.
export CIBW_TEST_SKIP="*i686* cp312-win*"

# Pytest makes it *very* awkward to run tests
# from an installed package, and still find/
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
extra-args: ["", "--concat"]
exclude:
- os: windows-latest
python-version: 3.12

env:
PLATFORM: ${{ matrix.os }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
extra-args: ["", "--concat"]
exclude:
- os: windows-latest
python-version: 3.12

env:
PLATFORM: ${{ matrix.os }}
Expand Down
5 changes: 3 additions & 2 deletions indexed_gzip/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def tempdir():
"""Returnsa context manager which creates and returns a temporary
"""Returns a context manager which creates and returns a temporary
directory, and then deletes it on exit.
"""

Expand All @@ -34,6 +34,7 @@ def __enter__(self):

def __exit__(self, *a, **kwa):
os.chdir(self.prevdir)
time.sleep(0.25)
shutil.rmtree(self.tempdir)

return ctx()
Expand Down Expand Up @@ -77,7 +78,7 @@ def compress_with_gzip_module():
if len(data) == 0:
break
with open(outfile, 'ab') as outf:
gzip.GzipFile(fileobj=outf).write(data)
gzip.GzipFile(fileobj=outf, mode='ab').write(data)

def compress_with_gzip_command():

Expand Down
26 changes: 15 additions & 11 deletions indexed_gzip/tests/ctest_indexed_gzip.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_open_close(testfile, nelems, seed, drop):

assert not f.closed

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval = read_element(f, element)

assert readval == element
Expand All @@ -90,7 +90,7 @@ def test_open_function(testfile, nelems):
f1 = igzip.IndexedGzipFile(testfile)
f2 = igzip.open( testfile)

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval1 = read_element(f1, element)
readval2 = read_element(f2, element)

Expand All @@ -106,7 +106,7 @@ def test_open_close_ctxmanager(testfile, nelems, seed, drop):

with igzip._IndexedGzipFile(filename=testfile, drop_handles=drop) as f:

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval = read_element(f, element)

assert readval == element
Expand Down Expand Up @@ -262,7 +262,7 @@ def test_create_from_open_handle(testfile, nelems, seed, drop, file_like_object)
assert gzf.fileobj() is f
assert not gzf.drop_handles

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval = read_element(gzf, element)

gzf.close()
Expand Down Expand Up @@ -291,7 +291,7 @@ def test_accept_filename_or_fileobj(testfile, nelems):
gzf2 = igzip._IndexedGzipFile(f)
gzf3 = igzip._IndexedGzipFile(fileobj=BytesIO(open(testfile, 'rb').read()))

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval1 = read_element(gzf1, element)
readval2 = read_element(gzf2, element)
readval3 = read_element(gzf3, element)
Expand Down Expand Up @@ -329,7 +329,7 @@ def test_prioritize_fd_over_f(testfile, nelems):
f.read = error_fn # If the file-like object were directly used by zran.c, reading would raise an error.
gzf = igzip._IndexedGzipFile(fileobj=f)

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval = read_element(gzf, element)

assert readval == element
Expand All @@ -353,7 +353,7 @@ def test_handles_not_dropped(testfile, nelems, seed):
# doesn't change across reads
for i in range(5):

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval = read_element(f, element)

assert readval == element
Expand All @@ -367,7 +367,7 @@ def test_handles_not_dropped(testfile, nelems, seed):

for i in range(5):

element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval = read_element(gzf, element)

assert readval == element
Expand Down Expand Up @@ -413,7 +413,7 @@ def test_manual_build():
f.build_full_index()

for i in range(5):
element = np.random.randint(0, nelems, 1)
element = np.random.randint(0, nelems, 1)[0]
readval = read_element(f, element)
assert readval == element

Expand Down Expand Up @@ -493,6 +493,10 @@ def test_read_beyond_end(concat, drop):
assert check_data_valid(data1, 0)
assert check_data_valid(data2, 0)

del f
f = None
os.remove(testfile)


def test_seek(concat):
with tempdir() as tdir:
Expand Down Expand Up @@ -925,7 +929,7 @@ def test_build_index_from_unseekable():
# make a test file
data = np.arange(524288, dtype=np.uint64)
with gzip.open(fname, 'wb') as f:
f.write(data.tostring())
f.write(data.tobytes())

# Test creating the index when file is unseekable,
# then using the index when file is seekable.
Expand Down Expand Up @@ -967,7 +971,7 @@ def test_wrapper_class():

data = np.arange(65536, dtype=np.uint64)
with gzip.open(fname, 'wb') as f:
f.write(data.tostring())
f.write(data.tobytes())

with igzip.IndexedGzipFile(fname, drop_handles=False) as f:

Expand Down
6 changes: 3 additions & 3 deletions indexed_gzip/tests/ctest_zran.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ cdef class ReadBuffer:
zeros = np.zeros(min(towrite, 134217728), dtype=np.uint8)
towrite -= len(zeros)

os.write(fd, zeros.tostring())
os.write(fd, zeros.tobytes())

th = threading.Thread(target=initmem)
th.start()
Expand Down Expand Up @@ -1133,7 +1133,7 @@ def test_export_import_no_points(no_fds):
with tempdir():

with gzip.open('data.gz', 'wb') as f:
f.write(data.tostring())
f.write(data.tobytes())

with open('data.gz', 'rb') as pyfid:
cfid = fdopen(pyfid.fileno(), 'rb')
Expand Down Expand Up @@ -1187,7 +1187,7 @@ def test_export_import_format_v0():
with tempdir():

with gzip.open('data.gz', 'wb') as f:
f.write(data.tostring())
f.write(data.tobytes())

with open('data.gz', 'rb') as pyfid:
cfid = fdopen(pyfid.fileno(), 'rb')
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ version = {attr = "indexed_gzip.__version__"}

[tool.pytest.ini_options]
testpaths = ["indexed_gzip/tests"]
addopts = "-v --cov=indexed_gzip"
addopts = "-v --cov=indexed_gzip --showlocals"
markers = [
"zran_test: Test the zran.c library",
"indexed_gzip_test: Test the indexed_gzip library",
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ def run(self):
extra_srcs = []
extra_compile_args = []
compiler_directives = {'language_level' : 2}
define_macros = []
define_macros = [
('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION'),
]

if ZLIB_HOME is not None:
include_dirs.append(ZLIB_HOME)
Expand Down

0 comments on commit e258c68

Please sign in to comment.