Skip to content

Commit 645fd0f

Browse files
committed
fix
1 parent 5ed99f1 commit 645fd0f

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

.github/actions/tox/install_packages.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,18 @@ def from_setupcfg(path: str) -> Optional[str]:
117117
:returns: A python package name
118118
"""
119119
setup_cfg = os.path.join(path, "setup.cfg")
120-
if os.path.exists(setup_cfg):
121-
config = ConfigParser()
122-
config.read(setup_cfg)
123-
try:
124-
return config.get("metadata", "name")
125-
except (NoSectionError, NoOptionError):
126-
# Some things have a setup.cfg, but don't keep
127-
# metadata in it; fall back to setup.py below
128-
logger.info("[metadata] name not found in %s, skipping", setup_cfg)
129-
return None
120+
if not os.path.exists(setup_cfg):
121+
logger.info("%s does not exist", setup_cfg)
122+
return None
123+
config = ConfigParser()
124+
config.read(setup_cfg)
125+
try:
126+
return config.get("metadata", "name")
127+
except (NoSectionError, NoOptionError):
128+
# Some things have a setup.cfg, but don't keep
129+
# metadata in it; fall back to setup.py below
130+
logger.info("[metadata] name not found in %s, skipping", setup_cfg)
131+
return None
130132

131133

132134
def from_setuppy(path: str, tox_py: str) -> Optional[str]:
@@ -136,18 +138,21 @@ def from_setuppy(path: str, tox_py: str) -> Optional[str]:
136138
:param tox_py: python executable using to test setup.py
137139
:returns: A python package name
138140
"""
139-
if os.path.exists(os.path.join(path, "setup.py")):
140-
# It's a python package but doesn't use pbr, so we need to run
141-
# python setup.py --name to get setup.py to tell us what the
142-
# package name is.
143-
package_name = subprocess.check_output(
144-
[os.path.abspath(tox_py), "setup.py", "--name"],
145-
cwd=path,
146-
shell=True,
147-
stderr=subprocess.STDOUT,
148-
).decode("utf-8")
149-
if package_name:
150-
return package_name.strip()
141+
setup_py = os.path.join(path, "setup.py")
142+
if not os.path.exists(setup_py):
143+
logger.info("%s does not exist", setup_py)
144+
return None
145+
# It's a python package but doesn't use pbr, so we need to run
146+
# python setup.py --name to get setup.py to tell us what the
147+
# package name is.
148+
package_name = subprocess.check_output(
149+
[os.path.abspath(tox_py), "setup.py", "--name"],
150+
cwd=path,
151+
shell=True,
152+
stderr=subprocess.STDOUT,
153+
).decode("utf-8")
154+
if package_name:
155+
return package_name.strip()
151156
return None
152157

153158

0 commit comments

Comments
 (0)