diff options
author | Anthony DiGirolamo <tonymd@google.com> | 2022-05-11 15:52:29 -0700 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-05-13 22:56:47 +0000 |
commit | 3feef6a3514a2e818c50ebc4d4329622b15b54fb (patch) | |
tree | e4a1dc91f71516c3cd4d44c02bc1b6cdeb4bbcce | |
parent | e2dcca1857dabf5d9ff3e6bb55f5e8e3e06d2924 (diff) | |
download | pigweed-3feef6a3514a2e818c50ebc4d4329622b15b54fb.tar.gz |
pw_build: Restore ._build_wheel for Python Pkgs
The new Python build system flag was inadvertently disabling the
._build_wheel targets for every python package. This was breaking the
pw_python_wheels template.
Also only add install_3p_deps as dep on python actions if the new
Python build system is enabled.
Change-Id: Idca81ccd6efd3323891e2f74c82da5038bd4a0a9
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/94280
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
-rw-r--r-- | pw_build/python.gni | 100 | ||||
-rw-r--r-- | pw_build/python_action.gni | 10 |
2 files changed, 61 insertions, 49 deletions
diff --git a/pw_build/python.gni b/pw_build/python.gni index 0b944638c..184dbb5f8 100644 --- a/pw_build/python.gni +++ b/pw_build/python.gni @@ -490,58 +490,64 @@ template("pw_python_package") { } } - if (_is_package && _pip_install_package) { - # Install this Python package and its dependencies in the current Python - # environment using pip. - pw_python_action("$target_name._run_pip_install") { - module = "pip" - public_deps = [] - if (defined(invoker.public_deps)) { - public_deps += invoker.public_deps - } - - args = [ - "install", + if (_is_package) { + if (_pip_install_package) { + # Install this Python package and its dependencies in the current Python + # environment using pip. + pw_python_action("$target_name._run_pip_install") { + module = "pip" + public_deps = [] + if (defined(invoker.public_deps)) { + public_deps += invoker.public_deps + } - # This speeds up pip installs. At this point in the gn build the - # virtualenv is already activated so build isolation isn't required. - # This requires that pip, setuptools, and wheel packages are - # installed. - "--no-build-isolation", - ] + args = [ + "install", - inputs = pw_build_PIP_CONSTRAINTS - foreach(_constraints_file, pw_build_PIP_CONSTRAINTS) { - args += [ - "--constraint", - rebase_path(_constraints_file, root_build_dir), + # This speeds up pip installs. At this point in the gn build the + # virtualenv is already activated so build isolation isn't required. + # This requires that pip, setuptools, and wheel packages are + # installed. + "--no-build-isolation", ] - } - # For generated packages, reinstall when any files change. For regular - # packages, only reinstall when setup.py changes. - if (_generate_package) { - public_deps += [ ":${invoker.target_name}" ] - } else { - inputs += invoker.setup - - # Install with --editable since the complete package is in source. - args += [ "--editable" ] + inputs = pw_build_PIP_CONSTRAINTS + foreach(_constraints_file, pw_build_PIP_CONSTRAINTS) { + args += [ + "--constraint", + rebase_path(_constraints_file, root_build_dir), + ] + } + + # For generated packages, reinstall when any files change. For regular + # packages, only reinstall when setup.py changes. + if (_generate_package) { + public_deps += [ ":${invoker.target_name}" ] + } else { + inputs += invoker.setup + + # Install with --editable since the complete package is in source. + args += [ "--editable" ] + } + + args += [ rebase_path(_setup_dir, root_build_dir) ] + + stamp = true + + # Parallel pip installations don't work, so serialize pip invocations. + pool = "$dir_pw_build/pool:pip($default_toolchain)" + + foreach(dep, _python_deps) { + # We need to add a suffix to the target name, but the label is + # formatted as "//path/to:target(toolchain)", so we can't just append + # ".subtarget". Instead, we replace the opening parenthesis of the + # toolchain with ".suffix(". + public_deps += [ string_replace(dep, "(", "._run_pip_install(") ] + } } - - args += [ rebase_path(_setup_dir, root_build_dir) ] - - stamp = true - - # Parallel pip installations don't work, so serialize pip invocations. - pool = "$dir_pw_build/pool:pip($default_toolchain)" - - foreach(dep, _python_deps) { - # We need to add a suffix to the target name, but the label is - # formatted as "//path/to:target(toolchain)", so we can't just append - # ".subtarget". Instead, we replace the opening parenthesis of the - # toolchain with ".suffix(". - public_deps += [ string_replace(dep, "(", "._run_pip_install(") ] + } else { + # Stubs for non-package targets. + group("$target_name._run_pip_install") { } } diff --git a/pw_build/python_action.gni b/pw_build/python_action.gni index 4029dafe1..b6d9fab18 100644 --- a/pw_build/python_action.gni +++ b/pw_build/python_action.gni @@ -259,6 +259,9 @@ template("pw_python_action") { _install_venv_3p_deps = false } + # If pw_build_USE_NEW_PYTHON_BUILD is false this variable is not needed. + not_needed([ "_install_venv_3p_deps" ]) + # Check that script or module is a present and not a no-op. _run_script_or_module = false if (defined(invoker.script) || defined(invoker.module)) { @@ -280,8 +283,11 @@ template("pw_python_action") { inputs = _inputs outputs = _outputs deps = _deps - if (_install_venv_3p_deps && _run_script_or_module) { - deps += [ "$dir_pw_env_setup:install_3p_deps($default_toolchain)" ] + + if (pw_build_USE_NEW_PYTHON_BUILD) { + if (_install_venv_3p_deps && _run_script_or_module) { + deps += [ "$dir_pw_env_setup:install_3p_deps($default_toolchain)" ] + } } } } |