Skip to content

Commit

Permalink
support python 3.13
Browse files Browse the repository at this point in the history
  • Loading branch information
jtherrmann committed Oct 15, 2024
1 parent 903344f commit f406c05
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/ASFHyP3/hyp3-lib/issues/300>.

## [3.1.1]

### Fixed
Expand Down
3 changes: 1 addition & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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="[email protected]"},
Expand All @@ -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 = [
Expand Down
7 changes: 4 additions & 3 deletions src/hyp3lib/fetch.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit f406c05

Please sign in to comment.