Skip to content

Commit

Permalink
dev-python/python-multipart: Hard-rename to python_multipart
Browse files Browse the repository at this point in the history
Hard-rename the Python package to `python_multipart`, to avoid conflicts
with the `multipart` PyPI package.

Both `multipart` and `python-multipart` packages install using
`multipart` import name, therefore both cannot be installed at the same
time.  Historically, we have included only the latter in Gentoo, since
it was pulled in as a dependency of dev-python/starlette.  However,
the former was recently made the recommended replacement
for the deprecated and removed `cgi` standard library module, therefore
other packages started depending on it.

Given that both packages intend to be maintained throughout
the foreseeable future, it seems that the best workaround is to rename
one of them.  In this case, `python-multipart` uses an import name
that does not match the package and seems to be have fewer reverse
dependencies at this time, so rename it.  There is already an open pull
request upstream to do exactly that, so reuse parts of it.  That said,
since we can simply patch reverse dependencies, we do not need
the compatibility layer (and probably do not want it, as it could yield
confusing errors if the wrong package is installed).

Bug: pypa/packaging-problems#818
Pull-Request: Kludex/python-multipart#166
Signed-off-by: Michał Górny <mgorny@gentoo.org>
  • Loading branch information
mgorny committed Oct 19, 2024
1 parent df9bc3f commit 981dacd
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From d6e30eb0269fa04d4a16133bd94405f10240aeb0 Mon Sep 17 00:00:00 2001
From: Henry Schreiner <henryschreineriii@gmail.com>
Date: Fri, 11 Oct 2024 17:11:21 -0400
Subject: [PATCH 1/2] refactor: rename to python_multipart

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

diff --git a/pyproject.toml b/pyproject.toml
index fb03f83..1a81077 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -62,13 +65,10 @@ Changelog = "https://github.com/Kludex/python-multipart/blob/master/CHANGELOG.md
Source = "https://github.com/Kludex/python-multipart"

[tool.hatch.version]
-path = "multipart/__init__.py"
-
-[tool.hatch.build.targets.wheel]
-packages = ["multipart"]
+path = "python_multipart/__init__.py"

[tool.hatch.build.targets.sdist]
-include = ["/multipart", "/tests", "CHANGELOG.md", "LICENSE.txt"]
+include = ["/python_multipart", "/tests", "CHANGELOG.md", "LICENSE.txt", "_python_multipart.pth", "_python_multipart_loader.py"]

[tool.mypy]
strict = true
diff --git a/tests/test_multipart.py b/tests/test_multipart.py
index b824f19..f5f8e7e 100644
--- a/tests/test_multipart.py
+++ b/tests/test_multipart.py
@@ -11,9 +11,9 @@

import yaml

-from multipart.decoders import Base64Decoder, QuotedPrintableDecoder
-from multipart.exceptions import DecodeError, FileError, FormParserError, MultipartParseError, QuerystringParseError
-from multipart.multipart import (
+from python_multipart.decoders import Base64Decoder, QuotedPrintableDecoder
+from python_multipart.exceptions import DecodeError, FileError, FormParserError, MultipartParseError, QuerystringParseError
+from python_multipart.multipart import (
BaseParser,
Field,
File,
@@ -31,7 +31,7 @@
if TYPE_CHECKING:
from typing import Any, Iterator, TypedDict

- from multipart.multipart import FieldProtocol, FileConfig, FileProtocol
+ from python_multipart.multipart import FieldProtocol, FileConfig, FileProtocol

class TestParams(TypedDict):
name: str

47 changes: 47 additions & 0 deletions dev-python/python-multipart/python-multipart-0.0.12-r100.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

DISTUTILS_USE_PEP517=hatchling
PYTHON_COMPAT=( pypy3 python3_{10..13} )

inherit distutils-r1

DESCRIPTION="A streaming multipart parser for Python"
HOMEPAGE="
https://github.com/Kludex/python-multipart/
https://pypi.org/project/python-multipart/
"
SRC_URI="
https://github.com/Kludex/python-multipart/archive/${PV}.tar.gz
-> ${P}.gh.tar.gz
"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"

BDEPEND="
test? (
dev-python/pyyaml[${PYTHON_USEDEP}]
)
"

distutils_enable_tests pytest

src_prepare() {
local PATCHES=(
# https://github.com/Kludex/python-multipart/pull/166
"${FILESDIR}/${P}-rename.patch"
)

distutils-r1_src_prepare

mv multipart python_multipart || die
}

python_test() {
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
epytest
}

0 comments on commit 981dacd

Please sign in to comment.