Skip to content

Commit 4c2a61a

Browse files
committed
find the file directly
1 parent 913b376 commit 4c2a61a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tools/azure-sdk-tools/ci_tools/build.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,16 @@ def create_package(
193193
# The file normalization changes in setuptools 67.3.0 intends source distribution file names to have the
194194
# formatting a whl distributions. This patch avoids that for now.
195195
normalized_package_name = setup_parsed.name.replace("-", "_")
196-
package_for_adjustments = [f for f in os.listdir(dist) if normalized_package_name in f and f.endswith("tar.gz")]
196+
generated_sdist_name = os.path.join(dist, f"{normalized_package_name}-{setup_parsed.version}.tar.gz")
197197

198-
if package_for_adjustments:
199-
source = os.path.join(dist, package_for_adjustments[0])
198+
if os.path.exists(generated_sdist_name):
199+
source = generated_sdist_name
200200
destination = source.replace(normalized_package_name, setup_parsed.name)
201201

202+
if os.path.exists(destination):
203+
os.remove(destination)
204+
202205
os.rename(source, destination)
203206
else:
204-
logger.log(level=logging.ERROR, msg=f"Unable to find a source distribution for {setup_parsed.name} that could be renamed to un-normalized title.")
207+
logger.log(level=logging.ERROR, msg=f"Unable to find a source distribution for {setup_parsed.name} that could be renamed without normalization.")
205208

0 commit comments

Comments
 (0)