Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore newlines when processing keywords/platforms #4888

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/4887.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed handling of keywords following the old specification with spaces instead of commas and containing newlines.
1 change: 1 addition & 0 deletions setuptools/_distutils/dist.py
Original file line number Diff line number Diff line change
@@ -644,6 +644,7 @@ def finalize_options(self) -> None:
if value is None:
continue
if isinstance(value, str):
value = value.replace("\n", " ")
value = [elm.strip() for elm in value.split(',')]
setattr(self.metadata, attr, value)

24 changes: 24 additions & 0 deletions setuptools/tests/test_core_metadata.py
Original file line number Diff line number Diff line change
@@ -164,6 +164,30 @@ def __read_test_cases():
version=sic('1.0.0a'),
),
),
(
'Keywords with commas',
params(
keywords='one, two, three',
),
),
(
'Keywords with spaces',
params(
keywords='one two three',
),
),
(
'Keywords with commas multiline',
params(
keywords='one, two,\nthree, four\n',
),
),
(
'Keywords with spaces multiline',
params(
keywords='one two\nthree four\n',
),
),
]



Unchanged files with check annotations Beta

try:
# Ensure a DistutilsError raised by these methods is the same as distutils.errors.DistutilsError
from distutils._modified import (

Check warning on line 3 in setuptools/modified.py

GitHub Actions / pyright (3.9, ubuntu-latest)

Import "distutils._modified" could not be resolved (reportMissingImports)

Check warning on line 3 in setuptools/modified.py

GitHub Actions / pyright (3.13, ubuntu-latest)

Import "distutils._modified" could not be resolved from source (reportMissingModuleSource)
newer,
newer_group,
newer_pairwise,
import types
from typing import TypeVar, cast, overload
import distutils.filelist

Check warning on line 13 in setuptools/monkey.py

GitHub Actions / pyright (3.13, ubuntu-latest)

Import "distutils.filelist" could not be resolved from source (reportMissingModuleSource)
_T = TypeVar("_T")
_UnpatchT = TypeVar("_UnpatchT", type, types.FunctionType)
_patch_distribution_metadata()
# Install Distribution throughout the distutils
for module in distutils.dist, distutils.core, distutils.cmd:

Check warning on line 81 in setuptools/monkey.py

GitHub Actions / pyright (3.9, ubuntu-latest)

"dist" is not a known attribute of module "distutils" (reportAttributeAccessIssue)

Check warning on line 81 in setuptools/monkey.py

GitHub Actions / pyright (3.9, ubuntu-latest)

"core" is not a known attribute of module "distutils" (reportAttributeAccessIssue)

Check warning on line 81 in setuptools/monkey.py

GitHub Actions / pyright (3.9, ubuntu-latest)

"cmd" is not a known attribute of module "distutils" (reportAttributeAccessIssue)

Check warning on line 81 in setuptools/monkey.py

GitHub Actions / pyright (3.13, ubuntu-latest)

"dist" is not a known attribute of module "distutils" (reportAttributeAccessIssue)

Check warning on line 81 in setuptools/monkey.py

GitHub Actions / pyright (3.13, ubuntu-latest)

"core" is not a known attribute of module "distutils" (reportAttributeAccessIssue)

Check warning on line 81 in setuptools/monkey.py

GitHub Actions / pyright (3.13, ubuntu-latest)

"cmd" is not a known attribute of module "distutils" (reportAttributeAccessIssue)
module.Distribution = setuptools.dist.Distribution
# Install the patched Extension
if 'distutils.command.build_ext' in sys.modules:
sys.modules[
'distutils.command.build_ext'
].Extension = setuptools.extension.Extension

Check warning on line 90 in setuptools/monkey.py

GitHub Actions / pyright (3.9, ubuntu-latest)

Cannot assign to attribute "Extension" for class "ModuleType"   Attribute "Extension" is unknown (reportAttributeAccessIssue)

Check warning on line 90 in setuptools/monkey.py

GitHub Actions / pyright (3.13, ubuntu-latest)

Cannot assign to attribute "Extension" for class "ModuleType"   Attribute "Extension" is unknown (reportAttributeAccessIssue)
def _patch_distribution_metadata():
'get_fullname',
):
new_val = getattr(_core_metadata, attr)
setattr(distutils.dist.DistributionMetadata, attr, new_val)

Check warning on line 105 in setuptools/monkey.py

GitHub Actions / pyright (3.9, ubuntu-latest)

"dist" is not a known attribute of module "distutils" (reportAttributeAccessIssue)

Check warning on line 105 in setuptools/monkey.py

GitHub Actions / pyright (3.13, ubuntu-latest)

"dist" is not a known attribute of module "distutils" (reportAttributeAccessIssue)
def patch_func(replacement, target_mod, func_name):
"""
Undo secondary effect of `extra_path` adding to `install_lib`
"""
suffix = os.path.relpath(self.install_lib, self.install_libbase)

Check warning on line 79 in setup.py

GitHub Actions / pyright (3.9, ubuntu-latest)

No overloads for "relpath" match the provided arguments (reportCallIssue)

Check warning on line 79 in setup.py

GitHub Actions / pyright (3.9, ubuntu-latest)

Argument of type "str | None" cannot be assigned to parameter "path" of type "StrPath" in function "relpath"   Type "str | None" is not assignable to type "StrPath"     Type "None" is not assignable to type "StrPath"       "None" is not assignable to "str"       "None" is incompatible with protocol "PathLike[str]"         "__fspath__" is not present (reportArgumentType)
if suffix.strip() == self._pth_contents.strip():
self.install_lib = self.install_libbase
# check that submodules load as expected
core = importlib.import_module('distutils.core')
assert '_distutils' in core.__file__, core.__file__

Check warning on line 76 in _distutils_hack/__init__.py

GitHub Actions / pyright (3.9, ubuntu-latest)

Operator "in" not supported for types "Literal['_distutils']" and "str | None"   Operator "in" not supported for types "Literal['_distutils']" and "None" (reportOperatorIssue)
assert 'setuptools._distutils.log' not in sys.modules
def add_shim():
DISTUTILS_FINDER in sys.meta_path or insert_shim()

Check warning on line 215 in _distutils_hack/__init__.py

GitHub Actions / pyright (3.9, ubuntu-latest)

Expression value is unused (reportUnusedExpression)
class shim:
cmd.install_dir = install_dir
if executable is not None:
bs = cmd.get_finalized_command('build_scripts')
bs.executable = executable

Check warning on line 30 in setuptools/tests/test_install_scripts.py

GitHub Actions / pyright (3.13, ubuntu-latest)

Cannot assign to attribute "executable" for class "Command"   Attribute "executable" is unknown (reportAttributeAccessIssue)
cmd.ensure_finalized()
with contexts.quiet():
cmd.run()
setup_script = tmp_path / "setup.py"
setup_script.write_text(setup_py, encoding="utf-8")
dist = distutils.core.run_setup(setup_script, stop_after="init")

Check warning on line 37 in setuptools/tests/test_logging.py

GitHub Actions / pyright (3.13, ubuntu-latest)

"core" is not a known attribute of module "distutils" (reportAttributeAccessIssue)
dist.script_args = [flag, "sdist"]
dist.parse_command_line() # <- where the log level is set
log_level = logger.getEffectiveLevel()
import setuptools.logging
from distutils import dist

Check warning on line 67 in setuptools/tests/test_logging.py

GitHub Actions / pyright (3.13, ubuntu-latest)

Import "distutils.dist" could not be resolved from source (reportMissingModuleSource)
setuptools.logging.configure()