@@ -117,16 +117,18 @@ def from_setupcfg(path: str) -> Optional[str]:
117
117
:returns: A python package name
118
118
"""
119
119
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
130
132
131
133
132
134
def from_setuppy (path : str , tox_py : str ) -> Optional [str ]:
@@ -136,18 +138,21 @@ def from_setuppy(path: str, tox_py: str) -> Optional[str]:
136
138
:param tox_py: python executable using to test setup.py
137
139
:returns: A python package name
138
140
"""
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 ()
151
156
return None
152
157
153
158
0 commit comments