-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsetup.py
More file actions
141 lines (118 loc) · 4.97 KB
/
setup.py
File metadata and controls
141 lines (118 loc) · 4.97 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# The MIT License (MIT)
# Copyright © 2023 Yuma Rao
# KMFODA
# Copyright © 2023 <your name>
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the “Software”), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of
# the Software.
# THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
# THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
import codecs
import os
import re
import subprocess
from io import open
from os import path
from pkg_resources import parse_requirements
from setuptools import find_packages, setup
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install
def custom_command():
import pip
pip.main(
[
"install",
"git+https://github.com/learning-at-home/hivemind.git@3a4cc15e29ce51b20c5d415a4c579abbae435718",
]
)
pip.main(["install", "bittensor==9.12.2"])
pip.main(["install", "py-multihash==2.0.1"])
# Install Go and HFDownloader
try:
subprocess.run(["apt-get", "update"], check=True)
subprocess.run(["apt-get", "install", "-y", "golang"], check=True)
subprocess.run(
["go", "install", "github.com/lxe/hfdownloader@latest"], check=True
)
# Add Go bin to PATH in venv activate script
if "VIRTUAL_ENV" in os.environ:
activate_script = os.path.join(os.environ["VIRTUAL_ENV"], "bin", "activate")
if os.path.exists(activate_script):
with open(activate_script, "a") as f:
f.write('\nexport PATH="$HOME/go/bin:$PATH"\n')
# Also update current session's PATH
go_bin_path = os.path.expanduser("~/go/bin")
if go_bin_path not in os.environ["PATH"]:
os.environ["PATH"] = f"{go_bin_path}:{os.environ['PATH']}"
except Exception as e:
raise RuntimeError(f"Failed to install Go and HFDownloader: {str(e)}")
class CustomInstallCommand(install):
def run(self):
custom_command()
install.run(self)
class CustomDevelopCommand(develop):
def run(self):
custom_command()
develop.run(self)
class CustomEggInfoCommand(egg_info):
def run(self):
custom_command()
egg_info.run(self)
with open("requirements.txt") as requirements_file:
requirements = list(map(str, parse_requirements(requirements_file)))
here = path.abspath(path.dirname(__file__))
with open(path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()
# loading version from setup.py
with codecs.open(
os.path.join(here, "distributed_training/__init__.py"), encoding="utf-8"
) as init_file:
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", init_file.read(), re.M
)
version_string = version_match.group(1)
setup(
name="distributed_training",
version=version_string,
description="distributed_training",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/dstrbtd/DistributedTraining",
author="KMFODA",
packages=find_packages(),
include_package_data=True,
author_email="",
license="MIT",
python_requires=">=3.8",
cmdclass={
"install": CustomInstallCommand,
"develop": CustomDevelopCommand,
"egg_info": CustomEggInfoCommand,
},
setup_requires=["pip"],
install_requires=requirements,
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
# Pick your license as you wish
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)