Commit Graph

7 Commits

Author SHA1 Message Date
Chih-Hung Hsieh
3d24aed831 Add add3prf.py and call it from get_rust_pky.py
* add3prf.py can be called in existing rust package directories
  to normalize METADATA, OWNERS, and other LICENSE* files.
* Add option in get_rust_pkg.py to call add3prt.py and add
  required files for 3rd party reviews.

Bug: 170254513
Test: call add3prf.py in external/rust/crates/*
Test: get_rust_pkg.py --add3prf quote remain paste
Change-Id: I70ed5942847716af2ca740a91e7ecde50543b7a0
2020-10-13 22:29:07 -07:00
Joel Galenson
70da55bef5 Allow passing arguments with -- in addition to -.
This allows the Unix-like command-line argument --show.  We keep the
existing -show.

Test: get_rust_pkg.py -show foo
Test: get_rust_pkg.py --show foo
Change-Id: I5906e0c59ef6f9e4ad33b0a9645a1fc4d9d9e1aa
2020-06-04 08:49:46 -07:00
Chih-Hung Hsieh
2f22d1cb80 Miscellaneous coding style and output improvements
* 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
2020-05-06 18:22:17 -07:00
Chih-Hung Hsieh
783dfd4c64 Show number of dependent packages
* 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
2020-05-05 17:13:34 -07:00
Chih-Hung Hsieh
23a7406de1 Accept and fetch multiple packages
* 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
2020-04-24 13:24:14 -07:00
Chih-Hung Hsieh
7c6362a96b Skip yanked packages and use newest version number.
* 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
2020-04-02 10:23:48 -07:00
Chih-Hung Hsieh
8a3e910fee add get_rust_pkg.py
Test: get_rust_pkg.py syn
Test: get_rust_pkg.py -v -o /tmp bitflags-1.2.0
Change-Id: I540b757a9dab56d4216015513d649b23063fb901
2020-03-27 12:41:29 -07:00