Skip to content

Commit 6faa888

Browse files
scbeddmccoyp
andauthored
Produce Source Distribution and Documentation as tar.gz (Azure#31419)
* remove all references to *.zip files throughout CI * source distribution and documentation artifact are now all tar.gz files * update all references to artifact .zip -> .tar.gz Co-authored-by: McCoy Patiño <39780829+mccoyp@users.noreply.github.com>
1 parent f70ea33 commit 6faa888

File tree

13 files changed

+55
-45
lines changed

13 files changed

+55
-45
lines changed

eng/pipelines/templates/jobs/smoke.tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ jobs:
159159
timeoutInMinutes: 5
160160

161161
- pwsh: |
162-
$packages = Get-ChildItem "$(Pipeline.Workspace)/${{ parameters.ArtifactName }}/${{ parameters.Artifact.name }}/*.zip"
162+
$packages = Get-ChildItem "$(Pipeline.Workspace)/${{ parameters.ArtifactName }}/${{ parameters.Artifact.name }}/*.tar.gz"
163163
Write-Host "Artifacts found:"
164164
$artifacts = $packages | ForEach-Object {
165-
if ($_.Name -match "([a-zA-Z\-]+)\-(.*).zip") {
165+
if ($_.Name -match "([a-zA-Z\-]+)\-(.*).tar.gz") {
166166
Write-Host "$($matches[1]): $($matches[2])"
167167
return @{ "name" = $matches[1]; "version" = $matches[2] }
168168
}

eng/pipelines/templates/stages/archetype-python-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ stages:
106106
New-Item -ItemType Directory -Force -Path $esrpDirectory
107107
108108
Get-ChildItem -Path "$(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}" `
109-
| Where-Object { ($_.Name -like "*.zip" -or $_.Name -like "*.whl") } `
109+
| Where-Object { ($_.Name -like "*.tar.gz" -or $_.Name -like "*.whl") } `
110110
| Copy-Item -Destination $esrpDirectory
111111
112112
Get-ChildItem $esrpDirectory
@@ -129,7 +129,7 @@ stages:
129129
set -e
130130
twine upload --repository ${{parameters.DevFeedName}} --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*.whl
131131
echo "Uploaded whl to devops feed"
132-
twine upload --repository ${{parameters.DevFeedName}} --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*.zip
132+
twine upload --repository ${{parameters.DevFeedName}} --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*.tar.gz
133133
echo "Uploaded sdist to devops feed"
134134
displayName: 'Publish package to feed: ${{parameters.DevFeedName}}'
135135
@@ -275,7 +275,7 @@ stages:
275275
276276
twine upload --repository $(DevFeedName) --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*-*a*.whl
277277
echo "Uploaded whl to devops feed $(DevFeedName)"
278-
twine upload --repository $(DevFeedName) --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*-*a*.zip
278+
twine upload --repository $(DevFeedName) --config-file $(PYPIRC_PATH) $(Pipeline.Workspace)/${{parameters.ArtifactName}}/${{artifact.name}}/*-*a*.tar.gz
279279
echo "Uploaded sdist to devops feed $(DevFeedName)"
280280
displayName: 'Publish ${{artifact.name}} alpha package'
281281

eng/pipelines/templates/steps/build-package-artifacts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ steps:
6767
6868
- script: |
6969
twine check $(Build.ArtifactStagingDirectory)/**/*.whl
70-
twine check $(Build.ArtifactStagingDirectory)/**/*.zip
70+
twine check $(Build.ArtifactStagingDirectory)/**/*.tar.gz
7171
displayName: 'Verify Readme'
7272
7373
- ${{if eq(variables['System.TeamProject'], 'internal') }}:

eng/scripts/Language-Settings.ps1

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$Language = "python"
22
$LanguageDisplayName = "Python"
33
$PackageRepository = "PyPI"
4-
$packagePattern = "*.zip"
4+
$packagePattern = "*.tar.gz"
55
$MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/main/_data/releases/latest/python-packages.csv"
66
$BlobStorageUrl = "https://azuresdkdocs.blob.core.windows.net/%24web?restype=container&comp=list&prefix=python%2F&delimiter=%2F"
77
$GithubUri = "https://github.com/Azure/azure-sdk-for-python"
@@ -86,7 +86,7 @@ function IsPythonPackageVersionPublished($pkgId, $pkgVersion)
8686
}
8787
}
8888

89-
# Parse out package publishing information given a python sdist of ZIP format.
89+
# Parse out package publishing information given a python sdist of tar.gz format.
9090
function Get-python-PackageInfoFromPackageFile ($pkg, $workingDirectory)
9191
{
9292
$pkg.Basename -match $SDIST_PACKAGE_REGEX | Out-Null
@@ -101,7 +101,8 @@ function Get-python-PackageInfoFromPackageFile ($pkg, $workingDirectory)
101101
$readmeContent = ""
102102

103103
New-Item -ItemType Directory -Force -Path $workFolder
104-
Expand-Archive -Path $pkg -DestinationPath $workFolder
104+
Write-Host "tar -zxvf $pkg -C $workFolder"
105+
tar -zxvf $pkg -C $workFolder
105106

106107
$changeLogLoc = @(Get-ChildItem -Path $workFolder -Recurse -Include "CHANGELOG.md")[0]
107108
if ($changeLogLoc) {
@@ -130,16 +131,26 @@ function Get-python-PackageInfoFromPackageFile ($pkg, $workingDirectory)
130131
# Stage and Upload Docs to blob Storage
131132
function Publish-python-GithubIODocs ($DocLocation, $PublicArtifactLocation)
132133
{
133-
$PublishedDocs = Get-ChildItem "$DocLocation" | Where-Object -FilterScript {$_.Name.EndsWith(".zip")}
134+
$PublishedDocs = Get-ChildItem "$DocLocation" | Where-Object -FilterScript {$_.Name.EndsWith(".tar.gz")}
134135

135136
foreach ($Item in $PublishedDocs)
136137
{
137-
$PkgName = $Item.BaseName
138+
$PkgName = $Item.BaseName.Replace(".tar", "")
138139
$ZippedDocumentationPath = Join-Path -Path $DocLocation -ChildPath $Item.Name
139140
$UnzippedDocumentationPath = Join-Path -Path $DocLocation -ChildPath $PkgName
140141
$VersionFileLocation = Join-Path -Path $UnzippedDocumentationPath -ChildPath "version.txt"
141142

142-
Expand-Archive -Force -Path $ZippedDocumentationPath -DestinationPath $UnzippedDocumentationPath
143+
if (!(Test-Path $UnzippedDocumentationPath)) {
144+
New-Item -Path $UnzippedDocumentationPath -ItemType Directory
145+
}
146+
147+
Write-Host "tar -zxvf $ZippedDocumentationPath -C $UnzippedDocumentationPath"
148+
tar -zxvf $ZippedDocumentationPath -C $UnzippedDocumentationPath
149+
150+
if ($LASTEXITCODE -ne 0) {
151+
Write-Error "tar failed with exit code $LASTEXITCODE."
152+
exit $LASTEXITCODE
153+
}
143154

144155
$Version = $(Get-Content $VersionFileLocation).Trim()
145156

eng/tox/create_package_and_install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def build_and_discover_package(setuppy_path, dist_dir, target_setup, package_typ
7676
create_package(setuppy_path, dist_dir, enable_wheel=False)
7777

7878
prebuilt_packages = [
79-
f for f in os.listdir(args.distribution_directory) if f.endswith(".whl" if package_type == "wheel" else ".zip")
79+
f for f in os.listdir(args.distribution_directory) if f.endswith(".whl" if package_type == "wheel" else ".tar.gz")
8080
]
8181

8282
if not in_ci():

eng/tox/run_sphinx_build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
def in_ci():
3333
return os.getenv('TF_BUILD', False)
3434

35-
def move_output_and_zip(target_dir, package_dir, package_name):
35+
def move_output_and_compress(target_dir, package_dir, package_name):
3636
if not os.path.exists(ci_doc_dir):
3737
os.mkdir(ci_doc_dir)
3838

3939
individual_zip_location = os.path.join(ci_doc_dir, package_name, package_name)
40-
shutil.make_archive(individual_zip_location, 'zip', target_dir)
40+
shutil.make_archive(individual_zip_location, 'gztar', target_dir)
4141

4242
def sphinx_build(target_dir, output_dir):
4343
command_array = [
@@ -114,6 +114,6 @@ def sphinx_build(target_dir, output_dir):
114114
sphinx_build(target_dir, output_dir)
115115

116116
if in_ci() or args.in_ci:
117-
move_output_and_zip(output_dir, package_dir, pkg_details.name)
117+
move_output_and_compress(output_dir, package_dir, pkg_details.name)
118118
else:
119119
logging.info("Skipping sphinx build for {}".format(pkg_details.name))

eng/tox/tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ deps =
379379
{[packaging]pkgs}
380380
commands =
381381
python -m pip install {repository_root}/tools/azure-sdk-tools --no-deps
382-
python {tox_root}/setup.py --q sdist --format zip -d {envtmpdir}
382+
python {tox_root}/setup.py --q sdist -d {envtmpdir}
383383
python {repository_root}/eng/tox/verify_sdist.py -d {envtmpdir} -t {tox_root}
384384

385385

eng/tox/tox_helper_tasks.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,13 @@
1010
import shutil
1111
import sys
1212
import logging
13-
import ast
1413
import os
15-
import textwrap
16-
import io
1714
import glob
1815
import zipfile
19-
import fnmatch
16+
import tarfile
2017
import subprocess
2118
import re
2219

23-
from packaging.specifiers import SpecifierSet
24-
from pkg_resources import Requirement, parse_version
25-
2620
logging.getLogger().setLevel(logging.INFO)
2721

2822

@@ -50,19 +44,27 @@ def get_pip_list_output():
5044
return collected_output
5145

5246

53-
def unzip_sdist_to_directory(containing_folder):
54-
# grab the first one
55-
path_to_zip_file = glob.glob(os.path.join(containing_folder, "*.zip"))[0]
56-
return unzip_file_to_directory(path_to_zip_file, containing_folder)
47+
def unzip_sdist_to_directory(containing_folder: str) -> str:
48+
zips = glob.glob(os.path.join(containing_folder, "*.zip"))
49+
50+
if zips:
51+
return unzip_file_to_directory(zips[0], containing_folder)
52+
else:
53+
tars = glob.glob(os.path.join(containing_folder, "*.tar.gz"))
54+
return unzip_file_to_directory(tars[0], containing_folder)
5755

5856

59-
def unzip_file_to_directory(path_to_zip_file, extract_location):
60-
# unzip file in given path
61-
# dump into given path
62-
with zipfile.ZipFile(path_to_zip_file, "r") as zip_ref:
63-
zip_ref.extractall(extract_location)
64-
extracted_dir = os.path.basename(os.path.splitext(path_to_zip_file)[0])
65-
return os.path.join(extract_location, extracted_dir)
57+
def unzip_file_to_directory(path_to_zip_file: str, extract_location: str) -> str:
58+
if path_to_zip_file.endswith(".zip"):
59+
with zipfile.ZipFile(path_to_zip_file, "r") as zip_ref:
60+
zip_ref.extractall(extract_location)
61+
extracted_dir = os.path.basename(os.path.splitext(path_to_zip_file)[0])
62+
return os.path.join(extract_location, extracted_dir)
63+
else:
64+
with tarfile.open(path_to_zip_file) as tar_ref:
65+
tar_ref.extractall(extract_location)
66+
extracted_dir = os.path.basename(path_to_zip_file).replace(".tar.gz", "")
67+
return os.path.join(extract_location, extracted_dir)
6668

6769

6870
def move_and_rename(source_location):

eng/tox/verify_sdist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_root_directories_in_sdist(dist_dir: str, version: str) -> List[str]:
4242
"""
4343
# find sdist zip file
4444
# extract sdist and find list of directories in sdist
45-
path_to_zip = glob.glob(os.path.join(dist_dir, "*{}*.zip".format(version)))[0]
45+
path_to_zip = glob.glob(os.path.join(dist_dir, "*{}*.tar.gz".format(version)))[0]
4646
extract_location = os.path.join(dist_dir, "unzipped")
4747
# Cleanup any files in unzipped
4848
cleanup(extract_location)

eng/tox/verify_whl.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
import glob
1313
import shutil
1414
from tox_helper_tasks import (
15-
unzip_sdist_to_directory,
16-
move_and_rename,
1715
unzip_file_to_directory,
1816
)
1917

@@ -35,8 +33,8 @@ def extract_whl(dist_dir, version):
3533
# Find whl for the package
3634
path_to_whl = glob.glob(os.path.join(dist_dir, "*{}*.whl".format(version)))[0]
3735

38-
# Cleanup any existing stale files if any and rename whl file to tar.gz
39-
zip_file = path_to_whl.replace(".whl", ".tar.gz")
36+
# Cleanup any existing stale files if any and rename whl file to zip for extraction later
37+
zip_file = path_to_whl.replace(".whl", ".zip")
4038
cleanup(zip_file)
4139
os.rename(path_to_whl, zip_file)
4240

@@ -48,7 +46,7 @@ def extract_whl(dist_dir, version):
4846

4947

5048
def verify_whl_root_directory(dist_dir, expected_top_level_module, version):
51-
# This method ensures root directory in whl is the directoy indicated by our top level namespace
49+
# This method ensures root directory in whl is the directory indicated by our top level namespace
5250
extract_location = extract_whl(dist_dir, version)
5351
root_folders = os.listdir(extract_location)
5452

0 commit comments

Comments
 (0)