-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Setup.cfg - add support for trailing comments #3322
Comments
Thank you very much @neutrinoceros. I am busy this morning/afternoon, but I will try to have a look as soon as possible. This is probably related to the fact we updated the version of pyparsing... I don't see other changes influencing here. It might be the case previously when parsing |
Thank you ! FYI there is no rush on our side, removing the badly-parsed comment resolved the immediate issue. |
On a first glance I feel like Line 710 in b416443
inline_comment_prefixes=(" #",) , but that requires discussing the idea with the team...
On the other hand, setuptools never needed that, why did things change since then? I am still puzzled about what changed from 62.2.0 to 62.3.0 that might possibly have caused this problem... I will need some time to investigate. |
Just for the sake of documenting the main changes between 62.2 and 62.3: git diff v62.2.0 v62.3.0 -- ':!setuptools/_vendor' ':!setuptools/_distutils' ':!chang*' ':!.bump*' ':!CHANGE*' ':!docs' ':!pkg_resources/_vendor' ':!setuptools/tests' diff --git a/setup.cfg b/setup.cfg
index 0dec946b..a4b0333d 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,6 +1,6 @@
[metadata]
name = setuptools
-version = 62.2.0
+version = 62.3.0
author = Python Packaging Authority
author_email = distutils-sig@python.org
description = Easily download, build, install, upgrade, and uninstall Python packages
@@ -93,6 +93,7 @@ docs =
pygments-github-lexers==0.0.5
sphinx-favicon
sphinx-inline-tabs
+ sphinx-reredirects
sphinxcontrib-towncrier
furo
diff --git a/setuptools/_importlib.py b/setuptools/_importlib.py
index c1ac137e..819bf5d3 100644
--- a/setuptools/_importlib.py
+++ b/setuptools/_importlib.py
@@ -12,6 +12,17 @@ def disable_importlib_metadata_finder(metadata):
import importlib_metadata
except ImportError:
return
+ except AttributeError:
+ import warnings
+
+ msg = (
+ "`importlib-metadata` version is incompatible with `setuptools`.\n"
+ "This problem is likely to be solved by installing an updated version of "
+ "`importlib-metadata`."
+ )
+ warnings.warn(msg) # Ensure a descriptive message is shown.
+ raise # This exception can be suppressed by _distutils_hack
+
if importlib_metadata is metadata:
return
to_remove = [
diff --git a/setuptools/command/build_py.py b/setuptools/command/build_py.py
index c3fdc092..91f47416 100644
--- a/setuptools/command/build_py.py
+++ b/setuptools/command/build_py.py
@@ -1,3 +1,4 @@
+from functools import partial
from glob import glob
from distutils.util import convert_path
import distutils.command.build_py as orig
@@ -8,6 +9,9 @@ import io
import distutils.errors
import itertools
import stat
+import warnings
+from pathlib import Path
+from setuptools._deprecation_warning import SetuptoolsDeprecationWarning
from setuptools.extern.more_itertools import unique_everseen
@@ -98,7 +102,7 @@ class build_py(orig.build_py):
package,
src_dir,
)
- globs_expanded = map(glob, patterns)
+ globs_expanded = map(partial(glob, recursive=True), patterns)
# flatten the expanded globs into an iterable of matches
globs_matches = itertools.chain.from_iterable(globs_expanded)
glob_files = filter(os.path.isfile, globs_matches)
@@ -129,6 +133,7 @@ class build_py(orig.build_py):
src_dirs[assert_relative(self.get_package_dir(package))] = package
self.run_command('egg_info')
+ check = _IncludePackageDataAbuse()
ei_cmd = self.get_finalized_command('egg_info')
for path in ei_cmd.filelist.files:
d, f = os.path.split(assert_relative(path))
@@ -139,8 +144,13 @@ class build_py(orig.build_py):
d, df = os.path.split(d)
f = os.path.join(df, f)
if d in src_dirs:
- if path.endswith('.py') and f == oldf:
- continue # it's a module, not data
+ if f == oldf:
+ if check.is_module(f):
+ continue # it's a module, not data
+ else:
+ importable = check.importable_subpackage(src_dirs[d], f)
+ if importable:
+ check.warn(importable)
mf.setdefault(src_dirs[d], []).append(path)
def get_data_files(self):
@@ -240,3 +250,44 @@ def assert_relative(path):
% path
)
raise DistutilsSetupError(msg)
+
+
+class _IncludePackageDataAbuse:
+ """Inform users that package or module is included as 'data file'"""
+
+ MESSAGE = """\
+ !!\n\n
+ ############################
+ # Package would be ignored #
+ ############################
+ Python recognizes {importable!r} as an importable package, however it is
+ included in the distribution as "data".
+ This behavior is likely to change in future versions of setuptools (and
+ therefore is considered deprecated).
+
+ Please make sure that {importable!r} is included as a package by using
+ setuptools' `packages` configuration field or the proper discovery methods.
+
+ You can read more about "package discovery" and "data files" on setuptools
+ documentation page.
+ \n\n!!
+ """
+
+ def __init__(self):
+ self._already_warned = set()
+
+ def is_module(self, file):
+ return file.endswith(".py") and file[:-len(".py")].isidentifier()
+
+ def importable_subpackage(self, parent, file):
+ pkg = Path(file).parent
+ parts = list(itertools.takewhile(str.isidentifier, pkg.parts))
+ if parts:
+ return ".".join([parent, *parts])
+ return None
+
+ def warn(self, importable):
+ if importable not in self._already_warned:
+ msg = textwrap.dedent(self.MESSAGE).format(importable=importable)
+ warnings.warn(msg, SetuptoolsDeprecationWarning, stacklevel=2)
+ self._already_warned.add(importable)
diff --git a/setuptools/config/_apply_pyprojecttoml.py b/setuptools/config/_apply_pyprojecttoml.py
index a580b63f..4b4ed9df 100644
--- a/setuptools/config/_apply_pyprojecttoml.py
+++ b/setuptools/config/_apply_pyprojecttoml.py
@@ -16,6 +16,8 @@ from types import MappingProxyType
from typing import (TYPE_CHECKING, Any, Callable, Dict, List, Optional, Set, Tuple,
Type, Union)
+from setuptools._deprecation_warning import SetuptoolsDeprecationWarning
+
if TYPE_CHECKING:
from setuptools._importlib import metadata # noqa
from setuptools.dist import Distribution # noqa
@@ -75,6 +77,12 @@ def _apply_tool_table(dist: "Distribution", config: dict, filename: _Path):
for field, value in tool_table.items():
norm_key = json_compatible_key(field)
+
+ if norm_key in TOOL_TABLE_DEPRECATIONS:
+ suggestion = TOOL_TABLE_DEPRECATIONS[norm_key]
+ msg = f"The parameter `{norm_key}` is deprecated, {suggestion}"
+ warnings.warn(msg, SetuptoolsDeprecationWarning)
+
norm_key = TOOL_TABLE_RENAMES.get(norm_key, norm_key)
_set_config(dist, norm_key, value)
@@ -181,8 +189,10 @@ def _python_requires(dist: "Distribution", val: dict, _root_dir):
def _dependencies(dist: "Distribution", val: list, _root_dir):
- existing = getattr(dist, "install_requires", [])
- _set_config(dist, "install_requires", existing + val)
+ if getattr(dist, "install_requires", []):
+ msg = "`install_requires` overwritten in `pyproject.toml` (dependencies)"
+ warnings.warn(msg)
+ _set_config(dist, "install_requires", val)
def _optional_dependencies(dist: "Distribution", val: dict, _root_dir):
@@ -305,6 +315,9 @@ PYPROJECT_CORRESPONDENCE: Dict[str, _Correspondence] = {
}
TOOL_TABLE_RENAMES = {"script_files": "scripts"}
+TOOL_TABLE_DEPRECATIONS = {
+ "namespace_packages": "consider using implicit namespaces instead (PEP 420)."
+}
SETUPTOOLS_PATCHES = {"long_description_content_type", "project_urls",
"provides_extras", "license_file", "license_files"}
diff --git a/setuptools/config/setupcfg.py b/setuptools/config/setupcfg.py
index d485a8bb..b2d5c346 100644
--- a/setuptools/config/setupcfg.py
+++ b/setuptools/config/setupcfg.py
@@ -12,6 +12,7 @@ from typing import (TYPE_CHECKING, Callable, Any, Dict, Generic, Iterable, List,
from distutils.errors import DistutilsOptionError, DistutilsFileError
from setuptools.extern.packaging.version import Version, InvalidVersion
from setuptools.extern.packaging.specifiers import SpecifierSet
+from setuptools._deprecation_warning import SetuptoolsDeprecationWarning
from . import expand
@@ -507,7 +508,7 @@ class ConfigMetadataHandler(ConfigHandler["DistributionMetadata"]):
parse_list,
"The requires parameter is deprecated, please use "
"install_requires for runtime dependencies.",
- DeprecationWarning,
+ SetuptoolsDeprecationWarning,
),
'obsoletes': parse_list,
'classifiers': self._get_parser_compound(parse_file, parse_list),
@@ -516,7 +517,7 @@ class ConfigMetadataHandler(ConfigHandler["DistributionMetadata"]):
exclude_files_parser('license_file'),
"The license_file parameter is deprecated, "
"use license_files instead.",
- DeprecationWarning,
+ SetuptoolsDeprecationWarning,
),
'license_files': parse_list,
'description': parse_file,
@@ -584,7 +585,12 @@ class ConfigOptionsHandler(ConfigHandler["Distribution"]):
'scripts': parse_list,
'eager_resources': parse_list,
'dependency_links': parse_list,
- 'namespace_packages': parse_list,
+ 'namespace_packages': self._deprecated_config_handler(
+ parse_list,
+ "The namespace_packages parameter is deprecated, "
+ "consider using implicit namespaces instead (PEP 420).",
+ SetuptoolsDeprecationWarning,
+ ),
'install_requires': parse_list_semicolon,
'setup_requires': parse_list_semicolon,
'tests_require': parse_list_semicolon,
diff --git a/setuptools/dist.py b/setuptools/dist.py
index 5507167d..37021ac7 100644
--- a/setuptools/dist.py
+++ b/setuptools/dist.py
@@ -280,6 +280,11 @@ def check_nsp(dist, attr, value):
nsp,
parent,
)
+ msg = (
+ "The namespace_packages parameter is deprecated, "
+ "consider using implicit namespaces instead (PEP 420).",
+ )
+ warnings.warn(msg, SetuptoolsDeprecationWarning)
def check_extras(dist, attr, value): This release was mainly about warnings (+ recursive globs for That is why I am considering that this might have been caused by the dependency update ( |
I don't trust that v62.3 release is implicated here. In #3330, abravalheri put together a test to capture the failure, but if I apply that test to the release prior to 62.3, the test still fails, suggesting that the issue wasn't caused by the 62.3 release:
|
Trying to replicate the issue using the reported instructions, I'm unable to do so:
Aha. The issue was fixed in main by removing the offending comment in yt-project/yt@e355df7. I am able to replicate the issue using |
And digging deeper into the history, I see the comment was added to the setup.cfg in yt-project/yt@d3500c7, so it wasn't a Setuptools regression at all, but the user expecting a behavior that was likely never present. |
I see. Sorry for the confusion. I don't really get how my adding a comment there survived CI however, but I can live with it. Thank you for your feedback ! |
Thank you Jason and Clément. Let's leave this aside for now. Ideally we want to try avoiding adding more features to |
Perfectly understandable. Good luck to you guys with supporting |
setuptools version
62.3.0 to 62.3.1
Python version
3.7 to 3.10
OS
Linux, MacOS, Windows
Additional environment information
No response
Description
I can't build wheels for yt since the 62.3.0 release. 62.3.1 didn't solve it either.
I'm seeing this on yt's regular wheel building jobs (for all major platforms, from Python 3.7 to 3.10)
https://github.com/yt-project/yt/runs/6467399046?check_suite_focus=true
I assume this problem isn't specific to yt and affects other projects as well, but I haven't found any duplicate so far.
Expected behavior
I expect the build to complete
How to Reproduce
python -m venv .env source .env/bin/activate python -m pip install --upgrade setuptools python -m pip install git+https://github.com/yt-project/yt.git
Output
The actual version string embedded in yt's source code is
'4.1.dev0'
, which I believe is PEP 440 compliant.The text was updated successfully, but these errors were encountered: