forked from Aider-AI/aider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
111 lines (91 loc) · 3.28 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
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
import re
import subprocess
import sys
from setuptools import find_packages, setup
from aider import __version__
from aider.help_pats import exclude_website_pats
# Find the torch requirement and replace it with the CPU only version,
# because the GPU versions are huge
def get_requirements():
with open("requirements.txt") as f:
requirements = f.read().splitlines()
requirements = [line for line in requirements if not line.startswith("---extra-index-url")]
torch = next((req for req in requirements if req.startswith("torch==")), None)
if not torch:
return requirements
pytorch_url = None
cmd = [
sys.executable,
"-m",
"pip",
"install",
torch,
"--no-deps",
"--dry-run",
"--no-cache-dir", # Find the true URL even if another env has cached it
"--index-url",
"https://download.pytorch.org/whl/cpu",
]
# print(' '.join(cmd))
try:
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
for line in process.stdout:
url_match = re.search(r"Downloading (https://download\.pytorch\.org/[^\s]+\.whl)", line)
if url_match:
pytorch_url = url_match.group(1)
if pytorch_url:
process.terminate() # Terminate the subprocess
break
process.wait() # Wait for the process to finish
except subprocess.CalledProcessError as e:
print(f"Error running pip download: {e}")
# print(pytorch_url)
# sys.exit()
if pytorch_url:
requirements.remove(torch)
requirements = [f"torch @ {pytorch_url}"] + requirements
return requirements
requirements = get_requirements()
# README
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
long_description = re.sub(r"\n!\[.*\]\(.*\)", "", long_description)
# long_description = re.sub(r"\n- \[.*\]\(.*\)", "", long_description)
# Discover packages, plus the website
packages = find_packages(exclude=["benchmark"]) + ["aider.website"]
print("Discovered packages:", packages)
setup(
name="aider-chat",
version=__version__,
packages=packages,
include_package_data=True,
package_data={
"aider": ["queries/*.scm"],
"aider.website": ["**/*.md"],
},
exclude_package_data={"aider.website": exclude_website_pats},
install_requires=requirements,
python_requires=">=3.9,<3.13",
entry_points={
"console_scripts": [
"aider = aider.main:main",
],
},
description="Aider is AI pair programming in your terminal",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/paul-gauthier/aider",
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python",
"Topic :: Software Development",
],
)