aboutsummaryrefslogtreecommitdiff
path: root/pw_cli
AgeCommit message (Collapse)Author
2020-11-04pw_env_setup: Use GN to install Python packagesRob Mohr
For now leave the setup.py search in place to make migration easier for downstream projects, but largely turn it off for Pigweed itself. Bug: 287 Change-Id: I79e3a1ba64f98eec2b6617903fad634e8ef0b95a Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23160 Commit-Queue: Rob Mohr <mohrr@google.com> Reviewed-by: Wyatt Hepler <hepler@google.com>
2020-10-30Python: Update mypy and pylint versionsWyatt Hepler
Update mypy and pylint and fix several new warnings. Change-Id: I448eb306a1b7325ab6aae46f02622db781f8b6db Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22880 Commit-Queue: Wyatt Hepler <hepler@google.com> Reviewed-by: Rob Mohr <mohrr@google.com>
2020-10-22Python: Generate BUILD.gn files for Python packagesWyatt Hepler
- Generate BUILD.gn files with pw_python_packages using pw_build.generate_python_package_gn. - Add the new pw_python_package targets to the default build. - Remove the unncecessary "python_packages" group. - Fix some Windows path issues in Python tests. Change-Id: I50c9b1f650652554f0836cbdc1781a00ec7e8e56 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22203 Commit-Queue: Wyatt Hepler <hepler@google.com> Reviewed-by: Rob Mohr <mohrr@google.com>
2020-10-22Python: Add py.typed files per PEP 561Wyatt Hepler
- PEP 561 (https://www.python.org/dev/peps/pep-0561/) specifies that packages that wish to support type checking must provide a py.typed marker file. Add py.typed to all packages. - Add missing __init__.py files to pw_cli and pw_hdlc_lite. Change-Id: I32d652222e9909a5ac4a5612c2dd1683b18b2d36 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22200 Reviewed-by: Alexei Frolov <frolv@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-22pw_build: pw_python_package and mypy fixesWyatt Hepler
- Use the target-relative path for pylint's stamp so it is unique when there are multiple files with the same basename (e.g. __init__.py). - Serialize pip install commands since in-parallel --editable installs do not work correctly. - Run mypy over the entire package directory rather than individual files. - Fix various mypy issues so that mypy passes without --ignore-missing-imports. Change-Id: I8129144d7c963616e5b836dd2f082c41f1dc1416 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/22201 Reviewed-by: Alexei Frolov <frolv@google.com>
2020-10-15BUILD.gn files: Improve import formattingWyatt Hepler
The "# gn-format disable" comments are no longer necessary. Delete these comments and reformat with a Vim macro and gn format. Change-Id: Ia62c40ad73eef91187d0d443d6e3b0fa723e5aa9 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/21380 Reviewed-by: Armando Montanez <amontanez@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-10-15pw_env_setup: Change how files are passed inRob Mohr
Change how files are passed into pw_env_setup. In most cases they're passed in with --use-pigweed-defaults, but downstream projects now have the option to not include Pigweed's defaults. Change-Id: I82383705e156be14276a8498648ca376e3340efb Bug: 274 Requires: pigweed-internal:7120 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19380 Commit-Queue: Rob Mohr <mohrr@google.com> Reviewed-by: Joe Ethier <jethier@google.com> Reviewed-by: Michael Spang <spang@google.com>
2020-10-01docs: Make labels consistent; remove boilerplateWyatt Hepler
- Update labels so they use consistent naming. Instead of the copy-and-pasted `chapter` prefix, name labels with a prefix consistent with what they point to: - "module-" for module - "target-" for targets - "docs-" for general documentation - Remove the unnecessary highlight and default-domain directives. Neither is necessary since the Pigweed docs always specify the language in code snippets and other directives. Change-Id: I55c34e9ec919f6f4670e5d3d008e0edf5fecf05b Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/19328 Commit-Queue: Wyatt Hepler <hepler@google.com> Reviewed-by: Keir Mierle <keir@google.com>
2020-09-25Skip pigweed requirements.txt if overriddenMichael Spang
Pigweed uses exact versions of packages that may conflict with downstream requirements. Skip them by default and add an option PW_VIRTUALENV_REQUIREMENTS_APPEND_DEFAULT to allow re=adding the default requirements.txt. Change-Id: Idf6b6b47ae8a6bdfc5dbf1e948a63d2070d8285a Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/18861 Commit-Queue: Michael Spang <spang@google.com> Reviewed-by: Rob Mohr <mohrr@google.com>
2020-07-21pw_env_setup: make all Python code 3.7-compatibleRob Mohr
Make all Python code compatible with 3.7. Specifically, remove dependency on shlex.join(), a one-line function added in Python 3.8, and typing.Literal. Change-Id: I38f57c9f0ee7b8ef1c3e3d9ead456b2e60a4b42d Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13461 Reviewed-by: Michael Spang <spang@google.com> Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Rob Mohr <mohrr@google.com>
2020-07-16pw_env_setup: allow setting environment directoryRob Mohr
Allow setting of environment installation directory. Everything created from environment setup gets installed into this directory. The first time bootstrap is run after this commit is applied will take longer, and eventually the old paths should be removed from .gitignore (and deleted). Bug: 216 Change-Id: I92ebe8a2414998cb5e4ae9ef3a92d6b50ffa8fab Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13600 Reviewed-by: Keir Mierle <keir@google.com> Commit-Queue: Rob Mohr <mohrr@google.com>
2020-07-13pw_doctor: allow skipping CIPD checksRob Mohr
Change-Id: I22fc7f680238315ada03dadbb0f25c6ff2394efb Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13685 Reviewed-by: Wyatt Hepler <hepler@google.com> Commit-Queue: Rob Mohr <mohrr@google.com>
2020-06-24pw_cli: add allowed suffixes to env parserRob Mohr
Add ability to ignore suffixes in environment variable parser. Add '_CIPD_INSTALL_DIR' to this list. Change-Id: I35c734136591fb932ccb7d99c58ecf3582d4e7f2 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/12842 Reviewed-by: Alexei Frolov <frolv@google.com> Commit-Queue: Rob Mohr <mohrr@google.com>
2020-06-22pw_presubmit: Don't use setup.py testWyatt Hepler
Previously, Python tests were executed using setup.py test. There are a few issues with this. First, with the current setup, tests are executed twice for some reason. Occasionally other odd errors occur. Also, setuptools has deprecated the test command for setup.py and states that it will be removed in a future version. This change discovers tests by finding the package directories of affected files and searching for tests with customizable patterns ('*_test.py' by default). This approach is simpler, faster, and no longer relies on setuptools or unittest. Since setup.py test is no longer used, this change removes test suite discovery from Pigweed's setup.py files. Change-Id: I3de6c5d05ea5e38eea27b0e3aca956fe468035be Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/12662 Reviewed-by: Rob Mohr <mohrr@google.com> Commit-Queue: Wyatt Hepler <hepler@google.com>
2020-06-16Remove legacy_target.gniArmando Montanez
Transition to args is done, so this import is no longer needed. Change-Id: Id42e06ec9fcc16eace2cc7ef51a5dacaf012147a
2020-06-16Don't declare pigweed variables as globalsArmando Montanez
Require targets to explicitly import pigweed variable definitions. This moves out some necessary logic from the BUILDCONFIG.gn file. Change-Id: If9c9fe5a680cc9d897a0e8a55889873be618ed84
2020-06-11pw_cli: Add support for brandingKeir Mierle
This adds the ability to change the banner (including color) that's displayed across the "pw" tooling; such as in "pw watch". Change-Id: I4483e0674020365f5da7974248446e8325ba8389
2020-06-10pw_presubmit: Support multiple repositoriesWyatt Hepler
- Support checking files in multiple repositories. - Support specifying the root path to use, which does not have to be in a Git repo. - Remove the --repository argument, which is redundant with -C and conflicts with having multiple repos. - Update the semantics for specifying pathspecs to work naturally across multiple repositories. - Update the Pigweed presubmit with the new arguments. - Expand docs.rst and docstrings. Change-Id: Ibaa494bdc645af3e8f8cc3b736f89098de0d1634
2020-05-14pw_cli: Use an absolute path for -CWyatt Hepler
The -C/--directory path needs to be resolved before changing the directory with os.chdir, otherwise it may not resolve correctly. Change-Id: If8c26c17957e27dfbc35d9acd5b07d93ed928b36
2020-05-12Use pw_env_setup from GCSRob Mohr
Change-Id: I7325d63e244de7555fabdc66ed3c49ccd54fdc7b Bug: 67
2020-04-29bootstrap.sh: Option for hiding the bannerWyatt Hepler
Do not display the PIGWEED bannner if PW_ENVSETUP_NO_BANNER is set. This allows projects to use their own banner, but keep the rest of the bootstrap messaging. Change-Id: I87c0720fb47faf026a999b04ed8a5e273f95a73b
2020-04-24pw_cli: New pw plugin registration systemWyatt Hepler
- Introduce new system for registering plugins with the pw command. Plugins can be registered for a directory tree by listing them in a PW_PLUGINS file. - Update most existing plugins to be registered as "built-in" plugins in pw_cli. - Register pw_presubmit using a PW_PLUGINS file, since it only applies to the Pigweed repository. - No longer add plugins to the pw argument parser as subparsers. Instead, use argparse to separate the pw arguments from the plugin arguments. - Remove __init__.py files that were only used to trigger plugin registration, since __init__.py is not required in Python 3. Change-Id: I20028f2053476df2afebd36e9299062e7e96727e
2020-04-22pw_cli: Implement pw option to change directoryWyatt Hepler
Implement the -C/--directory option for pw, which changes to the specified directory before doing anything. This is similar to the -C option in Make or Git. Change-Id: I5e66e5bd45bcde207e49bc140579fef272e4a1ed
2020-04-22pw_doctor: Disable presubmit hook warningWyatt Hepler
Disable the presubmit hook warning by default. External projects won't necessarily have setup a presubmit script, and installing the presubmit hook prematurely would interfere with pushing code. Change-Id: I1ce3c80366588542916f812981a631e67aa39725
2020-04-03pw_env_setup: use env vars for bootstrap optsRob Mohr
The following environment variables are now used to pass options into pw_env_setup: * PW_CIPD_PACKAGEFILES * PW_VIRTUALENV_REQUIREMENTS * PW_VIRTUALENV_SETUPPYROOTS * PW_CARGO_PACKAGEFILES Each of these variables can contain multiple entries separated by ':' (or ';' on Windows) like PATH. However, they will also be interpreted as globs, so PW_VIRTUALENV_REQUIREMENTS="/foo/bar/*/requirements.txt" is perfectly valid. They should be full paths. Projects depending on Pigweed should prepend to these variables and then invoke Pigweed's bootstrap.sh (or bootstrap.bat). Users wanting additional setup should set these variables in their shell init files. Change-Id: Ibf0f1d5279028856a590ffc50850df2174c38e28 Bug: 138
2020-03-17Docs: Add missing RST docsArmando Montanez
Adds dcos.rst files for all modules lacking documentation. Change-Id: Ief5594831d31fcb876381a4a3886382fab7d595e
2020-03-13pw_cli: Make process.py fasterWyatt Hepler
- For run_async, replace the silent option with the log_output option. With log_output, lines are read one-by-one and logged. Otherwise, the output is dumped to a temporary file. - For tests, only log the output on failure. This substantially speeds up verbose tests. A pw_kvs test went from 38 s to 1.2 s when passing, or 26 s when failing and printing the output. Change-Id: Iba18c555c07eeaa9eb5ba79bc8d36d3ef2435485
2020-03-13pw_doctor: check for pre-push hookRob Mohr
Fixed: 157 Change-Id: I94cb3295226d97f503ecbcf353f92582ce4b4f64
2020-03-11env_setup: Split activate and bootstrap on WindowsAlexei Frolov
This change creates a top level bootstrap and activate script on Windows to mirror the Linux setup. Change-Id: I6d06ea2112b68deceb0d6d2011c3c80699a7e77f
2020-03-09pw_env_setup: Just use the system PythonAlexei Frolov
MacOS runs into some strange issues when trying to call python3. While the source of these issues has not been found, it was determined that there is no longer any reason to try to prioritize python3 for env setup, as it works with any Python version. The environment variable to force python2 has been replaced with a variable to force a specific version of Python. Fixed: 151 Change-Id: Ief21cb1cf3f5326d2d7036d46c3a9fc0504ba9fa
2020-03-07pw_env_setup: Improve POSIX CLI outputAlexei Frolov
This change updates the output of the bootstrap and env_setup scripts to make it more detailed and prettier. The POSIX-side improvements are handled here; Windows will come in a follow-up change. Example output: WELCOME TO... ▒█████▄ █▓ ▄███▒ ▒█ ▒█ ░▓████▒ ░▓████▒ ▒▓████▄ ▒█░ █░ ░█▒ ██▒ ▀█▒ ▒█░ █ ▒█ ▒█ ▀ ▒█ ▀ ▒█ ▀█▌ ▒█▄▄▄█░ ░█▒ █▓░ ▄▄░ ▒█░ █ ▒█ ▒███ ▒███ ░█ █▌ ▒█▀ ░█░ ▓█ █▓ ░█░ █ ▒█ ▒█ ▄ ▒█ ▄ ░█ ▄█▌ ▒█ ░█░ ░▓███▀ ▒█▓▀▓█░ ░▓████▒ ░▓████▒ ▒▓████▀ BOOTSTRAP! Bootstrap may take a few minutes; please be patient. Downloading and installing packages into local source directory: Setting up CIPD package manager...done Setting up Python environment.....done Setting up Pigweed host tools.....done Setting up Rust's cargo...........done Activating environment (setting environment variables): Setting environment variables for CIPD package manager...done Setting environment variables for Python environment.....done Setting environment variables for Pigweed host tools.....done Setting environment variables for Rust's cargo...........skipped Note: Re-run bootstrap with PW_CARGO_SETUP=1 set in your environment to enable Rust. Sanity checking the environment: 20200306 12:48:12 ℹ️ Pigweed environment passes all checks! Environment looks good; you are ready to go! To activate this environment in the future, run this in your terminal: . pw_env_setup/env_setup.sh Bug: 143 Change-Id: If91457888cecfa117d5b8907c82c396413c640e8
2020-03-06pw_presubmit: Enable mypy and get it passingWyatt Hepler
- Fix several typing issues. - Disable type checking in several places where mypy wasn't working correctly. - Enable mypy. - Execute individual steps in the same order as they are provided with --step. Change-Id: I229cf8ee39a4db5067c1923b4acfc5fcd164f733
2020-03-06pw_cli: Add argument to hide bannerAlexei Frolov
This change adds an argument to the pw command which prevents it from printing the Pigweed banner. This is useful when pw is called from scripts to avoid polluting the output. Bug: 143 Change-Id: I30af43bd7815aa0472a1cb1ac2ca3f5ef49976dc
2020-01-30Disable cargo setup by defaultRob Mohr
Fixes: 109 Change-Id: I6dc2ed9b5ebc87a4a6c313ebae6745ed96040f65
2020-01-28Add output and run doctor in env setupRob Mohr
Echo info about steps in generated env setup script. Also run 'pw doctor' at end of env setup script. Non-warning/error output can be suppressed by setting PW_ENVSETUP_QUIET to '1'. Change-Id: Ief333779dabbdb4613db05726d00f80d3fca325a
2020-01-24env_setup: enable host build in WindowsAlexei Frolov
This change fixes pw_exec to work with Windows GOPATHs and enables ANSI color codes in cmd.exe. This should be the final change required to run host builds within Windows, so it is added back into the env_setup steps. Fixes: 97 Change-Id: I389e9374ec685f2b94de8d7651733207e7b1ecf8
2020-01-17Improve test runner loggingAlexei Frolov
This change switches the test runner from coloredlogs to pw_cli.log with the timestamp removed to improve its output when running from Ninja. Change-Id: Ieb6dd09988309eb3244f13345a73c7b9053a5065
2020-01-14Add new vars to env.pyRob Mohr
Change-Id: Ifc3ebcb67219b228faa69996f79ca1f8cfe75522
2020-01-13envparse: Accept emoji as booleansAlexei Frolov
This change updates the envparse strict_bool type to accept emoji. Change-Id: I585445399367e07cb2e30605f62cf44f882ee2cd
2020-01-13pw_cli: Add emoji for log levelsAlexei Frolov
This change enables emoji in pw_cli logs with PW_EMOJI=1. Bug: 56 Change-Id: Iaafaa2a1dc2c3f3defe613442a32d6a006f4feba
2020-01-10pw_cli: Handle decoding errors for log statementWyatt Hepler
Change-Id: I71c22f624253fc35524ae6500e90ee04e06e89f3
2020-01-10pw_watch: Add emojiAlexei Frolov
This change adds emoji support to the watch command. Change-Id: Ic42569668ed7caec51678cd02a122a89f23b7319
2020-01-07Reduce env_setup output.Rob Mohr
$ source env_setup/bootstrap.sh Setting up cipd...done. Setting up python...done. Setting up host_tools...done. Fixes: 40 Change-Id: I8ed2500d1dd3e17c8f65b5788c2fb3ce42275cdb
2020-01-07Move watch outside of pw_cli.Rob Mohr
Create new module for 'pw watch' command. Change-Id: Id0cb4b8204fe6201935f13ff99101ef554d3c80b
2020-01-03pw_cli: Define Pigweed environment variablesAlexei Frolov
This change adds an environment module to pw_cli which defines all of the environment variables used by Pigweed. A new variable named PW_USE_COLOR added, forcing the use of log colors even if not printing to a TTY. This is set by the watch command for its subprocesses. The check for the PW_SUBPROCESS variable in logging is updated to use the environment module. Change-Id: I84007691f3ae9bb262c6bf6471afa43db831268f
2020-01-03pw_cli: Add envparse moduleAlexei Frolov
This change adds a Python module which implements an environment variable parser that allows defining and typing environment variables for a Python program. Change-Id: Icda61c8dabcf4e4bc6902707f6ebed9c50d31d71
2019-12-31Logging adjustmentsWyatt Hepler
Add function for setting the stderr log level and adjust some log statements. Bug: 41 Change-Id: I3cb44d78c5316949da331ca91fca25592f3f5907
2019-12-27Ignore presubmit directory in pw watchAlexei Frolov
This change extends the watch command to ignore the presubmit directory in addition to its build directories. Change-Id: I7880fcbd4e2887a8af736ee93ffccd404d60256e
2019-12-26pw_watch: Set log level for build result log lineKeir Mierle
Change-Id: I4323441465f19323771e253b5ac3062f9db7d124
2019-12-26pw_test_server -> pw_target_runnerAlexei Frolov
This change renames the pw_test_server module to pw_target_runner and integrates it into the GN build using the new Go templates. The module is updated to match the GOPATH structure under its go/ directory, and its protos are moved into the module protos directory. Additionally, the simple server and client are split into two separate programs instead of combining them into one. Change-Id: I44adeca0989dc7e15cb1a169a6ce183139dde2ce