Skip to content

Commit

Permalink
pw_build: Restore ._build_wheel for Python Pkgs
Browse files Browse the repository at this point in the history
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 <[email protected]>
Commit-Queue: Anthony DiGirolamo <[email protected]>
  • Loading branch information
AnthonyDiGirolamo authored and CQ Bot Account committed May 13, 2022
1 parent e2dcca1 commit 3feef6a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 49 deletions.
100 changes: 53 additions & 47 deletions pw_build/python.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
}
}

Expand Down
10 changes: 8 additions & 2 deletions pw_build/python_action.gni
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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)" ]
}
}
}
}
Expand Down

0 comments on commit 3feef6a

Please sign in to comment.