-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
Mysterious error with optional dependencies in pyproject.toml #1711
Comments
I've dug in a bit more and it's weirder than I thought. This following pyproject.toml doesn't work:
However, if you remove the
How odd is that?! |
Thanks! Can you post the entire |
That is the entire |
It usually should be there if it's describing an installable package, but I'm not sure if it ought to be strictly mandatory here. Looking at PEP 518:
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel"] # PEP 508 specifications.
|
My thought at the moment is that if you add the above sample section and it works, then this is a bug, since when omitted
|
A colleague has tracked down the source of the problem. If you check
Putting the authors = [{ name = "author1", email = "author1@email.com" }] |
I'm glad you've found the root of the issue. I'll close this since there's no action required regarding pip-tools. Thanks for the issue! |
Thanks for your help @atugushev. It may still be worth opening a separate issue re having better error reporting in the case where the |
If you think that this could be improved on the build side feel free to report on https://github.com/pypa/build/issues. |
Ouch, sorry. This is the pip-tools' message: pip-tools/piptools/scripts/compile.py Line 479 in eff8476
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
I've stumbled upon this issue a couple of times in the last month. Here is the error I see: $ pip-compile pyproject.toml -v
Creating venv isolated environment...
Installing packages in isolated environment... (setuptools >= 40.8.0, wheel)
Getting build dependencies for wheel...
Backend subprocess exited when trying to invoke get_requires_for_build_wheel
Failed to parse /Users/vduseev/Projects/OSS/opensearch-logger/pyproject.toml SetupEnvironment:
The [build-system]
requires = [
"flit_core >=3.2,<4",
]
build-backend = "flit_core.buildapi"
[project]
name = "opensearch-logger"
version = "1.2.1"
requires-python = ">=3.6"
dependencies = ["opensearch-py"] What causes itIt's definitely not a pip-tools/piptools/scripts/compile.py Lines 474 to 476 in eff8476
The I have no idea how it is supposed to work, but it looks like the ['/private/var/folders/59/45422z7x04vc6pztgy7xm51m0000gn/T/build-env-rj6bf2id/bin/python', '/Users/vduseev/Projects/Playground/pip-tools-bug/.venv/lib/python3.11/site-packages/pep517/in_process/_in_process.py', 'get_requires_for_build_wheel', '/var/folders/59/45422z7x04vc6pztgy7xm51m0000gn/T/tmpb6wdunjz'] Obviously, when something wrong happens in that subprocess script all we get at the end is:
But in reality, the real error does not ever get propagated to the parent process and we don't see it. I've caught it by instrumenting the Exception: description must be specified under [project] or listed as a dynamic field
_in_process.py was called with args: ['/Users/vduseev/Projects/Playground/pip-tools-bug/.venv/lib/python3.11/site-packages/pep517/in_process/_in_process.py', 'get_requires_for_build_wheel', '/var/folders/59/45422z7x04vc6pztgy7xm51m0000gn/T/tmpttsp4wmf']
Exception: description must be specified under [project] or listed as a dynamic field
File "/Users/vduseev/Projects/Playground/pip-tools-bug/.venv/lib/python3.11/site-packages/pep517/in_process/_in_process.py", line 338, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/vduseev/Projects/Playground/pip-tools-bug/.venv/lib/python3.11/site-packages/pep517/in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/59/45422z7x04vc6pztgy7xm51m0000gn/T/build-env-tpnuh3w_/lib/python3.11/site-packages/flit_core/buildapi.py", line 23, in get_requires_for_build_wheel
info = read_flit_config(pyproj_toml)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/59/45422z7x04vc6pztgy7xm51m0000gn/T/build-env-tpnuh3w_/lib/python3.11/site-packages/flit_core/config.py", line 79, in read_flit_config
return prep_toml_config(d, path)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/59/45422z7x04vc6pztgy7xm51m0000gn/T/build-env-tpnuh3w_/lib/python3.11/site-packages/flit_core/config.py", line 106, in prep_toml_config
loaded_cfg = read_pep621_metadata(d['project'], path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/private/var/folders/59/45422z7x04vc6pztgy7xm51m0000gn/T/build-env-tpnuh3w_/lib/python3.11/site-packages/flit_core/config.py", line 630, in read_pep621_metadata
raise ConfigError( Now I can see that the underlying error actually comes from the How to get the same outputHere is what I manually added to the def main():
# begin: added
from pathlib import Path
log_file = Path(__file__).parent / "log.txt"
with log_file.open("a") as f:
try:
# end: added
if len(sys.argv) < 3:
sys.exit("Needs args: hook_name, control_dir")
hook_name = sys.argv[1]
control_dir = sys.argv[2]
if hook_name not in HOOK_NAMES:
sys.exit("Unknown hook: %s" % hook_name)
hook = globals()[hook_name]
hook_input = read_json(pjoin(control_dir, 'input.json'))
json_out = {'unsupported': False, 'return_val': None}
try:
json_out['return_val'] = hook(**hook_input['kwargs'])
except BackendUnavailable as e:
json_out['no_backend'] = True
json_out['traceback'] = e.traceback
except BackendInvalid as e:
json_out['backend_invalid'] = True
json_out['backend_error'] = e.message
except GotUnsupportedOperation as e:
json_out['unsupported'] = True
json_out['traceback'] = e.traceback
except HookMissing as e:
json_out['hook_missing'] = True
json_out['missing_hook_name'] = e.hook_name or hook_name
write_json(json_out, pjoin(control_dir, 'output.json'), indent=2)
# begin: more_added
except Exception as e:
f.write(f"Exception: {e}\n")
import traceback
traceback.print_tb(e.__traceback__, file=f)
# end: more_added Fixing the issueI can address the complaints of
And voila: #
# This file is autogenerated by pip-compile with python 3.11
# To update, run:
#
# pip-compile pyproject.toml
#
certifi==2022.9.24
# via
# opensearch-py
# requests
charset-normalizer==2.1.1
# via requests
idna==3.4
# via requests
opensearch-py==2.0.0
# via opensearch-logger (pyproject.toml)
requests==2.28.1
# via opensearch-py
urllib3==1.26.13
# via
# opensearch-py
# requests Alternatively, should I swap the build system to classic setuptools, it compiles successfully even without said fixes. [build-system]
requires = [
"setuptools",
"wheel",
]
build-backend = "setuptools.build_meta"
[project]
name = "opensearch-logger"
version = "1.2.1"
requires-python = ">=3.6"
dependencies = ["opensearch-py"] ConclusionI don't understand why such system was chosen by creators of build system (not pip-tools). This is the reason we don't see an underlying problem from the chosen build system. It just does not get propagated to higher level tools, such as P.S. was so happy to see @atugushev in the comments of this issue. Cheers! |
@vduseev thanks for chiming in and for the additional context! Digging into the issue I found that Patched diff --git src/build/util.py src/build/util.py
index 9675393..a435479 100644
--- src/build/util.py
+++ src/build/util.py
@@ -43,7 +43,7 @@ def project_wheel_metadata(
"""
builder = build.ProjectBuilder(
os.fspath(srcdir),
- runner=pep517.quiet_subprocess_runner,
+ runner=pep517.default_subprocess_runner,
)
if not isolated:
root@35878ab01f42:/foo# pip-compile pyproject.toml
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 351, in <module>
main()
File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 333, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/lib/python3.10/site-packages/pep517/in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
return hook(metadata_directory, config_settings)
File "/usr/local/lib/python3.10/site-packages/flit_core/buildapi.py", line 47, in prepare_metadata_for_build_wheel
ini_info = read_flit_config(pyproj_toml)
File "/usr/local/lib/python3.10/site-packages/flit_core/config.py", line 79, in read_flit_config
return prep_toml_config(d, path)
File "/usr/local/lib/python3.10/site-packages/flit_core/config.py", line 106, in prep_toml_config
loaded_cfg = read_pep621_metadata(d['project'], path)
File "/usr/local/lib/python3.10/site-packages/flit_core/config.py", line 630, in read_pep621_metadata
raise ConfigError(
flit_core.config.ConfigError: description must be specified under [project] or listed as a dynamic field
Backend subprocess exited when trying to invoke prepare_metadata_for_build_wheel
Failed to parse /foo/pyproject.toml @pradyunsg I wonder if would it be okay to introduce one of the following params in
|
This comment was marked as resolved.
This comment was marked as resolved.
FTR: tracking issue pypa/build#553 for |
I just saw this, and I would've suggested that you do exactly what you've done. :) |
I had a bad whitespace, a '\t' (tab) in a quoted string, that caused this issue; TOML Linter found it. |
I found another case today where this error can occur:. I started with a working The clue for me was that Running validate-projected returned no errors.
|
Regarding that last example, it seems to be about the way setuptools auto-discovers the project structure, and can be avoided with [tool.setuptools]
py-modules = [] Aside from that I'll note that the alternative runner selection is now in |
pip-compile omitted all error logs, I have to use |
- Use pip-tools' pip-compile command via '.venv/bin/pip-compile' - Note: For pip-compile to work for this project we have to add: ``` [tool.setuptools] py-modules = [] ``` Details here: - jazzband/pip-tools#1711 (comment) - pypa/setuptools#3197 (comment)
- Use pip-tools' pip-compile command via '.venv/bin/pip-compile' - Note: For pip-compile to work for this project we have to add: ``` [tool.setuptools] py-modules = [] ``` Details here: - jazzband/pip-tools#1711 (comment) - pypa/setuptools#3197 (comment)
- Use pip-tools' pip-compile command via '.venv/bin/pip-compile' - Note: For pip-compile to work for this project we have to add: ``` [tool.setuptools] py-modules = [] ``` Details here: - jazzband/pip-tools#1711 (comment) - pypa/setuptools#3197 (comment)
I also experienced this problem. I have a valid |
- Add tool.setuptools section to avoid this mysterious issue: jazzband/pip-tools#1711
for the record, |
So the errors come because pip-compile swallows output of In the case of a flatlayout with multiple packages, mentioned by @cout
|
this also solved the problem for me. |
- Add tool.setuptools section to avoid this mysterious issue: jazzband/pip-tools#1711
- Add tool.setuptools section to avoid this mysterious issue: jazzband/pip-tools#1711
Thanks for that, gives way more descriptive error and it turned out that it my case it was related to write permissions. |
I had the same error
I rolled back pip-tools to 7.3.0 then for some reason I got a more useful output:
Because I had moved my source files from project root to a src folder and after a bit of back and forth in git, the old folder had reappeared empty. I figured I'd leave a not here in case it helps anyone. |
I have been following the guide in the README file on how to use pip-tools with pyproject.toml. Unfortunately, if I add a
project.optional-dependencies
section to pyproject.toml, regardless of what its contents are, I get the following error:Environment Versions
python 3.9.13
pip 22.2.2 from C:\ProgramData\Miniconda3\lib\site-packages\pip (python 3.9)
pip-compile, version 6.9.0
Steps to replicate
project.optional-dependencies
section to yourpyproject.toml
pip-compile pyproject.toml
The text was updated successfully, but these errors were encountered: