-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathsetup.py
More file actions
executable file
·98 lines (83 loc) · 3.51 KB
/
setup.py
File metadata and controls
executable file
·98 lines (83 loc) · 3.51 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python
import glob
import os
from collections.abc import Iterator
from importlib.util import module_from_spec, spec_from_file_location
from setuptools import find_packages, setup
_PATH_ROOT = os.path.realpath(os.path.dirname(__file__))
_PATH_SOURCE = os.path.join(_PATH_ROOT, "src")
_PATH_REQUIRE = os.path.join(_PATH_ROOT, "requirements")
def _load_py_module(fname: str, pkg: str = "lightning_utilities"):
spec = spec_from_file_location(os.path.join(pkg, fname), os.path.join(_PATH_SOURCE, pkg, fname))
py = module_from_spec(spec)
spec.loader.exec_module(py)
return py
about = _load_py_module("__about__.py")
requirements_module = _load_py_module(os.path.join("install", "requirements.py"))
# load basic requirements using the central parser from lightning_utilities.install.requirements
def _parse_requirements(lines: list[str]) -> Iterator[str]:
"""Parse requirements from lines using the canonical parser."""
return (str(req) for req in requirements_module._parse_requirements(lines))
with open(os.path.join(_PATH_REQUIRE, "core.txt")) as fp:
requirements = list(_parse_requirements(fp.readlines()))
# make extras as automated loading
def _requirement_extras(path_req: str = _PATH_REQUIRE) -> dict:
extras = {}
for fpath in glob.glob(os.path.join(path_req, "*.txt")):
fname = os.path.basename(fpath)
if fname.startswith(("_", "gha-")):
continue
if fname in ("core.txt",):
continue
name, _ = os.path.splitext(fname)
with open(fpath) as fp:
extras[name] = list(_parse_requirements(fp.readlines()))
return extras
# loading readme as description
with open(os.path.join(_PATH_ROOT, "README.md")) as fp:
readme = fp.read()
setup(
name="lightning-utilities",
version=about.__version__,
description=about.__docs__,
author=about.__author__,
author_email=about.__author_email__,
url=about.__homepage__,
download_url="https://github.com/Lightning-AI/utilities",
license=about.__license__, # Should be a license identifier like "MIT"
license_files=["LICENSE"], # Path to your license file
packages=find_packages(where="src"),
package_dir={"": "src"},
long_description=readme,
long_description_content_type="text/markdown",
include_package_data=True,
zip_safe=False,
keywords=["Utilities", "DevOps", "CI/CD"],
python_requires=">=3.10",
setup_requires=[],
install_requires=requirements,
extras_require=_requirement_extras(),
project_urls={
"Bug Tracker": "https://github.com/Lightning-AI/utilities/issues",
"Documentation": "https://dev-toolbox.rtfd.io/en/latest/", # TODO: Update domain
"Source Code": "https://github.com/Lightning-AI/utilities",
},
classifiers=[
"Environment :: Console",
"Natural Language :: English",
# How mature is this project? Common values are
# 3 - Alpha, 4 - Beta, 5 - Production/Stable
"Development Status :: 3 - Alpha",
# Indicate who your project is intended for
"Intended Audience :: Developers",
# Pick your license as you wish
# 'License :: OSI Approved :: BSD License',
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
],
)