Skip to content

Commit a164a09

Browse files
authored
Add python 3.8 nuget generation (#587)
* Upgrade Flake8 3.7.9 and fix new rules linting * Update grpcio tools to 1.26.0 for py38 package generation * Separate V2 host and V3 host package generation
1 parent bf728b1 commit a164a09

16 files changed

+132
-58
lines changed

.flake8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ exclude =
44
.git, __pycache__, build, dist, .eggs, .github, .local, docs/,
55
Samples, azure_functions_worker/protos/,
66
azure_functions_worker/typing_inspect.py,
7-
tests/unittests/test_typing_inspect.py
7+
tests/unittests/test_typing_inspect.py,
8+
.venv*, .env*, .vscode

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ celerybeat-schedule
7979
# SageMath parsed files
8080
*.sage.py
8181

82-
# dotenv
83-
.env
82+
# dotenv (.env/.env36/.env37/.env38)
83+
.env*
8484

85-
# virtualenv
86-
.venv
85+
# virtualenv (.venv/.venv36/.venv37/.venv38)
86+
.venv*
8787
venv/
8888
ENV/
8989

azure-pipelines.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: 1.0.$(Date:yyyyMMdd)$(Rev:r)
1+
name: 1.x.$(Date:yyyyMMdd)$(Rev:r)
22

33
trigger:
44
- dev
@@ -17,6 +17,8 @@ jobs:
1717
pythonVersion: '3.6'
1818
Python37:
1919
pythonVersion: '3.7'
20+
Python38:
21+
pythonVersion: '3.8'
2022
maxParallel: 1
2123
steps:
2224
- task: UsePythonVersion@0
@@ -54,14 +56,16 @@ jobs:
5456
5557
- job: Build_WINDOWS_X64
5658
dependsOn: 'Tests'
57-
pool:
59+
pool:
5860
vmImage: 'vs2017-win2016'
5961
strategy:
6062
matrix:
6163
Python36:
6264
pythonVersion: '3.6'
6365
Python37:
6466
pythonVersion: '3.7'
67+
Python38:
68+
pythonVersion: '3.8'
6569
steps:
6670
- template: pack/templates/win_env_gen.yml
6771
parameters:
@@ -70,12 +74,14 @@ jobs:
7074
artifactName: '$(pythonVersion)_WINDOWS_X64'
7175
- job: Build_WINDOWS_X86
7276
dependsOn: 'Tests'
73-
pool:
77+
pool:
7478
vmImage: 'vs2017-win2016'
7579
strategy:
7680
matrix:
7781
Python37:
7882
pythonVersion: '3.7'
83+
Python38:
84+
pythonVersion: '3.8'
7985
steps:
8086
- template: pack/templates/win_env_gen.yml
8187
parameters:
@@ -84,29 +90,33 @@ jobs:
8490
artifactName: '$(pythonVersion)_WINDOWS_x86'
8591
- job: Build_LINUX_X64
8692
dependsOn: 'Tests'
87-
pool:
93+
pool:
8894
vmImage: 'ubuntu-16.04'
8995
strategy:
9096
matrix:
9197
Python36:
9298
pythonVersion: '3.6'
9399
Python37:
94100
pythonVersion: '3.7'
101+
Python38:
102+
pythonVersion: '3.8'
95103
steps:
96104
- template: pack/templates/nix_env_gen.yml
97105
parameters:
98106
pythonVersion: '$(pythonVersion)'
99107
artifactName: '$(pythonVersion)_LINUX_X64'
100108
- job: Build_OSX_X64
101109
dependsOn: 'Tests'
102-
pool:
110+
pool:
103111
vmImage: 'macOS-10.13'
104112
strategy:
105113
matrix:
106114
Python36:
107115
pythonVersion: '3.6'
108116
Python37:
109117
pythonVersion: '3.7'
118+
Python38:
119+
pythonVersion: '3.8'
110120
steps:
111121
- template: pack/templates/nix_env_gen.yml
112122
parameters:
@@ -121,7 +131,22 @@ jobs:
121131
]
122132
pool:
123133
vmImage: 'vs2017-win2016'
134+
strategy:
135+
matrix:
136+
V2PythonWorker:
137+
minorVersion: '0'
138+
nuspecPath: 'pack\Microsoft.Azure.Functions.V2.PythonWorker.nuspec'
139+
V3PythonWorker:
140+
minorVersion: '1'
141+
nuspecPath: 'pack\Microsoft.Azure.Functions.V3.PythonWorker.nuspec'
124142
steps:
143+
- bash: |
144+
MAJOR=$(echo $BUILD_BUILDNUMBER | cut -d '.' -f1)
145+
MINOR=$(minorVersion)
146+
PATCH=$(echo $BUILD_BUILDNUMBER | cut -d '.' -f3)
147+
echo "##vso[task.setvariable variable=worker_version]$MAJOR.$MINOR.$PATCH"
148+
echo "Packaging Python Worker Version $MAJOR.$MINOR.$PATCH"
149+
displayName: "Generate Worker Version"
125150
- task: DownloadBuildArtifacts@0
126151
inputs:
127152
buildType: 'current'
@@ -130,11 +155,10 @@ jobs:
130155
- task: NuGetCommand@2
131156
inputs:
132157
command: pack
133-
packagesToPack: 'pack\Microsoft.Azure.Functions.PythonWorker.nuspec'
158+
packagesToPack: '$(nuspecPath)'
134159
versioningScheme: 'byEnvVar'
135-
versionEnvVar: BUILD_BUILDNUMBER # Replaces version in nuspec
160+
versionEnvVar: WORKER_VERSION # Replaces version in nuspec
136161
- task: PublishBuildArtifacts@1
137162
inputs:
138163
pathtoPublish: '$(Build.ArtifactStagingDirectory)'
139164
artifactName: 'PythonWorker'
140-

