generate protobuf python file using setuptools

This commit is contained in:
Domenico Iezzi 2019-04-09 14:34:24 +02:00
parent 26f675c5a6
commit e5e60b8356
No known key found for this signature in database
GPG Key ID: D8CE73FC9E4393C3
4 changed files with 44 additions and 12480 deletions

3
.gitignore vendored
View File

@ -8,3 +8,6 @@ dist/
*.egg-info/
.idea/
.venv/
# This file will be generated during build
gpapi/googleplay_pb2.py

View File

@ -9,6 +9,15 @@ maintained anymore. The code was updated with some important changes:
* select the device you want to fake from a list of pre-defined values (check `device.properties`)
(defaults to a OnePlus One)
# Build
This is the recommended way to build the package, since setuptools will take care of
generating the `googleplay_pb2.py` file needed by the library (check the `setup.py`)
```
$ python setup.py build
```
# Usage
Check scripts in `test` directory for more examples on how to use this API.

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,27 @@
from setuptools import setup
from setuptools.command.build_py import build_py as _build
import os.path
import subprocess
PROTOC_BIN = "/usr/bin/protoc"
CURRENT_DIR = os.path.abspath( os.path.dirname( __file__ ) )
class ProtobufBuilder(_build):
def run(self):
# check if protobuf is installed
if not os.path.isfile(PROTOC_BIN):
raise Exception("You should install protobuf compiler")
print("Building protobuf file")
subprocess.run([PROTOC_BIN,
"--proto_path=" + CURRENT_DIR,
"--python_out=" + CURRENT_DIR + "/gpapi/",
"googleplay.proto"])
super().run()
setup(name='gpapi',
version='0.4.3',
@ -8,7 +31,15 @@ setup(name='gpapi',
author_email='domenico.iezzi.201@gmail.com',
license='GPL3',
packages=['gpapi'],
package_data={'gpapi': ['device.properties']},
package_data={
'gpapi': [
'config.py'
'device.properties',
'googleplay_pb2.py',
'googleplay.py',
'utils.py'
]},
cmdclass={'build_py': ProtobufBuilder},
install_requires=['cryptography>=2.2',
'protobuf>=3.5.2',
'requests'])