Skip to content

Commit d8af90e

Browse files
committed
in places where no rename is necessary, avoid the work
1 parent 4c2a61a commit d8af90e

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,16 @@ def create_package(
194194
# formatting a whl distributions. This patch avoids that for now.
195195
normalized_package_name = setup_parsed.name.replace("-", "_")
196196
generated_sdist_name = os.path.join(dist, f"{normalized_package_name}-{setup_parsed.version}.tar.gz")
197-
198-
if os.path.exists(generated_sdist_name):
199-
source = generated_sdist_name
200-
destination = source.replace(normalized_package_name, setup_parsed.name)
201-
202-
if os.path.exists(destination):
203-
os.remove(destination)
204-
205-
os.rename(source, destination)
206-
else:
207-
logger.log(level=logging.ERROR, msg=f"Unable to find a source distribution for {setup_parsed.name} that could be renamed without normalization.")
197+
destination = generated_sdist_name.replace(normalized_package_name, setup_parsed.name)
198+
199+
# in cases where there is no reformatting necessary (sdk/core/corehttpp is a good example)
200+
# skip this effort
201+
if generated_sdist_name != destination:
202+
if os.path.exists(generated_sdist_name):
203+
if os.path.exists(destination):
204+
os.remove(destination)
205+
206+
os.rename(generated_sdist_name, destination)
207+
else:
208+
logger.log(level=logging.ERROR, msg=f"Unable to find a source distribution for {setup_parsed.name} that could be renamed without normalization.")
208209

0 commit comments

Comments
 (0)