Skip to content

[WIP] Begin testing on Python 3.12 and numpy 2.0-dev #1242

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

Closed
wants to merge 5 commits into from
Closed
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
5 changes: 4 additions & 1 deletion .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
architecture: ['x64', 'x86']
install: ['pip']
check: ['test']
Expand All @@ -54,6 +54,8 @@ jobs:
architecture: x86
- os: macos-latest
architecture: x86
- python-version: '3.12'
architecture: x86

env:
DEPENDS: ${{ matrix.depends }}
Expand All @@ -72,6 +74,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
allow-prereleases: true
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Create virtual environment
Expand Down
6 changes: 6 additions & 0 deletions nibabel/openers.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ def __init__(
mtime=mtime,
)

def seek(self, pos: int, whence: int = 0, /) -> int:
# Work around bug (gh-180111) in Python 3.12rc1, where seeking without
# flushing can cause write of excess null bytes
self.flush()
return super().seek(pos, whence)


def _gzip_open(
filename: str,
Expand Down
5 changes: 5 additions & 0 deletions nibabel/tests/test_image_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import io
import pathlib
import sys
import warnings
from functools import partial
from itertools import product
Expand Down Expand Up @@ -579,6 +580,10 @@ def validate_from_url(self, imaker, params):
del img
del rt_img

@pytest.mark.xfail(
sys.version_info >= (3, 12),
reason='Response type for file: urls is not a stream in Python 3.12',
)
def validate_from_file_url(self, imaker, params):
tmp_path = self.tmp_path

Expand Down
2 changes: 1 addition & 1 deletion tools/ci/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ PYDICOM_MASTER="git+https://github.com/pydicom/pydicom.git@master"
MIN_OPT_DEPENDS="matplotlib==1.5.3 pydicom==1.0.1 pillow==2.6"

# Numpy and scipy upload nightly/weekly/intermittent wheels
NIGHTLY_WHEELS="https://pypi.anaconda.org/scipy-wheels-nightly/simple"
NIGHTLY_WHEELS="https://pypi.anaconda.org/scientific-python-nightly-wheels/simple"
STAGING_WHEELS="https://pypi.anaconda.org/multibuild-wheels-staging/simple"
PRE_PIP_FLAGS="--pre --extra-index-url $NIGHTLY_WHEELS --extra-index-url $STAGING_WHEELS"
4 changes: 2 additions & 2 deletions tools/ci/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ if [ -n "$EXTRA_PIP_FLAGS" ]; then
fi

if [ -n "$DEPENDS" ]; then
pip install ${EXTRA_PIP_FLAGS} --prefer-binary ${!DEPENDS}
pip install ${EXTRA_PIP_FLAGS} --only-binary :all: ${!DEPENDS}
if [ -n "$OPTIONAL_DEPENDS" ]; then
for DEP in ${!OPTIONAL_DEPENDS}; do
pip install ${EXTRA_PIP_FLAGS} --prefer-binary $DEP || true
pip install ${EXTRA_PIP_FLAGS} --only-binary :all: $DEP || true
done
fi
fi
Expand Down