Skip to content

[BUG] No filename and code hints in traceback #4815

Open
@MarcinKonowalczyk

Description

@MarcinKonowalczyk

setuptools version

setuptools==75.8.0

Python version

Python 3.14.0a4+ (heads/main:5c9a63f, Jan 29 2025, 12:10:34) [Clang 16.0.0 (clang-1600.0.26.6)] on darwin

Also tested on 3.12.3. I don't believe this is python-version specific.

OS

macOS

Additional environment information

No response

Description

I'm trying to install a package which has an error in its setup.py (see here if you want, but the details there are not important. ). The issue is that the filename and code hints do not show up in the traceback.

Expected behavior

Seeing filename and code hints in the traceback.

How to Reproduce

mkdir bad_package
cd bad_package
cat > setup.py << EOF
class BadPackageError(Exception):
    pass

def foo():
    raise BadPackageError("This package is bad")

def bar():
    foo()

def baz():
    bar()

baz()
EOF

pip install --no-build-isolation .

Output

Looking in indexes: https://pypi.org/simple
Processing ~/git/bad_package
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [20 lines of output]
      Traceback (most recent call last):
        File "~/.pyenv/versions/3.12.3/envs/default/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "~/.pyenv/versions/3.12.3/envs/default/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "~/.pyenv/versions/3.12.3/envs/default/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 149, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "~/.pyenv/versions/3.12.3/envs/default/lib/python3.12/site-packages/setuptools/build_meta.py", line 377, in prepare_metadata_for_build_wheel
          self.run_setup()
        File "~/.pyenv/versions/3.12.3/envs/default/lib/python3.12/site-packages/setuptools/build_meta.py", line 522, in run_setup
          super().run_setup(setup_script=setup_script)
        File "~/.pyenv/versions/3.12.3/envs/default/lib/python3.12/site-packages/setuptools/build_meta.py", line 320, in run_setup
          exec(code, locals())
        File "<string>", line 14, in <module>
        File "<string>", line 12, in baz
        File "<string>", line 9, in bar
        File "<string>", line 6, in foo
      BadPackageError: This package is bad
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions