From f406c0565f48aae041213d2ac016a7c273f07429 Mon Sep 17 00:00:00 2001 From: Jake Herrmann Date: Tue, 15 Oct 2024 13:06:44 -0800 Subject: [PATCH] support python 3.13 --- .github/workflows/test.yml | 2 +- CHANGELOG.md | 5 +++++ environment.yml | 3 +-- pyproject.toml | 4 ++-- src/hyp3lib/fetch.py | 7 ++++--- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f512e2b..19fc938 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,4 +17,4 @@ jobs: with: local_package_name: hyp3lib python_versions: >- - ["3.10", "3.11", "3.12"] + ["3.10", "3.11", "3.12", "3.13"] diff --git a/CHANGELOG.md b/CHANGELOG.md index bb2da40..3acd4c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/) and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.1.2] + +### Fixed +* Support Python 3.13 by replacing the `cgi` module with the `email.message` module as described in [PEP 594](https://peps.python.org/pep-0594/#cgi). Fixes . + ## [3.1.1] ### Fixed diff --git a/environment.yml b/environment.yml index 449099e..2c97d9f 100644 --- a/environment.yml +++ b/environment.yml @@ -3,8 +3,7 @@ channels: - conda-forge - nodefaults dependencies: - # FIXME: standard lib `cgi` module removed in 3.13: https://github.com/ASFHyP3/hyp3-lib/issues/300 - - python>=3.10,<3.13 + - python>=3.10 - pip # For running - boto3 diff --git a/pyproject.toml b/pyproject.toml index 4c9b19d..6148ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "hyp3lib" -# FIXME: standard lib `cgi` module removed in 3.13: https://github.com/ASFHyP3/hyp3-lib/issues/300 -requires-python = ">=3.10,<3.13" +requires-python = ">=3.10" readme = "README.md" authors = [ {name="ASF APD/Tools Team", email="UAF-asf-apd@alaska.edu"}, @@ -21,6 +20,7 @@ classifiers=[ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Software Development :: Libraries", ] dependencies = [ diff --git a/src/hyp3lib/fetch.py b/src/hyp3lib/fetch.py index 8dbb3b6..a7d2184 100644 --- a/src/hyp3lib/fetch.py +++ b/src/hyp3lib/fetch.py @@ -1,6 +1,6 @@ """Utilities for fetching things from external endpoints""" -import cgi import logging +from email.message import Message from os.path import basename from pathlib import Path from typing import Optional, Tuple, Union @@ -29,8 +29,9 @@ def write_credentials_to_netrc_file( def _get_download_path(url: str, content_disposition: str = None, directory: Union[Path, str] = '.'): filename = None if content_disposition is not None: - _, params = cgi.parse_header(content_disposition) - filename = params.get('filename') + message = Message() + message['content-type'] = content_disposition + filename = message.get_param('filename') if not filename: filename = basename(urlparse(url).path) if not filename: