Skip to content

Commit 01fe023

Browse files
forsyth2Copilot
andauthored
Add Python 3.14 support by forcing parallelism to use fork (#434)
* Add Python 3.14 support * Address review comments * Force fork start method for multiprocessing (Python 3.14+) Co-authored-by: forsyth2 <30700190+forsyth2@users.noreply.github.com> * Fix tar.extract filter for Python 3.12+ to allow absolute symlinks Co-authored-by: forsyth2 <30700190+forsyth2@users.noreply.github.com> * Fix pre-commit checks --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 33f379d commit 01fe023

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

.github/workflows/build_workflow.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
- name: Checkout Code Repository
2020
uses: actions/checkout@v3
2121

22-
- name: Set up Python 3.13
22+
- name: Set up Python 3.14
2323
uses: actions/setup-python@v4
2424
with:
25-
python-version: "3.13"
25+
python-version: "3.14"
2626

2727
# Run all pre-commit hooks on all the files.
2828
# Getting only staged files can be tricky in case a new PR is opened
@@ -36,7 +36,7 @@ jobs:
3636
runs-on: ubuntu-latest
3737
strategy:
3838
matrix:
39-
python-version: ["3.11", "3.12", "3.13"]
39+
python-version: ["3.11", "3.12", "3.13", "3.14"]
4040
defaults:
4141
run:
4242
shell: bash -l {0}
@@ -72,11 +72,6 @@ jobs:
7272
conda list
7373
# Ensure we have the right Python version
7474
python --version
75-
# Fix pip issues for Python 3.12+
76-
if [[ "${{ matrix.python-version }}" == "3.12" ]] || [[ "${{ matrix.python-version }}" == "3.13" ]]; then
77-
python -m ensurepip --upgrade || true
78-
python -m pip install --upgrade --force-reinstall pip setuptools wheel
79-
fi
8075
8176
- name: Install `zstash` Package
8277
run: |
@@ -121,7 +116,7 @@ jobs:
121116
environment-file: conda/dev.yml
122117
channel-priority: flexible # Changed from strict to flexible
123118
auto-update-conda: true
124-
python-version: "3.13" # Use stable Python version for docs
119+
python-version: "3.14" # Use stable Python version for docs
125120

126121
# sphinx-multiversion allows for version docs.
127122
- name: Build Sphinx Docs

conda/dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ dependencies:
55
# Base
66
# =================
77
- pip
8-
- python >=3.11,<3.14
8+
- python >=3.11,<3.15
9+
- setuptools
910
- sqlite
1011
- six >=1.16.0
1112
- globus-sdk >=3.15.0,<4.0

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ exclude =
4646
venv
4747

4848
[mypy]
49-
python_version = 3.13
49+
python_version = 3.14
5050
check_untyped_defs = True
5151
ignore_missing_imports = True
5252
warn_unused_ignores = True

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
author_email="forsyth2@llnl.gov, golaz1@llnl.gov, shaheen2@llnl.gov",
88
description="Long term HPSS archiving software for E3SM",
99
packages=find_packages(include=["zstash", "zstash.*"]),
10-
python_requires=">=3.11,<3.14",
10+
python_requires=">=3.11,<3.15",
1111
entry_points={"console_scripts": ["zstash=zstash.main:main"]},
1212
)

zstash/extract.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,12 @@ def extractFiles( # noqa: C901
659659
logger.debug("Valid md5: {} {}".format(md5, fname))
660660

661661
elif extract_this_file:
662-
tar.extract(tarinfo)
662+
if sys.version_info >= (3, 12):
663+
tar.extract(
664+
tarinfo, filter="tar"
665+
) # "data" is too restrictive, "fully_trusted" is too permissive.
666+
else:
667+
tar.extract(tarinfo)
663668
# Note: tar.extract() will not restore time stamps of symbolic
664669
# links. Could not find a Python-way to restore it either, so
665670
# relying here on 'touch'. This is not the prettiest solution.

zstash/main.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from __future__ import absolute_import, print_function
33

44
import argparse
5+
import multiprocessing
56
import os
67
import os.path
78
import sys
@@ -27,6 +28,12 @@ def handler(signal_received, frame):
2728
# -----------------------------------------------------------------------------
2829
def main():
2930

31+
# Force the use of 'fork' for multiprocessing to ensure consistent behavior
32+
# across Python versions (Python 3.14+ changed the default to 'spawn').
33+
# 'fork' is only available on POSIX systems (Linux, macOS).
34+
if sys.platform != "win32":
35+
multiprocessing.set_start_method("fork", force=True)
36+
3037
# Run the handler() function when SIGINT is received
3138
signal(SIGINT, handler)
3239

0 commit comments

Comments
 (0)