* Call print with flush=True to get immediate output to piped files.
* Simplify code with functools.reduce or for-loops.
* Clarify error handling and messages.
* Skip output of empty dependent lists.
* Suppress output of repeated dependent lists.
* Move "revisit" logic from recursive add_non_dev_dependencies to
a while loop in add_indirect_build_deps.
This is less efficient, but more complete and easier to understand.
* Align table captions to something like:
build_deps[k] = # of non-dev-dependent packages of pkg[k]
dev_deps[k] = # of all dependent packages of pkg[k]
all_build_deps[k] = # of non-dev-dependent ... of pkg[1] to pkg[k]
all_dev_deps[k] = # of all dependent ... of pkg[1] to pkg[k]
Test: get_rust_pkg.py -h
Test: get_rust_pkg.py -v -show remain syn quote
Test: get_rust_pkg.py -v -show glob libloading
Change-Id: I6171b6be8806bcdd1129f52e7e5ccf7b274e2e8c
* With flag "-show" and a list of package names,
call crates.io api to count dependent packages.
* The packages are NOT fetched.
* Optional dependent packages are not counted.
* Indirect non-dev dependent packages are counted.
* Finally all non-dev dependent packages are also
included in the report.
* The report is a table like this:
build_deps[k] = # of non-dev-dependent packages of pkg[k]
dev_deps[k] = # of all dependent packages of pkg[k]
all_build_deps[k] = # of non-dev-dependent ... of pkg[1] to pkg[k]
all_dev_deps[k] = # of all dependent ... of pkg[1] to pkg[k]
k pkg build_deps dev_deps all_build_deps all_dev_deps
1 unicode-xid 0 0 0 0
2 proc-macro2 1 3 0 1
3 syn 2 107 0 104
4 quote 2 18 0 107
5 remain 4 18 0 107
Packages are sorted topologically by the non-dev-dependencies.
The column all_build_deps should be 0 if the topological sort
did not find cyclic dependency.
* Simplify find_dl_path with a crates.io api call to get max_version.
* Handle urllib.error.HTTPError exception
* Formatted by pyformat.
Test: get_rust_pkg.py -h
Test: get_rust_pkg.py -show syn remain quote
Test: get_rust_pkg.py -v -show remain syn quote
Change-Id: Ib4ece8dd391558fb5fd866b153f30cd2ef59f6b3
* Duplicated package names are skipped.
* A package name can be a simple base name like 'syn',
or with version number like 'syn-1.0.5'.
Test: get_rust_pkg.py -h
Test: get_rust_pkg.py pkg1 pkg2 pkg3
Test: get_rust_pkg.py -o tmp -v pkg1 pkg2 pkg1
Change-Id: I5757f20c9a7cb244dc4b06113e28fcf4585c0703
* crates.io keeps yanked packages with the "yanked" attribute.
For example, log-0.4.9 and log-0.4.10 were yanked so
"get_rust_pkg log" should skip them.
* Compare version numbers before the publish id number.
For example, lazy_static-1.1.1 was published after lazy_static-1.4.0,
but "get_rust_pkg lazy_static" should fetch 1.4.0.
Test: get_rust_pkg.py -v log # get log.0.4.8
Test: get_rust_pkg.py -v log-0.4.10 # get log.0.4.10
Test: get_rust_pkg.py -v lazy_static # get lazy_static-1.4.0
Change-Id: Id005a91b75c0885285a76136bd6de19d0dafa5c1