diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 630f09d99..4431c7135 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -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'] @@ -54,6 +54,8 @@ jobs: architecture: x86 - os: macos-latest architecture: x86 + - python-version: '3.12' + architecture: x86 env: DEPENDS: ${{ matrix.depends }} @@ -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 diff --git a/nibabel/openers.py b/nibabel/openers.py index 90c7774d1..9a024680a 100644 --- a/nibabel/openers.py +++ b/nibabel/openers.py @@ -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, diff --git a/nibabel/tests/test_image_api.py b/nibabel/tests/test_image_api.py index 091bc57e8..890619bad 100644 --- a/nibabel/tests/test_image_api.py +++ b/nibabel/tests/test_image_api.py @@ -25,6 +25,7 @@ import io import pathlib +import sys import warnings from functools import partial from itertools import product @@ -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 diff --git a/tools/ci/env.sh b/tools/ci/env.sh index dd2944312..3d37ad955 100644 --- a/tools/ci/env.sh +++ b/tools/ci/env.sh @@ -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" diff --git a/tools/ci/install_dependencies.sh b/tools/ci/install_dependencies.sh index f26c5204c..2ea4a524e 100755 --- a/tools/ci/install_dependencies.sh +++ b/tools/ci/install_dependencies.sh @@ -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