Skip to content

Commit fa2bb49

Browse files
authored
Use platform-specific activation, pin setuptools 69.2.0 (#36454)
* pin setuptools to 69.2.0 * use virtualenv for our virtual environment creation instead of default venv * source the virtual environment just before build steps, versus prepending path which was working unreliably * remove venv use from test phase, as it wasn't actually having the effect we originally expected
1 parent 7c0548f commit fa2bb49

File tree

10 files changed

+52
-50
lines changed

10 files changed

+52
-50
lines changed

.vscode/cspell.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@
198198
"contosodataset",
199199
"centralus",
200200
"centraluseuap",
201-
"corehttp",
202201
"creds",
203202
"ctoring",
204203
"ctxt",

eng/ci_tools.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# requirements leveraged by ci tools
2-
setuptools==70.2.0; python_version >= '3.5'
3-
virtualenv==20.24.3
2+
setuptools==69.2.0; python_version >= '3.5'
3+
virtualenv==20.25.1
44
wheel==0.43.0
55
packaging==23.1
66
tox==4.5.0

eng/conda_test_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trio
88
typing_extensions>=3.7.2
99
cryptography
1010
adal
11-
setuptools==70.2.0; python_version >= '3.5'
11+
setuptools==69.2.0; python_version >= '3.5'
1212
pytest-asyncio==0.12.0
1313
-e sdk/core/azure-core/tests/testserver_tests/coretestserver
1414
azure-mgmt-storage

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,27 @@ steps:
5252
inputs:
5353
versionSpec: $(PythonVersion)
5454

55-
- ${{ if eq(parameters.UseVirtualEnvironment, true) }}:
56-
- template: /eng/pipelines/templates/steps/use-venv.yml
55+
56+
- template: /eng/pipelines/templates/steps/use-venv.yml
57+
parameters:
58+
VirtualEnvironmentName: "venv"
59+
Activate: false
60+
61+
- bash: |
62+
source $(VENV_LOCATION)/bin/activate
63+
which python
64+
python -m pip install --force -r eng/ci_tools.txt
65+
python -m pip freeze --all
66+
displayName: 'Prep Environment Linux/Mac'
67+
condition: and(succeeded(), or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin')))
5768
5869
- pwsh: |
70+
. $(VENV_LOCATION)/Scripts/Activate.ps1
5971
which python
6072
python -m pip install --force -r eng/ci_tools.txt
6173
python -m pip freeze --all
62-
displayName: 'Prep Environment'
74+
displayName: 'Prep Environment Windows'
75+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
6376
6477
- template: set-dev-build.yml@self
6578
parameters:
@@ -84,10 +97,22 @@ steps:
8497
displayName: 'Install QEMU Dependencies'
8598
condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux'))
8699
100+
- bash: |
101+
source $(VENV_LOCATION)/bin/activate
102+
which python
103+
sdk_build -d "$(Build.ArtifactStagingDirectory)" "$(TargetingString)" --service=${{parameters.ServiceDirectory}} --inactive
104+
displayName: 'Generate Packages Linux/Mac'
105+
condition: and(succeeded(), or(eq(variables['Agent.OS'], 'Linux'), eq(variables['Agent.OS'], 'Darwin')))
106+
timeoutInMinutes: 80
107+
env:
108+
CIBW_BUILD_VERBOSITY: 3
109+
87110
- pwsh: |
111+
. $(VENV_LOCATION)/Scripts/Activate.ps1
88112
which python
89113
sdk_build -d "$(Build.ArtifactStagingDirectory)" "$(TargetingString)" --service=${{parameters.ServiceDirectory}} --inactive
90-
displayName: 'Generate Packages'
114+
displayName: 'Generate Packages Windows'
115+
condition: and(succeededOrFailed(), eq(variables['Agent.OS'], 'Windows_NT'))
91116
timeoutInMinutes: 80
92117
env:
93118
CIBW_BUILD_VERBOSITY: 3

eng/pipelines/templates/steps/build-test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ steps:
3333
parameters:
3434
versionSpec: '${{ parameters.PythonVersion }}'
3535

36-
- template: /eng/pipelines/templates/steps/use-venv.yml
37-
3836
- template: set-dev-build.yml
3937
parameters:
4038
ServiceDirectory: ${{ parameters.ServiceDirectory }}
@@ -46,11 +44,11 @@ steps:
4644
python -m pip freeze
4745
python -m pip install pip==23.2.1
4846
python -m pip install wheel==0.43.0 --force-reinstall
49-
python -m pip install setuptools==70.2.0 --force-reinstall
47+
python -m pip install setuptools==69.2.0 --force-reinstall
5048
python -m pip install -r eng/ci_tools.txt
5149
pip --version
5250
pip freeze
53-
displayName: 'Prep Environment'
51+
displayName: 'Prep Environment Linux/Mac'
5452
5553
- ${{if eq(parameters.TestProxy, true) }}:
5654
- template: /eng/common/testproxy/test-proxy-tool.yml

eng/pipelines/templates/steps/use-venv.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ parameters:
22
- name: VirtualEnvironmentName
33
type: string
44
default: "venv"
5+
- name: Activate
6+
type: boolean
7+
default: true
58

69
steps:
710
- pwsh: |
@@ -10,8 +13,9 @@ steps:
1013
-RepoRoot "$(Build.SourcesDirectory)"
1114
displayName: Create virtual environment
1215
13-
- pwsh: |
14-
$(Build.SourcesDirectory)/eng/scripts/activate-venv.ps1 `
15-
-VenvName "${{ parameters.VirtualEnvironmentName }}" `
16-
-RepoRoot "$(Build.SourcesDirectory)"
17-
displayName: Use ${{ parameters.VirtualEnvironmentName }} Virtual Environment
16+
- ${{ if eq(parameters.Activate, true) }}:
17+
- pwsh: |
18+
$(Build.SourcesDirectory)/eng/scripts/activate-venv.ps1 `
19+
-VenvName "${{ parameters.VirtualEnvironmentName }}" `
20+
-RepoRoot "$(Build.SourcesDirectory)"
21+
displayName: Use ${{ parameters.VirtualEnvironmentName }} Virtual Environment

eng/regression_tools.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# requirements leveraged by ci tools
2-
setuptools==70.2.0; python_version >= '3.5'
2+
setuptools==69.2.0; python_version >= '3.5'
33
virtualenv==20.23.0
44
wheel==0.43.0
55
Jinja2==3.1.2

eng/scripts/create-venv.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ param(
2323
$venvPath = Join-Path $RepoRoot $VenvName
2424
if (!(Test-Path $venvPath)) {
2525
Write-Host "Creating virtual environment '$VenvName'."
26-
python -m venv "$venvPath"
26+
python -m pip install virtualenv==20.25.1
27+
python -m virtualenv "$venvPath"
2728
Write-Host "Virtual environment '$VenvName' created."
2829
Write-Host "##vso[task.setvariable variable=$($VenvName)_LOCATION]$venvPath"
2930
}

eng/tox/tox_helper_tasks.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,19 @@ def unzip_sdist_to_directory(containing_folder: str) -> str:
2828
tars = glob.glob(os.path.join(containing_folder, "*.tar.gz"))
2929
return unzip_file_to_directory(tars[0], containing_folder)
3030

31+
3132
def unzip_file_to_directory(path_to_zip_file: str, extract_location: str) -> str:
3233
if path_to_zip_file.endswith(".zip"):
3334
with zipfile.ZipFile(path_to_zip_file, "r") as zip_ref:
3435
zip_ref.extractall(extract_location)
3536
extracted_dir = os.path.basename(os.path.splitext(path_to_zip_file)[0])
3637
return os.path.join(extract_location, extracted_dir)
37-
elif path_to_zip_file.endswith(".tar.gz") or path_to_zip_file.endswith(".tgz"):
38-
with tarfile.open(path_to_zip_file, "r:gz") as tar_ref:
39-
tar_ref.extractall(extract_location)
40-
top_level_dir = None
41-
for member in tar_ref.getmembers():
42-
if member.isdir():
43-
top_level_dir = member.name.split('/')[0]
44-
break
45-
if top_level_dir:
46-
return os.path.join(extract_location, top_level_dir)
47-
else:
48-
raise ValueError("Failed to determine the top-level directory in the tar.gz archive")
4938
else:
50-
raise ValueError("Unsupported file format")
39+
with tarfile.open(path_to_zip_file) as tar_ref:
40+
tar_ref.extractall(extract_location)
41+
extracted_dir = os.path.basename(path_to_zip_file).replace(".tar.gz", "")
42+
return os.path.join(extract_location, extracted_dir)
43+
5144

5245
def move_and_rename(source_location):
5346
new_location = os.path.join(os.path.dirname(source_location), "unzipped")

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -189,21 +189,3 @@ def create_package(
189189

190190
if enable_sdist:
191191
run([sys.executable, "setup.py", "sdist", "-d", dist], cwd=setup_parsed.folder, check=True)
192-
193-
# The file normalization changes in setuptools 67.3.0 intends source distribution file names to have the
194-
# formatting a whl distributions. This patch avoids that for now.
195-
normalized_package_name = setup_parsed.name.replace("-", "_")
196-
generated_sdist_name = os.path.join(dist, f"{normalized_package_name}-{setup_parsed.version}.tar.gz")
197-
destination = generated_sdist_name.replace(normalized_package_name, setup_parsed.name)
198-
199-
# in cases where there is no reformatting necessary (sdk/core/corehttp 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.")
209-

0 commit comments

Comments
 (0)