Skip to content
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

Show full dependency chain when uv pip compile encounters an error running setup.py #8962

Closed
alex opened this issue Nov 9, 2024 · 10 comments · Fixed by #9108
Closed

Show full dependency chain when uv pip compile encounters an error running setup.py #8962

alex opened this issue Nov 9, 2024 · 10 comments · Fixed by #9108
Assignees
Labels
error messages Messaging when something goes wrong resolver Related to the package resolver

Comments

@alex
Copy link
Contributor

alex commented Nov 9, 2024

When using --resolution=lowest (or lowest-direct), it's sadly not uncommon to hit errors running setup.py from very old versions of things.

Unfortunately, uv pip compile does not include the full chain of how a dependency was depended on, which can make it difficult to debug. For example:

~/p/cryptography ❯❯❯ uv pip compile --resolution=lowest-direct --universal -p 3.7 --extra=docs --extra=docstest --extra=pep8test --extra=test --extra=test-randomorder --extra=nox --extra=sdist --unsafe-package=cffi --unsafe-package=pycparser --unsafe-package=setuptools --unsafe-package=cryptography-vectors pyproject.toml > ci-constraints-requirements.txt && git diff
warning: The requested Python version 3.7 is not available; 3.13.0 will be used to build dependencies instead.
⠙ Resolving dependencies...                                                                                                  warning: The direct dependency `build` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `certifi` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `check-sdist{python_full_version >= '3.8'}` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `click` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `cryptography-vectors` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `mypy` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `nox` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `pretend` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `pytest-benchmark` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `pytest-cov` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `pytest-randomly` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `pytest-xdist` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `readme-renderer` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
warning: The direct dependency `ruff` is unpinned. Consider setting a lower bound when using `--resolution-strategy lowest` to avoid using outdated versions.
⠋ atomicwrites==1.4.1                                                                                                          × Failed to download and build `wsgiref==0.1.2`
  ╰─▶ Build backend failed to determine requirements with `build_wheel()` (exit status: 1)

      [stderr]
      Traceback (most recent call last):
        File "<string>", line 14, in <module>
          requires = get_requires_for_build({})
        File "/Users/alex_gaynor/Library/Caches/uv/builds-v0/.tmpefXcVs/lib/python3.13/site-packages/setuptools/build_meta.py",
      line 333, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/alex_gaynor/Library/Caches/uv/builds-v0/.tmpefXcVs/lib/python3.13/site-packages/setuptools/build_meta.py",
      line 303, in _get_build_requires
          self.run_setup()
          ~~~~~~~~~~~~~~^^
        File "/Users/alex_gaynor/Library/Caches/uv/builds-v0/.tmpefXcVs/lib/python3.13/site-packages/setuptools/build_meta.py",
      line 521, in run_setup
          super().run_setup(setup_script=setup_script)
          ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/alex_gaynor/Library/Caches/uv/builds-v0/.tmpefXcVs/lib/python3.13/site-packages/setuptools/build_meta.py",
      line 319, in run_setup
          exec(code, locals())
          ~~~~^^^^^^^^^^^^^^^^
        File "<string>", line 5, in <module>
        File
      "/Users/alex_gaynor/Library/Caches/uv/sdists-v6/pypi/wsgiref/0.1.2/TC3J4nFCD9kJFnrhcTIuq/wsgiref-0.1.2.zip/ez_setup/__init__.py",
      line 170
          print "Setuptools version",version,"or greater has been installed."
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?

~/p/cryptography ❯❯❯ 

Here, neither wsgiref nor atomicwrites is depended on directly, so I'm not sure which package I need to attach a minimal bound to.

@charliermarsh charliermarsh added enhancement New feature or improvement to existing functionality resolver Related to the package resolver labels Nov 9, 2024
@charliermarsh
Copy link
Member

Yeah I think something like this makes sense.

@charliermarsh charliermarsh self-assigned this Nov 10, 2024
@charliermarsh
Copy link
Member

One problem here is that if this happens during installation (rather than resolution), we may have already discarded the resolution itself (which would explain why it's included).

@charliermarsh
Copy link
Member

Actually, at the point we need it do we do still have it.

@charliermarsh charliermarsh added error messages Messaging when something goes wrong and removed enhancement New feature or improvement to existing functionality labels Nov 11, 2024
@charliermarsh
Copy link
Member

I'm working on this, I think it will be a great feature, but it's non-trivial.

charliermarsh added a commit that referenced this issue Nov 12, 2024
## Summary

Shows similar diagnostics for failures that happen at install time,
rather than resolve time. This will ultimately feed into
#8962 since we'll now have
consolidated handling for these kinds of failures.
charliermarsh added a commit that referenced this issue Nov 13, 2024
## Summary

In #9078, resolution fails because
we fail to build `jsmin`. However... if you look at what's actually
happening, `jsmin` fails to build during _prefetching_. And we never
actually attempt to access its metadata later on.

This PR modifies the metadata result handling such that we don't raise
these errors until the resolver actually asks for the metadata, so
#9078 now succeeds.

I actually had to make this change anyway in pursuing
#8962, so I've decided to carve it
out here.

Closes #9078.
charliermarsh added a commit that referenced this issue Nov 14, 2024
## Summary

I need this for the derivation chain work
(#8962), but it just seems
generally useful. You can't always get a version from a `Dist` (it could
be URL-based!), but when we create a `ResolvedDist`, we _do_ know the
version (and not just the URL). This PR preserves it.
@dimaqq
Copy link

dimaqq commented Nov 14, 2024

Feature idea: multi-dimensional uv bisect to determine the actual lower bounds for dependencies 🎉

charliermarsh added a commit that referenced this issue Nov 14, 2024
## Summary

This PR should not contain any user-visible changes, but the goal is to
refactor the `Resolution` type to retain a dependency graph. We want to
be able to explain _why_ a given package was excluded on error (see:
#8962), which in turn requires
that at install time, we can go back and figure out the dependency
chain. At present, `Resolution` is just a map from package name to
distribution; this PR remodels it as a graph in which each node is a
package, and the edges contain markers plus extras or dependency groups.
@alex
Copy link
Contributor Author

alex commented Nov 14, 2024 via email

@charliermarsh
Copy link
Member

@alex -- Do you know how to reproduce this failure? I'd be interested to test the behavior on it.

@alex
Copy link
Contributor Author

alex commented Nov 14, 2024

uv pip compile --resolution=lowest-direct --universal -p 3.7 --extra=docs --extra=docstest --extra=pep8test --extra=test --extra=test-randomorder --extra=nox --extra=sdist --unsafe-package=cffi --unsafe-package=pycparser --unsafe-package=setuptools --unsafe-package=cryptography-vectors pyproject.toml in a checkout of github.com/pyca/cryptography

@charliermarsh
Copy link
Member

Ok I think there's some bug that's preventing it from showing up there in that more complex scenario, so won't be in this release -- sorry!

@charliermarsh
Copy link
Member

Fixed!

`wsgiref` was included because `mypy==0.1` depends on `yaro==0.6.4` which depends on `wsgiref`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong resolver Related to the package resolver
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants