-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathsetup.py
More file actions
90 lines (76 loc) · 2.88 KB
/
setup.py
File metadata and controls
90 lines (76 loc) · 2.88 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
import os
import re
import subprocess
import sys
from pathlib import Path
from setuptools import setup, find_packages
from setuptools import Command
def read_file(path: str) -> str:
here = Path(__file__).parent
try:
return (here / path).read_text(encoding="utf-8")
except FileNotFoundError:
return ""
def read_requirements(filename: str = "requirements.txt"):
content = read_file(filename)
lines = [l.strip() for l in content.splitlines()]
return [l for l in lines if l and not l.startswith("#")] if content else []
def read_version():
init_py = read_file("cais/__init__.py")
m = re.search(r'__version__\s*=\s*"([^"]+)"', init_py)
return m.group(1) if m else "0.0.0"
class VenvCommand(Command):
description = "Create a local .venv and install requirements (optional helper)."
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def run(self):
venv_dir = Path(".venv")
python = sys.executable
if not venv_dir.exists():
subprocess.check_call([python, "-m", "venv", str(venv_dir)])
pip_bin = venv_dir / ("Scripts/pip.exe" if os.name == "nt" else "bin/pip")
# Upgrade pip and install requirements if present
subprocess.check_call([str(pip_bin), "install", "--upgrade", "pip"])
reqs = Path("requirements.txt")
if reqs.exists():
subprocess.check_call([str(pip_bin), "install", "-r", str(reqs)])
# Editable install of this package
subprocess.check_call([str(pip_bin), "install", "-e", "."])
print("Virtual environment setup complete at .venv")
setup(
name="causal-agent",
version=read_version(),
author="Vishal Verma",
author_email="[email protected]",
description="A library for automated causal inference",
long_description=read_file("README_PYPI.md") or "A library for automated causal inference",
long_description_content_type="text/markdown",
url="https://github.com/causalNLP/causal-agent",
packages=find_packages(exclude=["tests", "tests.*", "data_generation*", "replication_codes*"]),
include_package_data=True,
zip_safe=False,
python_requires=">=3.10",
install_requires=read_requirements(),
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Information Analysis",
],
entry_points={
"console_scripts": [
"cais=cais.cli:main",
]
},
cmdclass={
"venv": VenvCommand,
},
)