-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
104 lines (91 loc) · 3.61 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
import os
from subprocess import run
from setuptools import setup, find_packages
from setuptools.command.install import install
def add_autocompletion():
try:
config_root = os.path.join(os.path.expanduser("~"), ".config", "autoretouch")
os.makedirs(config_root, exist_ok=True)
except Exception as e:
print(f"failed to install autocompletion. Exception was: {str(e)}")
def add_bash():
run(f"cp autoretouch/.autoretouch-complete.sh {config_root}/".split())
bashrc_path = os.path.expanduser("~/.bashrc")
if os.path.isfile(bashrc_path):
string_to_add = "\n\n# autoretouch auto-completion\n. ~/.config/autoretouch/.autoretouch-complete.sh\n\n"
with open(bashrc_path, "r") as f:
bashrc_has_been_added = string_to_add in f.read()
if not bashrc_has_been_added:
os.system(f"echo \"{string_to_add}\" >> {bashrc_path}")
def add_fish():
run(f"cp autoretouch/.autoretouch-complete.fish {config_root}/".split())
fish_completions_path = os.path.expanduser("~/.config/fish/completions")
if os.path.isdir(fish_completions_path):
fish_completion_file_path = os.path.join(fish_completions_path, ".autoretouch-complete.fish")
if not os.path.isfile(fish_completion_file_path):
os.system(f"cp autoretouch/.autoretouch-complete.fish {fish_completion_file_path}")
def add_zsh():
run(f"cp autoretouch/.autoretouch-complete.zsh {config_root}/".split())
zshrc_path = os.path.expanduser("~/.zshrc")
if os.path.isfile(zshrc_path):
string_to_add = "\n\n# autoretouch auto-completion\n. ~/.config/autoretouch/.autoretouch-complete.zsh\n\n"
with open(zshrc_path, "r") as f:
zshrc_has_been_added = string_to_add in f.read()
if not zshrc_has_been_added:
os.system(f"echo \"{string_to_add}\" >> {zshrc_path}")
def add_powershell():
pass
for shell, shell_func in {
"bash": add_bash, "fish": add_fish, "zsh": add_zsh, "powershell": add_powershell
}.items():
try:
print(f"add autocompletion for {shell}")
shell_func()
except Exception as e:
print(f"failed to install autocompletion for {shell}. Exception was: {str(e)}")
class PostInstallCommand(install):
"""Post-installation for installation mode."""
# TODO
# - autocomplete fish, powershell
def run(self):
install.run(self)
add_autocompletion()
with open("README.md", "r") as f:
README = f.read()
setup(
name="autoretouch",
version="0.3.0",
author=[
"Antoine Daurat <[email protected]>",
"Oliver Allweyer <[email protected]>",
"Till Lorentzen <[email protected]>"
],
description="cli and python package to communicate with the autoRetouch API",
long_description=README,
long_description_content_type="text/markdown",
license="BSD Zero",
packages=find_packages(exclude=["test", "assets", "tmp"]),
install_requires=[
"requests",
"click==8.1.3",
"click-log==0.4.0"
],
extra_requires={
"test": [
"assertpy"
],
},
include_package_data=True,
package_data={
"autoretouch": [".autoretouch-complete.zsh", ".autoretouch-complete.bash", ".autoretouch-complete.fish"]
},
entry_points={
"console_scripts": [
"autoretouch = autoretouch.cli.commands:autoretouch_cli",
],
},
cmdclass={
"install": PostInstallCommand,
"develop": PostInstallCommand
},
)