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

--dependencies-transitive doesn't list third-party transitive dependencies #12733

Open
oliverdain opened this issue Sep 1, 2021 · 7 comments

Comments

@oliverdain
Copy link

Describe the bug
I wanted to find all the 3rd party dependencies for some of my code so I ran:

./pants dependencies --dependencies-transitive --dependencies-type=3rdparty device/coordinator/

It output:

fastapi[all]
hypercorn
pydantic
requests
types-requests

but some of those dependencies also have dependencies which were not output. For example hypercorn depends on h2, h11, priority, etc. You can see the full list here: https://github.com/pgjones/hypercorn/blob/master/setup.py

Pants version
2.6.0

OS
Linux (not tested on Mac). Debian Bullseye to be specific.

@oliverdain oliverdain added the bug label Sep 1, 2021
@jsirois
Copy link
Contributor

jsirois commented Sep 1, 2021

@oliverdain this is a known limitation of the dependencies goal going back to its inception in ~2010. Our docs could be better, but this only operates in the repository despite what the words in --dependencies-transitive --dependencies-type=3rdparty sound like, which is "please run a resolve to get this data", which we definitely don't do and have never done. It would be a really useful feature though!

@jsirois
Copy link
Contributor

jsirois commented Sep 1, 2021

I've marked this as answered but left open pending a doc fix at the least. If you're up for doing that or adding a companion feature request issue -that' would be wonderful, but of course beyond the call of duty too.

@Eric-Arellano
Copy link
Contributor

(Clicked wrong botton, sorry for noise.)

Semi-related: I also think the --type=3rdparty name is really confusing. Its sibling --type=source doesn't actually get you just first-party code. All it does is get you target addresses for everything, whereas --type=3rdparty gets you the raw requirement strings for all of your python_requirement_library targets that your code depends on. It should probably be something instead like dependencies --type=3rdparty --format=raw_requirement, where the former filters and the latter says to use a target address vs. requirement string.

P.S. @oliverdain in your example, you can use --type and --transitive w/o the dependencies prefix because those options happen after the dependencies goal is specified. That is, `./pants dependencies --transitive --type=3rdparty device/coordinator/

@benjyw
Copy link
Contributor

benjyw commented Oct 18, 2021

Feature request: #13283

@huonw
Copy link
Contributor

huonw commented Nov 21, 2022

I tripped over this: we got a vulnerability alert about one of our transitive/indirect dependencies and wanted to work out what code might be affected... and we had to do that manually because there doesn't seem to be a way to have pants tell us this automatically (e.g. ./pants dependees --transitive path/to/target#some-lib doesn't work).

Related discussion: https://pantsbuild.slack.com/archives/C046T6T9U/p1668753609863079. In that thread, it was raised that 'synthetic targets' might help make this easier to implement.

@benjyw
Copy link
Contributor

benjyw commented Nov 21, 2022

Yeah, this is a feature we could relatively easily implement, if you're using lockfiles, since all the data is there.

huonw added a commit that referenced this issue Mar 3, 2023
This has the `peek` output include the fingerprint of the sources
referenced in a target. This is a step towards #8445, by putting more
information into `peek`.

For instance, with this, one way to get a crude "hash" of a target would
be something like:

```shell
{ 
   pants dependencies --transitive --closed path/to:target | xargs pants peek
   # these might change behaviour and so need to be included
   cat pants.toml
   cat 3rdparty/python/default.lock # or whatever other lock files are relevant
} | openssl sha256
```

This is conservative: the hash can be different without the behaviour of
the target changing at all. For instance:

- irrelevant changes in `pants.toml`: adjusting comments, unrelated
subsystem config (e.g. settings in `[golang]` when `path/to:target` is a
Python-only `pex_binary`)
- upgrading 3rd party dependencies in the resolve that aren't
(transitively) used by `path/to:target`. This relates to #12733: if all
transitive 3rd party deps appeared in `pants dependencies --transitive`,
and `pants peek` included the right info for them (e.g. version and
fingerprints), the `cat 3rdparty/...` could be removed because the
`peek` pipe would handle it.
- target fields that don't impact execution behaviour, e.g. changing the
`skip_black` setting on a `python_source` target, without changing the
file contents (this might be _most_ fields on the (transitive)
dependencies of a packageable target?)

This is also only the hash of the input configuration, rather than a
hash of a built artefact. If there's processes that aren't deterministic
(e.g. `shell_command(command="date > output.txt",
output_files=["output.txt"])` somewhere in the chain), the exact output
artefact might be different if built twice, even if the hash hasn't
changed.

This PR is, in some sense, a partial revival of #8450, although is much
simpler, because the JSON-outputting `peek` target already exists, and
this doesn't try to solve the full problem.
@thejcannon
Copy link
Member

I just found out one of our transitive deps uses GPL, but we only use it for tests.

So either we yank it out because danger, or a ENFORCE (via visibility rules) nothing we ship depends on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants