Problem:
Python projects that use setuptools > 66.1.0 fail to be imported (from SCM) or tested/monitored (from CLI)
Discussion:
Snyk has identified a bug with the usage of the latest versions of setuptools that is causing import and testing issues.
This is an example error message when testing a project from the CLI:
Failed to test pip project
While the debug logs error message would look like this:
snyk:run-test Error running test {
error: 'Traceback (most recent call last):\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3030, in _dep_map\n' +
' return self.__dep_map\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2826, in __getattr__\n' +
' raise AttributeError(attr)\n' +
'AttributeError: _DistInfoDistribution__dep_map\n' +
'\n' +
'During handling of the above exception, another exception occurred:\n' +
'\n' +
'Traceback (most recent call last):\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 35, in __init__\n' +
' parsed = parse_requirement(requirement_string)\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 64, in parse_requirement\n' +
' return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 82, in _parse_requirement\n' +
' url, specifier, marker = _parse_requirement_details(tokenizer)\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 120, in _parse_requirement_details\n' +
' specifier = _parse_specifier(tokenizer)\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/_parser.py", line 206, in _parse_specifier\n' +
' with tokenizer.enclosing_tokens("LEFT_PARENTHESIS", "RIGHT_PARENTHESIS"):\n' +
' File "/opt/homebrew/Cellar/python@3.10/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 142, in __exit__\n' +
' next(self.gen)\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/_tokenizer.py", line 183, in enclosing_tokens\n' +
' self.raise_syntax_error(\n' +
' File "/opt/homebrew/lib/python3.10/site-packages/pkg_resources/_vendor/packaging/_tokenizer.py", line 163, in raise_syntax_error\n' +
' raise ParserSyntaxError(\n' +
'pkg_resources.extern.packaging._tokenizer.ParserSyntaxError: Expected closing RIGHT_PARENTHESIS\n' +
' pytz (>dev)\n' +
' ~^\n' +
'\n' +
Workaround:
The current workaround is to pin a specific version of setuptools < 67
Note:
Snyk Engineering is currently aware of this and working on a fix