forked from NVIDIA/nv-ingest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
73 lines (56 loc) · 2.15 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES.
# All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
import datetime
import os
import re
from setuptools import find_packages
from setuptools import setup
# TODO(Devin): This is duplicated in nv_ingest_client's setup.py, should be moved to common once Jermey's PR is merged
def get_version():
release_type = os.getenv("NV_INGEST_RELEASE_TYPE", "dev")
version = os.getenv("NV_INGEST_VERSION")
rev = os.getenv("NV_INGEST_REV", "0")
if not version:
version = f"{datetime.datetime.now().strftime('%Y.%m.%d')}"
# Ensure the version is PEP 440 compatible
pep440_regex = r"^\d{4}\.\d{1,2}\.\d{1,2}$"
if not re.match(pep440_regex, version):
raise ValueError(f"Version '{version}' is not PEP 440 compatible")
# Construct the final version string
if release_type == "dev":
final_version = f"{version}.dev{rev}"
elif release_type == "release":
final_version = f"{version}.post{rev}" if int(rev) > 0 else version
else:
raise ValueError(f"Invalid release type: {release_type}")
return final_version
def read_requirements(file_name):
"""Read a requirements file and return a list of its packages."""
with open(file_name) as f:
return f.read().splitlines()
# Specify your requirements files
requirements_files = [
"requirements.txt",
"util-requirements.txt",
"test-requirements.txt",
]
# Read and combine requirements from all specified files
combined_requirements = []
for file in requirements_files:
combined_requirements.extend(read_requirements(file))
combined_requirements = list(set(combined_requirements))
setup(
author="Devin Robison",
author_email="[email protected]",
classifiers=[],
description="Python module supporting document ingestion",
install_requires=combined_requirements,
license="Apache-2.0",
name="nv_ingest",
package_dir={"": "src"},
packages=find_packages(where="src"),
python_requires=">=3.10",
version=get_version(),
)