|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -import os |
| 15 | +from setuptools import find_packages, setup |
| 16 | +from typing import List |
| 17 | +from collections import defaultdict |
16 | 18 |
|
17 | | -import setuptools |
18 | 19 |
|
19 | | -readme_path = os.path.join(os.path.dirname(__file__), "README.md") |
| 20 | +def parse_requirements(lines: List[str]): |
| 21 | + extras_requires = defaultdict(list) |
| 22 | + extra = "requires" |
| 23 | + for line in lines: |
| 24 | + line = line.strip() |
| 25 | + if line.startswith("# extra="): |
| 26 | + extra = line.split("=")[1].strip() |
| 27 | + continue |
| 28 | + if line and line[0] != "#": |
| 29 | + lib_package = line.split("#")[0].strip() # split comments |
| 30 | + extras_requires[extra].append(lib_package) |
| 31 | + install_requires = extras_requires.pop("requires") |
| 32 | + return install_requires, extras_requires |
20 | 33 |
|
21 | | -with open(readme_path, "r", encoding="utf-8") as fh: |
22 | | - long_description = fh.read() |
23 | 34 |
|
24 | | -requirements_path = os.path.join(os.path.dirname(__file__), "requirements.txt") |
| 35 | +with open("requirements.txt", "r", encoding="utf-8") as fr: |
| 36 | + install_requires, extras_requires = parse_requirements(fr.readlines()) |
25 | 37 |
|
26 | | -with open(requirements_path, "r") as fr: |
27 | | - requirements = fr.read().splitlines() |
28 | | - print(requirements) |
| 38 | +with open("README.md", "r", encoding="utf-8") as fh: |
| 39 | + long_description = fh.read() |
29 | 40 |
|
30 | 41 |
|
31 | | -setuptools.setup( |
| 42 | +setup( |
32 | 43 | name="TensorFlowASR", |
33 | 44 | version="1.0.2", |
34 | 45 | author="Huy Le Nguyen", |
|
37 | 48 | long_description=long_description, |
38 | 49 | long_description_content_type="text/markdown", |
39 | 50 | url="https://github.com/TensorSpeech/TensorFlowASR", |
40 | | - packages=setuptools.find_packages(include=["tensorflow_asr*"]), |
41 | | - install_requires=requirements, |
42 | | - extras_require={ |
43 | | - "tf2.3": ["tensorflow~=2.3.0", "tensorflow-text~=2.3.0", "tensorflow-io~=0.16.0"], |
44 | | - "tf2.3-gpu": ["tensorflow-gpu~=2.3.0", "tensorflow-text~=2.3.0", "tensorflow-io~=0.16.0"], |
45 | | - "tf2.4": ["tensorflow~=2.4.0", "tensorflow-text~=2.4.0", "tensorflow-io~=0.17.0"], |
46 | | - "tf2.4-gpu": ["tensorflow-gpu~=2.4.0", "tensorflow-text~=2.4.0", "tensorflow-io~=0.17.0"], |
47 | | - "tf2.5": ["tensorflow~=2.5.0", "tensorflow-text~=2.5.0", "tensorflow-io~=0.18.0"], |
48 | | - "tf2.5-gpu": ["tensorflow-gpu~=2.5.0", "tensorflow-text~=2.5.0", "tensorflow-io~=0.18.0"], |
49 | | - "tf2.6": ["tensorflow~=2.6.0", "tensorflow-text~=2.6.0rc0", "tensorflow-io~=0.20.0"], |
50 | | - "tf2.6-gpu": ["tensorflow-gpu~=2.6.0", "tensorflow-text~=2.6.0rc0", "tensorflow-io~=0.20.0"], |
51 | | - }, |
| 51 | + packages=find_packages(include=("tensorflow_asr", "tensorflow_asr.*")), |
| 52 | + install_requires=install_requires, |
| 53 | + extras_require=extras_requires, |
52 | 54 | classifiers=[ |
53 | 55 | "Programming Language :: Python :: 3.6", |
54 | 56 | "Programming Language :: Python :: 3.7", |
55 | 57 | "Programming Language :: Python :: 3.8", |
| 58 | + "Programming Language :: Python :: 3.9", |
56 | 59 | "Intended Audience :: Science/Research", |
57 | 60 | "Operating System :: POSIX :: Linux", |
58 | 61 | "License :: OSI Approved :: Apache Software License", |
59 | 62 | "Topic :: Software Development :: Libraries :: Python Modules", |
60 | 63 | ], |
61 | | - python_requires=">=3.6", |
| 64 | + python_requires=">=3.6, <4", |
62 | 65 | ) |
0 commit comments