|
14 | 14 | from __future__ import absolute_import |
15 | 15 |
|
16 | 16 | import os |
17 | | -from glob import glob |
| 17 | +import re |
18 | 18 | import sys |
| 19 | +from ast import literal_eval |
| 20 | +from glob import glob |
| 21 | +from pathlib import Path |
19 | 22 |
|
20 | 23 | from setuptools import find_packages, setup |
21 | 24 |
|
22 | | - |
23 | | -def read(fname): |
| 25 | +sys.stderr.write( |
24 | 26 | """ |
25 | | - Args: |
26 | | - fname: |
27 | | - """ |
28 | | - return open(os.path.join(os.path.dirname(__file__), fname)).read() |
29 | | - |
| 27 | +=============================== |
| 28 | +Unsupported installation method |
| 29 | +=============================== |
30 | 30 |
|
31 | | -def read_version(): |
32 | | - return read("VERSION").strip() |
| 31 | +This version of sagemaker no longer supports installation with `python setup.py install`. |
33 | 32 |
|
| 33 | +Please use `python -m pip install .` instead. |
| 34 | +""" |
| 35 | +) |
34 | 36 |
|
35 | | -def read_requirements(filename): |
36 | | - """Reads requirements file which lists package dependencies. |
37 | | -
|
38 | | - Args: |
39 | | - filename: type(str) Relative file path of requirements.txt file |
| 37 | +HERE = Path(__file__).parent.absolute() |
| 38 | +PYPROJECT = HERE.joinpath("pyproject.toml").read_text(encoding="utf-8") |
| 39 | +BUILD_SCRIPT = HERE.joinpath("hatch_build.py").read_text(encoding="utf-8") |
40 | 40 |
|
41 | | - Returns: |
42 | | - list of dependencies extracted from file |
43 | | - """ |
44 | | - with open(os.path.abspath(filename)) as fp: |
45 | | - deps = [line.strip() for line in fp.readlines()] |
46 | | - return deps |
47 | 41 |
|
| 42 | +def get_dependencies(): |
| 43 | + pattern = r"^dependencies = (\[.*?\])$" |
| 44 | + array = re.search(pattern, PYPROJECT, flags=re.MULTILINE | re.DOTALL).group(1) |
| 45 | + return literal_eval(array) |
48 | 46 |
|
49 | | -# Declare minimal set for installation |
50 | | -required_packages = [ |
51 | | - "attrs>=23.1.0,<24", |
52 | | - "boto3>=1.34.142,<2.0", |
53 | | - "cloudpickle==2.2.1", |
54 | | - "google-pasta", |
55 | | - "numpy>=1.9.0,<2.0", |
56 | | - "protobuf>=3.12,<5.0", |
57 | | - "smdebug_rulesconfig==1.0.1", |
58 | | - "importlib-metadata>=1.4.0,<7.0", |
59 | | - "packaging>=20.0", |
60 | | - "pandas", |
61 | | - "pathos", |
62 | | - "schema", |
63 | | - "PyYAML~=6.0", |
64 | | - "jsonschema", |
65 | | - "platformdirs", |
66 | | - "tblib>=1.7.0,<4", |
67 | | - "urllib3>=1.26.8,<3.0.0", |
68 | | - "requests", |
69 | | - "docker", |
70 | | - "tqdm", |
71 | | - "psutil", |
72 | | -] |
73 | 47 |
|
74 | | -# Specific use case dependencies |
75 | | -# Keep format of *_requirements.txt to be tracked by dependabot |
76 | | -extras = { |
77 | | - "local": read_requirements("requirements/extras/local_requirements.txt"), |
78 | | - "scipy": read_requirements("requirements/extras/scipy_requirements.txt"), |
79 | | - "feature-processor": read_requirements( |
80 | | - "requirements/extras/feature-processor_requirements.txt" |
81 | | - ), |
82 | | - "huggingface": read_requirements("requirements/extras/huggingface_requirements.txt"), |
83 | | -} |
84 | | -# Meta dependency groups |
85 | | -extras["all"] = [item for group in extras.values() for item in group] |
86 | | -# Tests specific dependencies (do not need to be included in 'all') |
87 | | -test_dependencies = read_requirements("requirements/extras/test_requirements.txt") |
88 | | -# test dependencies are a superset of testing and extra dependencies |
89 | | -test_dependencies.extend(extras["all"]) |
90 | | -# remove torch and torchvision if python version is not 3.10/3.11 |
91 | | -if sys.version_info.minor != 10 or sys.version_info.minor != 11: |
92 | | - test_dependencies = [ |
93 | | - module |
94 | | - for module in test_dependencies |
95 | | - if not ( |
96 | | - module.startswith("transformers") |
97 | | - or module.startswith("sentencepiece") |
98 | | - or module.startswith("torch") |
99 | | - or module.startswith("torchvision") |
100 | | - ) |
101 | | - ] |
| 48 | +def get_optional_dependencies(): |
| 49 | + pattern = r"^def get_optional_dependencies.+" |
| 50 | + function = re.search(pattern, BUILD_SCRIPT, flags=re.MULTILINE | re.DOTALL).group(0) |
| 51 | + identifiers = {} |
| 52 | + exec(function, None, identifiers) |
| 53 | + return identifiers["get_optional_dependencies"](str(HERE)) |
102 | 54 |
|
103 | | -extras["test"] = (test_dependencies,) |
104 | 55 |
|
105 | 56 | setup( |
106 | 57 | name="sagemaker", |
107 | | - version=read_version(), |
108 | | - description="Open source library for training and deploying models on Amazon SageMaker.", |
| 58 | + version=HERE.joinpath("VERSION").read_text().strip(), |
109 | 59 | packages=find_packages("src"), |
110 | 60 | package_dir={"": "src"}, |
111 | 61 | package_data={"": ["*.whl"]}, |
112 | 62 | py_modules=[os.path.splitext(os.path.basename(path))[0] for path in glob("src/*.py")], |
113 | 63 | include_package_data=True, |
114 | | - long_description=read("README.rst"), |
115 | | - author="Amazon Web Services", |
116 | | - url="https://github.com/aws/sagemaker-python-sdk/", |
117 | | - license="Apache License 2.0", |
118 | | - keywords="ML Amazon AWS AI Tensorflow MXNet", |
119 | | - python_requires=">= 3.8", |
120 | | - classifiers=[ |
121 | | - "Development Status :: 5 - Production/Stable", |
122 | | - "Intended Audience :: Developers", |
123 | | - "Natural Language :: English", |
124 | | - "License :: OSI Approved :: Apache Software License", |
125 | | - "Programming Language :: Python", |
126 | | - "Programming Language :: Python :: 3.8", |
127 | | - "Programming Language :: Python :: 3.9", |
128 | | - "Programming Language :: Python :: 3.10", |
129 | | - "Programming Language :: Python :: 3.11", |
130 | | - ], |
131 | | - install_requires=required_packages, |
132 | | - extras_require=extras, |
| 64 | + install_requires=get_dependencies(), |
| 65 | + extras_require=get_optional_dependencies(), |
133 | 66 | entry_points={ |
134 | 67 | "console_scripts": [ |
135 | 68 | "sagemaker-upgrade-v2=sagemaker.cli.compatibility.v2.sagemaker_upgrade_v2:main", |
|
0 commit comments