forked from bazelbuild/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(py_wheel): Avoid reliance on bash in
py_wheel
macro. (bazelbuil…
…d#2171) While trying to modernize an older repo I tried building wheels on windows and ran into a failure: ``` Windows Subsystem for Linux has no installed distributions. Use 'wsl.exe --list --online' to list available distributions and 'wsl.exe --install <Distro>' to install. Distributions can also be installed by visiting the Microsoft Store: https://aka.ms/wlstore Errorcode: Bash/Service/CreateInstance/GetDefaultDistro/WSL_E_DEFAULT_DISTRO_NOT_FOUND ``` This appears to be caused by the `py_wheel_dist` rule which gets caught by `//...`. This target should be considered a side-effect/optional target of `py_wheel`. To fix: 1. Mark the target as `manual`, so it's only built when explicitly requested. 2. Implement copying to the directory with a Python program instead of shell, so bash isn't required.
- Loading branch information
1 parent
54c9fab
commit b97a5d6
Showing
4 changed files
with
103 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""A utility for generating the output directory for `py_wheel_dist`.""" | ||
|
||
import argparse | ||
import shutil | ||
from pathlib import Path | ||
|
||
|
||
def parse_args() -> argparse.Namespace: | ||
"""Parse command line arguments.""" | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument( | ||
"--wheel", type=Path, required=True, help="The path to a wheel." | ||
) | ||
parser.add_argument( | ||
"--name_file", | ||
type=Path, | ||
required=True, | ||
help="A file containing the sanitized name of the wheel.", | ||
) | ||
parser.add_argument( | ||
"--output", | ||
type=Path, | ||
required=True, | ||
help="The output location to copy the wheel to.", | ||
) | ||
|
||
return parser.parse_args() | ||
|
||
|
||
def main() -> None: | ||
"""The main entrypoint.""" | ||
args = parse_args() | ||
|
||
wheel_name = args.name_file.read_text(encoding="utf-8").strip() | ||
args.output.mkdir(exist_ok=True, parents=True) | ||
shutil.copyfile(args.wheel, args.output / wheel_name) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |