|
1 | 1 | from setuptools import setup, find_packages |
2 | 2 | import sys |
| 3 | +import pathlib |
3 | 4 | import platform |
4 | 5 |
|
| 6 | +parent = pathlib.Path(__file__).parent |
| 7 | +# get the readme for use in our long description |
| 8 | +readme = (parent / "README.md").read_text() |
5 | 9 |
|
6 | 10 | python_version = platform.python_version().rsplit('.', maxsplit=1)[0] |
7 | 11 |
|
8 | 12 | mac_v, _, _ = platform.mac_ver() |
9 | 13 | if mac_v != '': |
10 | | - mac_version = '.'.join(mac_v.split('.')[:2]) |
| 14 | + mac_v_split = mac_v.split('.') |
| 15 | + mac_major_version = mac_v_split[0] |
| 16 | + mac_minor_version = mac_v_split[1] |
| 17 | + mac_version = '.'.join([mac_major_version, mac_minor_version]) |
11 | 18 | else: |
| 19 | + mac_major_version = None |
12 | 20 | mac_version = None |
13 | 21 |
|
14 | 22 | requirements = [ |
15 | | - "pillow>=8.1.1", |
16 | | - "requests", |
17 | | - "numpy~=1.19.3", |
18 | | - "tensorflow~=2.4;platform_machine!='armv7l'", |
19 | | - "onnxruntime~=1.7.0;platform_machine!='armv7l'" |
| 23 | + "numpy~=1.19.5", |
| 24 | + "pillow~=8.3.1", |
| 25 | + "requests" |
20 | 26 | ] |
| 27 | +tf_req = "tensorflow~=2.5.0;platform_machine!='armv7l'" |
| 28 | +onnx_req = "onnxruntime~=1.8.1;platform_machine!='armv7l'" |
| 29 | +tflite_req = None |
21 | 30 |
|
22 | 31 | # get the right TF Lite runtime packages based on OS and python version: https://www.tensorflow.org/lite/guide/python#install_just_the_tensorflow_lite_interpreter |
23 | 32 | tflite_python = None |
| 33 | +tflite_platform = None |
24 | 34 | tflite_machine = None |
25 | 35 |
|
26 | 36 | # get the right python string for the version |
27 | | -if python_version == '3.5': |
28 | | - tflite_python = 'cp35-cp35m' |
29 | | -elif python_version == '3.6': |
| 37 | +if python_version == '3.6': |
30 | 38 | tflite_python = 'cp36-cp36m' |
31 | 39 | elif python_version == '3.7': |
32 | 40 | tflite_python = 'cp37-cp37m' |
33 | 41 | elif python_version == '3.8': |
34 | 42 | tflite_python = 'cp38-cp38' |
| 43 | +elif python_version == '3.9': |
| 44 | + tflite_python = 'cp39-cp39' |
35 | 45 |
|
36 | | -# get the right machine string |
37 | | -if sys.platform == 'win32': |
38 | | - tflite_machine = 'win_amd64' |
39 | | -elif sys.platform == 'darwin' and mac_version == '10.15': |
40 | | - tflite_machine = 'macosx_10_15_x86_64' |
41 | | -elif sys.platform == 'linux': |
42 | | - if platform.machine() == 'x86_64': |
43 | | - tflite_machine = 'linux_x86_64' |
44 | | - elif platform.machine() == 'armv7l': |
45 | | - tflite_machine = 'linux_armv7l' |
| 46 | +# get the right platform and machine strings for the tflite_runtime wheel URL |
| 47 | +sys_platform = sys.platform.lower() |
| 48 | +machine = platform.machine().lower() |
| 49 | +if sys_platform == 'linux': |
| 50 | + tflite_platform = sys_platform |
| 51 | + tflite_machine = machine |
| 52 | +elif sys_platform == 'win32': |
| 53 | + tflite_platform = 'win' |
| 54 | + tflite_machine = machine |
| 55 | +elif sys_platform == 'darwin' and machine == 'x86_64': |
| 56 | + if mac_version == '10.15': |
| 57 | + tflite_platform = 'macosx_10_15' |
| 58 | + elif mac_major_version == '11': |
| 59 | + tflite_platform = 'macosx_11_0' |
| 60 | + tflite_machine = machine |
46 | 61 |
|
47 | 62 | # add it to the requirements, or print the location to find the version to install |
48 | | -if tflite_python and tflite_machine: |
49 | | - requirements.append(f"tflite_runtime @ https://github.com/google-coral/pycoral/releases/download/release-frogfish/tflite_runtime-2.5.0-{tflite_python}-{tflite_machine}.whl") |
| 63 | +if tflite_python and tflite_platform and tflite_machine: |
| 64 | + tflite_req = f"tflite_runtime @ https://github.com/google-coral/pycoral/releases/download/v2.0.0/tflite_runtime-2.5.0.post1-{tflite_python}-{tflite_platform}_{tflite_machine}.whl" |
50 | 65 | else: |
51 | 66 | print( |
52 | | - f"Couldn't find tflite_runtime for your platform {sys.platform}, machine {platform.machine()}, and python version {python_version}, please see the install guide for the right version: https://www.tensorflow.org/lite/guide/python#install_just_the_tensorflow_lite_interpreter" |
| 67 | + f"Couldn't find tflite_runtime for your platform {sys.platform}, machine {platform.machine()}, python version {python_version}, and mac version {mac_version}. If you are trying to use TensorFlow Lite, please see the install guide for the right version: https://www.tensorflow.org/lite/guide/python#install_just_the_tensorflow_lite_interpreter" |
53 | 68 | ) |
54 | 69 |
|
55 | 70 | setup( |
56 | 71 | name="lobe", |
57 | | - version="0.4.0", |
| 72 | + version="0.5.0", |
| 73 | + description="Lobe Python SDK", |
| 74 | + long_description=readme, |
| 75 | + long_description_content_type="text/markdown", |
| 76 | + url="https://github.com/lobe/lobe-python", |
| 77 | + license="MIT", |
58 | 78 | packages=find_packages("src"), |
59 | 79 | package_dir={"": "src"}, |
60 | 80 | install_requires=requirements, |
| 81 | + extras_require={ |
| 82 | + 'all': [tf_req, onnx_req, tflite_req], |
| 83 | + 'tf': [tf_req], |
| 84 | + 'onnx': [onnx_req], |
| 85 | + 'tflite': [tflite_req], |
| 86 | + } |
61 | 87 | ) |
0 commit comments