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
Use of (Deprecated) pep517 Package Hides setup.py Syntax Errors #1627
Comments
Something as simple as this seems pretty close, but seems to fail on diff --git a/piptools/scripts/compile.py b/piptools/scripts/compile.py
index 0a2e828..224bfdc 100755
--- a/piptools/scripts/compile.py
+++ b/piptools/scripts/compile.py
@@ -6,8 +6,8 @@ import tempfile
from typing import IO, Any, BinaryIO, List, Optional, Tuple, Union, cast
import click
+from build.util import project_wheel_metadata
from click.utils import LazyFile, safecall
-from pep517 import meta
from pip._internal.commands import create_command
from pip._internal.req import InstallRequirement
from pip._internal.req.constructors import install_req_from_line
@@ -405,12 +405,14 @@ def cli(
constraints.extend(reqs)
elif is_setup_file:
setup_file_found = True
- dist = meta.load(os.path.dirname(os.path.abspath(src_file)))
- comes_from = f"{dist.metadata.get_all('Name')[0]} ({src_file})"
+ metadata = project_wheel_metadata(
+ os.path.dirname(os.path.abspath(src_file))
+ )
+ comes_from = f"{metadata.get_all('Name')[0]} ({src_file})"
constraints.extend(
[
install_req_from_line(req, comes_from=comes_from)
- for req in dist.requires or []
+ for req in metadata.get_all("Requires-Dist") or []
]
)
else:
diff --git a/setup.cfg b/setup.cfg
index 9e9215e..5d84058 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -30,8 +30,8 @@ packages = find:
zip_safe = false
install_requires =
# direct dependencies
+ build
click >= 7
- pep517
pip >= 21.2
# indirect dependencies
setuptools # typically needed when pip-tools invokes setup.py
|
Although the error output when using /home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Traceback (most recent call last):
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/build/__init__.py", line 482, in _handle_backend
yield
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/build/__init__.py", line 369, in get_requires_for_build
return set(get_requires(config_settings))
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/pep517/wrappers.py", line 172, in get_requires_for_build_wheel
return self._call_hook('get_requires_for_build_wheel', {
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/pep517/wrappers.py", line 322, in _call_hook
self._subprocess_runner(
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/build/__init__.py", line 320, in _runner
self._hook_runner(cmd, cwd, extra_environ)
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/pep517/wrappers.py", line 75, in quiet_subprocess_runner
check_output(cmd, cwd=cwd, env=env, stderr=STDOUT)
File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.10/subprocess.py", line 524, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/tmp/build-env-syt2th92/bin/python', '/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/pep517/in_process/_in_process.py', 'get_requires_for_build_wheel', '/tmp/tmp_1mc294c']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/bin/pip-compile", line 33, in <module>
sys.exit(load_entry_point('pip-tools', 'console_scripts', 'pip-compile')())
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "/home/andy/Code/pip-tools/piptools/scripts/compile.py", line 408, in cli
metadata = project_wheel_metadata(
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/build/util.py", line 54, in project_wheel_metadata
env.install(builder.get_requires_for_build('wheel'))
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/build/__init__.py", line 368, in get_requires_for_build
with self._handle_backend(hook_name):
File "/usr/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/home/andy/.local/share/venvs/1b2b5c9cc79c4656dd687f3b665b224c/venv/lib/python3.10/site-packages/build/__init__.py", line 490, in _handle_backend
raise BuildBackendException(exception, f'Backend subprocess exited when trying to invoke {hook}')
build.BuildBackendException: Backend subprocess exited when trying to invoke get_requires_for_build_wheel |
I've started #1629 for this; feel free to suggest some good error language, here or there. |
OK, current output for the error in that branch looks like:
I'm going to promote the PR from draft to ready-for-review, and please try it out and let me know what you think. Thanks! |
Just updating that the message's |
This comment was marked as resolved.
This comment was marked as resolved.
Fixed my last issue (was on an ancient |
Thanks for the issue, it was a push that helped me get that tooling change done that I'd been looking forward to/dreading, and the new concise error is much more communicative. Closing as fixed since it's merged and will be in the next release. |
Running
python -m piptools compile
when thesetup.py
file has invalid Python in it leads to this unhelpful error message from thepep517
package:This issue has been brought up in the issue tracker for that project (pypa/pyproject-hooks#142). The response was that the API being used was a proof-of-concept and is now deprecated. As such
pip-tools
should look into using an alternative.Environment Versions
3.8.10
22.1.1
6.6.1
Steps to replicate
setup.py
file that contains invalid python. Mine has a single line:setup(
pip install pip-tools
.python -m piptools compile
.Expected result
Print something mentioning that the
setup.py
file failed to be parsed/loaded.Actual result
Get the above error message.
The text was updated successfully, but these errors were encountered: