Skip to content

Commit 27cbe2f

Browse files
elprans1st1
authored andcommitted
Simplify installation process
Move dependencies to setup.py and make protobuf stub generation part of setup.py build stage.
1 parent ea769f2 commit 27cbe2f

6 files changed

+42
-44
lines changed

.ci/travis_install.sh

+1-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@ python --version
66

77
.ci/travis_download_webhost.sh
88

9-
pip install -r requirements-dev.txt
10-
pip install -e .
11-
12-
python setup.py gen_grpc
9+
pip install -U -e .[dev]

DEVELOPMENT.md

+3-15
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,11 @@ $ cd azure-functions-python-worker
3333
dll = /MY/LOCAL/PATH/TO/SiteExtensions/Functions/Microsoft.Azure.WebJobs.Script.WebHost.dll
3434
```
3535

36-
6. Install requirements for development and testing:
36+
6. Setup the 'azure' package in your new virtual environment
37+
in development mode:
3738

3839
```shell
39-
$ pip install -r requirements-dev.txt
40-
```
41-
42-
7. Install your local 'azure' package in your new virtual environment
43-
(so that Python can import the `azure` package):
44-
45-
```shell
46-
$ pip install -e .
47-
```
48-
49-
8. Generate GRPC implementation files:
50-
51-
```shell
52-
$ python setup.py gen_grpc
40+
$ pip install -U -e .[dev]
5341
```
5442

5543

appveyor.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ environment:
99
install:
1010
- ps: .ci\appveyor_download_webhost.ps1
1111
- "%PYTHON% -m pip install --upgrade pip wheel setuptools"
12-
- "%PYTHON% -m pip install --upgrade -r requirements-dev.txt"
1312

1413
build_script:
15-
- "%PYTHON% setup.py build"
16-
- "%PYTHON% setup.py gen_grpc"
14+
- "%PYTHON% -m pip install -U -e .[dev]"
1715

1816
test_script:
1917
- set PYAZURE_WEBHOST_DLL=%cd%\%PYAZURE_WEBHOST_PATH%\%PYAZURE_WEBHOST_EXECUTABLE% && %PYTHON% .ci\appveyor_setup_worker.py > worker_path && set /p PYAZURE_WORKER_DIR=<worker_path && %PYTHON% setup.py test

requirements-dev.txt

-5
This file was deleted.

requirements.txt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
grpcio
2-
grpcio-tools
1+
# Please list runtime dependencies in setup.py 'install_requires' and
2+
# 'extras_require'.
3+
.

setup.py

+34-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
import distutils.cmd
21
import os
32
import subprocess
43
import sys
4+
from distutils.command import build
55

66
from setuptools import setup
7+
from setuptools.command import develop
78

89

9-
class GenGrpcCommand(distutils.cmd.Command):
10-
description = 'Generate GRPC Python bindings.'
11-
user_options = []
12-
13-
def initialize_options(self):
14-
pass
15-
16-
def finalize_options(self):
17-
pass
18-
19-
def run(self):
10+
class BuildGRPC:
11+
"""Generate gRPC bindings."""
12+
def _gen_grpc(self):
2013
cwd = os.getcwd()
2114

2215
subprocess.run([
23-
'python', '-m', 'grpc_tools.protoc',
16+
sys.executable, '-m', 'grpc_tools.protoc',
2417
'-I', os.sep.join(('azure', 'worker', 'protos')),
2518
'--python_out', cwd,
2619
'--grpc_python_out', cwd,
@@ -30,6 +23,18 @@ def run(self):
3023
], check=True, stdout=sys.stdout, stderr=sys.stderr)
3124

3225

26+
class build(build.build, BuildGRPC):
27+
def run(self, *args, **kwargs):
28+
self._gen_grpc()
29+
super().run(*args, **kwargs)
30+
31+
32+
class develop(develop.develop, BuildGRPC):
33+
def run(self, *args, **kwargs):
34+
self._gen_grpc()
35+
super().run(*args, **kwargs)
36+
37+
3338
setup(
3439
name='azure',
3540
version='0.0.1',
@@ -45,11 +50,25 @@ def run(self):
4550
'Development Status :: 3 - Alpha',
4651
],
4752
license='MIT',
48-
packages=['azure', 'azure.worker', 'azure.functions'],
53+
packages=['azure', 'azure.functions',
54+
'azure.worker', 'azure.worker.protos'],
4955
provides=['azure'],
56+
install_requires=[
57+
'grpcio',
58+
'grpcio-tools',
59+
],
60+
extras_require={
61+
'dev': [
62+
'pytest',
63+
'requests',
64+
'mypy',
65+
'flake8',
66+
]
67+
},
5068
include_package_data=True,
5169
cmdclass={
52-
'gen_grpc': GenGrpcCommand
70+
'build': build,
71+
'develop': develop
5372
},
5473
test_suite='tests'
5574
)

0 commit comments

Comments
 (0)