azure_functions_worker/functions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ def add_function(self, function_id: str,
151151
# typing_inspect.get_args() returns a flat list,
152152
# so if the annotation was func.Out[typing.List[foo]],
153153
# we need to reconstruct it.
154-
if (isinstance(param_py_type, tuple) and
155-
typing_inspect.is_generic_type(param_py_type[0])):
154+
if (isinstance(param_py_type, tuple)
155+
and typing_inspect.is_generic_type(param_py_type[0])):
156156

157157
param_py_type = operator.getitem(
158158
param_py_type[0], *param_py_type[1:])
159159
else:
160160
param_py_type = param_anno
161161

162-
if (param_has_anno and not isinstance(param_py_type, type) and
163-
not typing_inspect.is_generic_type(param_py_type)):
162+
if (param_has_anno and not isinstance(param_py_type, type)
163+
and not typing_inspect.is_generic_type(param_py_type)):
164164
raise FunctionLoadError(
165165
func_name,
166166
f'binding {param.name} has invalid non-type annotation '
@@ -218,8 +218,8 @@ def add_function(self, function_id: str,
218218
return_pytype = None
219219
if return_binding_name is not None and 'return' in annotations:
220220
return_anno = annotations.get('return')
221-
if (typing_inspect.is_generic_type(return_anno) and
222-
typing_inspect.get_origin(return_anno).__name__ == 'Out'):
221+
if (typing_inspect.is_generic_type(return_anno)
222+
and typing_inspect.get_origin(return_anno).__name__ == 'Out'):
223223
raise FunctionLoadError(
224224
func_name,
225225
f'return annotation should not be azure.functions.Out')

azure_functions_worker/testutils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ class AsyncTestCaseMeta(type(unittest.TestCase)):
103103

104104
def __new__(mcls, name, bases, ns):
105105
for attrname, attr in ns.items():
106-
if (attrname.startswith('test_') and
107-
inspect.iscoroutinefunction(attr)):
106+
if (attrname.startswith('test_')
107+
and inspect.iscoroutinefunction(attr)):
108108
ns[attrname] = mcls._sync_wrap(attr)
109109

110110
return super().__new__(mcls, name, bases, ns)
@@ -348,7 +348,7 @@ async def invoke_function(
348348
name,
349349
input_data: typing.List[protos.ParameterBinding],
350350
metadata: typing.Optional[
351-
typing.Mapping[str, protos.TypedData]]=None):
351+
typing.Mapping[str, protos.TypedData]] = None):
352352

353353
if metadata is None:
354354
metadata = {}

pack/Microsoft.Azure.Functions.PythonWorker.nuspec renamed to pack/Microsoft.Azure.Functions.V2.PythonWorker.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
<file src="..\3.7_LINUX_X64\**" target="tools\3.7\LINUX\X64" />
2020
<file src="..\3.7_OSX_X64\**" target="tools\3.7\OSX\X64" />
2121
<file src="..\python\prod\worker.config.json" target="tools" />
22-
<file src="Microsoft.Azure.Functions.PythonWorker.targets" target="build" />
22+
<file src="Microsoft.Azure.Functions.V2.PythonWorker.targets" target="build" />
2323
</files>
24-
</package>
24+
</package>

pack/Microsoft.Azure.Functions.PythonWorker.targets renamed to pack/Microsoft.Azure.Functions.V2.PythonWorker.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
</Target>
1515

1616
<Target Name="CopyOnPublish" DependsOnTargets="Initialize" AfterTargets="Publish">
17-
<Copy SourceFiles="@(SourceFiles)"
17+
<Copy SourceFiles="@(SourceFiles)"
1818
DestinationFiles="@(SourceFiles->'$(PublishDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" />
1919
</Target>
2020

2121
<Target Name="CopyOnBuild" DependsOnTargets="Initialize" AfterTargets="Build">
22-
<Copy SourceFiles="@(SourceFiles)"
22+
<Copy SourceFiles="@(SourceFiles)"
2323
DestinationFiles="@(SourceFiles->'$(OutDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" />
2424
</Target>
25-
</Project>
25+
</Project>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
3+
<metadata>
4+
<id>Microsoft.Azure.Functions.PythonWorker</id>
5+
<version>1.1.0</version>
6+
<authors>Microsoft</authors>
7+
<owners>Microsoft</owners>
8+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
9+
<description>Microsoft Azure Functions Python Worker</description>
10+
<copyright>© .NET Foundation. All rights reserved.</copyright>
11+
</metadata>
12+
<files>
13+
<file src="..\3.6_WINDOWS_x64\**" target="tools\3.6\WINDOWS\X64" />
14+
<!-- <file src="..\3.6_WINDOWS_X86\**" target="tools\3.6\WINDOWS\X86" /> -->
15+
<file src="..\3.6_LINUX_X64\**" target="tools\3.6\LINUX\X64" />
16+
<file src="..\3.6_OSX_X64\**" target="tools\3.6\OSX\X64" />
17+
<file src="..\3.7_WINDOWS_X64\**" target="tools\3.7\WINDOWS\X64" />
18+
<file src="..\3.7_WINDOWS_X86\**" target="tools\3.7\WINDOWS\X86" />
19+
<file src="..\3.7_LINUX_X64\**" target="tools\3.7\LINUX\X64" />
20+
<file src="..\3.7_OSX_X64\**" target="tools\3.7\OSX\X64" />
21+
<file src="..\3.8_WINDOWS_X64\**" target="tools\3.8\WINDOWS\X64" />
22+
<file src="..\3.8_WINDOWS_X86\**" target="tools\3.8\WINDOWS\X86" />
23+
<file src="..\3.8_LINUX_X64\**" target="tools\3.8\LINUX\X64" />
24+
<file src="..\3.8_OSX_X64\**" target="tools\3.8\OSX\X64" />
25+
<file src="..\python\prod\worker.config.json" target="tools" />
26+
<file src="Microsoft.Azure.Functions.V3.PythonWorker.targets" target="build" />
27+
</files>
28+
</package>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project>
2+
<Target Name="Initialize" AfterTargets="Publish;Build">
3+
<CreateItem Include="$(MSBuildThisFileDirectory)\..\">
4+
<Output ItemName="MSBuildThisFileDirectoryParentDirectory" TaskParameter="Include"/>
5+
</CreateItem>
6+
7+
<CreateProperty Value="%(MSBuildThisFileDirectoryParentDirectory.Fullpath)">
8+
<Output PropertyName="NugetRoot" TaskParameter="Value"/>
9+
</CreateProperty>
10+
11+
<ItemGroup>
12+
<SourceFiles Include="$(NugetRoot)tools\**\*.*"/>
13+
</ItemGroup>
14+
</Target>
15+
16+
<Target Name="CopyOnPublish" DependsOnTargets="Initialize" AfterTargets="Publish">
17+
<Copy SourceFiles="@(SourceFiles)"
18+
DestinationFiles="@(SourceFiles->'$(PublishDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" />
19+
</Target>
20+
21+
<Target Name="CopyOnBuild" DependsOnTargets="Initialize" AfterTargets="Build">
22+
<Copy SourceFiles="@(SourceFiles)"
23+
DestinationFiles="@(SourceFiles->'$(OutDir)\workers\python\%(RecursiveDir)%(Filename)%(Extension)')" />
24+
</Target>
25+
</Project>

pack/scripts/win_deps.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ python -m pip install .
44

55
$depsPath = Join-Path -Path $env:BUILD_SOURCESDIRECTORY -ChildPath "deps"
66

7-
python -m pip install . azure-functions --no-compile --target $depsPath.ToString()
7+
python -m pip install . azure-functions --no-compile --target $depsPath.ToString()

0 commit comments

Comments
 (0)