Skip to content

Commit bda6d1f

Browse files
authored
fix path to whl for APIView (Azure#40095)
* fix path to whl for APIView * remove verbose logging * temp sr change for testing * temp- for testing * remove testing packages * scotts comments
1 parent f9a3b80 commit bda6d1f

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

eng/tox/run_apistubgen.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,29 @@
1616

1717
root_dir = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", ".."))
1818

19-
def get_package_wheel_path(pkg_root):
19+
def get_package_wheel_path(pkg_root, out_path):
2020
# parse setup.py to get package name and version
2121
pkg_details = ParsedSetup.from_path(pkg_root)
2222

2323
# Check if wheel is already built and available for current package
2424
prebuilt_dir = os.getenv("PREBUILT_WHEEL_DIR")
25+
out_token_path = None
2526
if prebuilt_dir:
26-
prebuilt_package_path = find_whl(prebuilt_dir, pkg_details.name, pkg_details.version)
27-
else:
28-
return None
29-
27+
pkg_path = os.path.join(prebuilt_dir, find_whl(prebuilt_dir, pkg_details.name, pkg_details.version))
28+
if not pkg_path:
29+
raise FileNotFoundError(
30+
"No prebuilt wheel found for package {} version {} in directory {}".format(
31+
pkg_details.name, pkg_details.version, prebuilt_dir)
32+
)
33+
# If the package is a wheel and out_path is given, the token file output path should be the parent directory of the wheel
34+
if out_path:
35+
out_token_path = os.path.join(out_path, os.path.basename(os.path.dirname(pkg_path)))
36+
return pkg_path, out_token_path
37+
pkg_path = pkg_root
38+
# If the package is not a wheel and out_path is given, the token file output path should be the same as the target package path
39+
if out_path:
40+
out_token_path = os.path.join(out_path, os.path.basename(pkg_path))
41+
return pkg_path, out_token_path
3042

3143
if __name__ == "__main__":
3244
parser = argparse.ArgumentParser(
@@ -55,18 +67,16 @@ def get_package_wheel_path(pkg_root):
5567
dest="out_path",
5668
help="Output directory to generate json token file"
5769
)
58-
70+
5971
args = parser.parse_args()
6072

6173
# Check if a wheel is already built for current package and install from wheel when available
6274
# If wheel is not available then install package from source
63-
pkg_path = get_package_wheel_path(args.target_package)
64-
if not pkg_path:
65-
pkg_path = args.target_package
75+
pkg_path, out_token_path = get_package_wheel_path(args.target_package, args.out_path)
6676

6777
cmds = ["apistubgen", "--pkg-path", pkg_path]
68-
if args.out_path:
69-
cmds.extend(["--out-path", os.path.join(args.out_path, os.path.basename(pkg_path))])
78+
if out_token_path:
79+
cmds.extend(["--out-path", out_token_path])
7080

7181
logging.info("Running apistubgen {}.".format(cmds))
7282
check_call(cmds, cwd=args.work_dir)

0 commit comments

Comments
 (0)