-
Notifications
You must be signed in to change notification settings - Fork 121
cargo: Allow filtering packages by name #325
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
base: master
Are you sure you want to change the base?
Conversation
Can you please explain when and why it could be useful? |
For example out of https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs we want only package "gst-plugin-gtk4", nothing else.
|
I don't see a lockfile in the project you've linked, where does the |
https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
You can |
I still fail to understand what you're trying to achieve and what could be the reason for excluding cargo dependencies from a lockfile. Just to be clear, to avoid possible misunderstandings: the |
For example out of https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs we want only package "gst-plugin-gtk4", nothing else.
|
From a workspace project like this, you select package(s) to build via cargo. Again, |
Without the filtering we'd have to download a lot of stuff that's not needed, which is wasteful. |
|
Because we can! :)
As I said, gst-plugins-rs contains multiple libraries but we only need [to build] only one of them, not all. That's why we download only the dependencies for the corresponding package, not for all the packages in the project. |
for dep in packages_dependencies(deps, all_packages): | ||
yield dep |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for dep in packages_dependencies(deps, all_packages): | |
yield dep | |
yield from packages_dependencies(deps, all_packages) |
|
||
pkg_coros = [get_package_sources(p, cargo_lock, git_repos) for p in cargo_lock['package']] | ||
if packages: | ||
packages = packages.split(',') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better do parsing earlier in the flow, ideally in main()
, and pass packages
here as a list of strings.
if packages: | ||
packages = packages.split(',') | ||
logging.debug('Considering only packages: %s', packages) | ||
all_packages = {p['name']: p for p in cargo_lock['package']} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The all_packages
dict feels out of place here, since it's only used within packages_dependencies()
scope. Better pass the whole cargo_lock
to packages_dependencies()
, and there get whatever information is needed from it.
else: | ||
pkg_sources, cargo_vendored_entry = pkg | ||
pkg_sources, cargo_vendored_entry = pkg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: please make unrelated changes in separate commits.
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('cargo_lock', help='Path to the Cargo.lock file') | ||
parser.add_argument('-p', '--packages', help='Comma-separated packages in Cargo.lock to build') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This help text is a bit misleading, since we don't control what Cargo builds. Maybe "...list of package name to fetch" would be better?
Do you plan to get back to this? I don't really like the idea having an out of band filtering here.
The upstream recommended way is to use the individual crates from crates.io https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/1765 The wget https://static.crates.io/crates/gst-plugin-audiofx/gst-plugin-audiofx-0.13.4.crate
tar xf gst-plugin-audiofx-0.13.4.crate
cd gst-plugin-audiofx-0.13.4
python flatpak-cargo-generator.py Cargo.lock |
8c5a0ec
to
ea9bfa2
Compare
Cargo.lock might contain unwanted packages.