Skip to content

Commit 252107b

Browse files
authored
fix: CI broken by removal of py.path (#1194)
* fix: CI broken by removal of py.path Use Python standard lib instead.
1 parent 61d5f7a commit 252107b

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

packages/google-auth/system_tests/noxfile.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
"""
2424

2525
import os
26+
import pathlib
2627
import subprocess
28+
import shutil
29+
import tempfile
2730

2831
from nox.command import which
2932
import nox
30-
import py.path
3133

3234
HERE = os.path.abspath(os.path.dirname(__file__))
3335
LIBRARY_DIR = os.path.abspath(os.path.dirname(HERE))
@@ -59,16 +61,18 @@
5961
CLOUD_SDK_ROOT = os.environ.get("CLOUD_SDK_ROOT")
6062

6163
if CLOUD_SDK_ROOT is not None:
62-
CLOUD_SDK_ROOT = py.path.local(CLOUD_SDK_ROOT)
63-
CLOUD_SDK_ROOT.ensure(dir=True) # Makes sure the directory exists.
64+
CLOUD_SDK_ROOT = pathlib.Path(CLOUD_SDK_ROOT)
65+
if not CLOUD_SDK_ROOT.exists() or not CLOUD_SDK_ROOT.is_dir():
66+
print("{} did not exist! Please set the CLOUD_SDK_ROOT environment variable to a directory that exists".format(CLOUD_SDK_ROOT))
67+
exit(1)
6468
else:
65-
CLOUD_SDK_ROOT = py.path.local.mkdtemp()
69+
CLOUD_SDK_ROOT = pathlib.Path(tempfile.mkdtemp())
6670

6771
# The full path the cloud sdk install directory
68-
CLOUD_SDK_INSTALL_DIR = CLOUD_SDK_ROOT.join("google-cloud-sdk")
72+
CLOUD_SDK_INSTALL_DIR = CLOUD_SDK_ROOT.joinpath("google-cloud-sdk")
6973

7074
# The full path to the gcloud cli executable.
71-
GCLOUD = str(CLOUD_SDK_INSTALL_DIR.join("bin", "gcloud"))
75+
GCLOUD = str(CLOUD_SDK_INSTALL_DIR.joinpath("bin", "gcloud"))
7276

7377
# gcloud requires Python 2 and doesn't work on 3, so we need to tell it
7478
# where to find 2 when we're running in a 3 environment.
@@ -90,26 +94,26 @@ def install_cloud_sdk(session):
9094
# This set the $PATH for the subprocesses so they can find the gcloud
9195
# executable.
9296
session.env["PATH"] = (
93-
str(CLOUD_SDK_INSTALL_DIR.join("bin")) + os.pathsep + os.environ["PATH"]
97+
str(CLOUD_SDK_INSTALL_DIR.joinpath("bin")) + os.pathsep + os.environ["PATH"]
9498
)
9599

96100
# If gcloud cli executable already exists, just update it.
97-
if py.path.local(GCLOUD).exists():
101+
if pathlib.Path(GCLOUD).exists():
98102
session.run(GCLOUD, "components", "update", "-q")
99103
return
100104

101-
tar_path = CLOUD_SDK_ROOT.join(CLOUD_SDK_DIST_FILENAME)
105+
tar_path = CLOUD_SDK_ROOT.joinpath(CLOUD_SDK_DIST_FILENAME)
102106

103107
# Download the release.
104108
session.run("wget", CLOUD_SDK_DOWNLOAD_URL, "-O", str(tar_path), silent=True)
105109

106110
# Extract the release.
107111
session.run("tar", "xzf", str(tar_path), "-C", str(CLOUD_SDK_ROOT))
108-
session.run(tar_path.remove)
112+
tar_path.unlink()
109113

110114
# Run the install script.
111115
session.run(
112-
str(CLOUD_SDK_INSTALL_DIR.join("install.sh")),
116+
str(CLOUD_SDK_INSTALL_DIR.joinpath("install.sh")),
113117
"--usage-reporting",
114118
"false",
115119
"--path-update",
@@ -123,10 +127,10 @@ def install_cloud_sdk(session):
123127
def copy_credentials(credentials_path):
124128
"""Copies credentials into the SDK root as the application default
125129
credentials."""
126-
dest = CLOUD_SDK_ROOT.join("application_default_credentials.json")
130+
dest = CLOUD_SDK_ROOT.joinpath("application_default_credentials.json")
127131
if dest.exists():
128-
dest.remove()
129-
py.path.local(credentials_path).copy(dest)
132+
dest.unlink()
133+
shutil.copyfile(pathlib.Path(credentials_path), dest)
130134

131135

132136
def configure_cloud_sdk(session, application_default_credentials, project=False):
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)