forked from DMTF/python-redfish-utility
-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathsetup.py
More file actions
116 lines (104 loc) · 3.87 KB
/
Copy pathsetup.py
File metadata and controls
116 lines (104 loc) · 3.87 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
from setuptools import find_packages, setup
import site
import os
import platform
import sys
site_packages = site.getsitepackages()
extras = {}
def set_env_var():
system = platform.system()
bin_path = os.path.dirname(sys.executable)
if system == "Windows":
import winreg
try:
# Open the registry key for the environment variables
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Environment", 0, winreg.KEY_ALL_ACCESS) as reg_key:
try:
current_path, _ = winreg.QueryValueEx(reg_key, "PATH")
reg_type = winreg.REG_SZ
except FileNotFoundError:
current_path = ""
reg_type = winreg.REG_EXPAND_SZ # Default type
if bin_path not in current_path.split(os.pathsep):
updated_path = bin_path
if current_path:
updated_path = bin_path + os.pathsep + current_path
winreg.SetValueEx(reg_key, "PATH", 0, reg_type, updated_path)
except Exception as e:
print(f"Failed to set environment variable: {e}")
elif system in ("Linux", "Darwin"):
try:
# Path to the shell configuration file
shell_config_path = os.path.expanduser("~/.bashrc")
if system == "Darwin":
import sysconfig
shell_config_path = os.path.expanduser("~/.zshrc")
paths = sysconfig.get_paths()
bin_path = paths.get("scripts", "")
# Write to the shell configuration file
with open(shell_config_path, "a+") as file:
file.seek(0)
file_content = file.read()
if bin_path not in file_content:
file.write(f'\nexport PATH="{bin_path}:$PATH"\n')
except Exception as e:
print(f"Failed to set environment variable: {e}")
set_env_var()
setup(
name="ilorest",
version="7.1.0.0",
description="HPE iLORest Tool",
author="Hewlett Packard Enterprise",
author_email="rajeevalochana.kallur@hpe.com",
extras_require=extras,
classifiers=[
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Communications",
],
keywords="Hewlett Packard Enterprise",
url="https://github.com/HewlettPackard/python-redfish-utility",
packages=find_packages(".", exclude=["tests", "docs"]),
package_dir={"": "."},
package_data={
"ilorest.chiflibrary": ["ilorest_chif.dll", "ilorest_chif.so"],
"ilorest.chiflibrary.arm": ["ilorest_chif.so"],
"ilorest.extensions.iLO_COMMANDS.data": ["*.py"],
},
data_files=[("", ["logging_config.json"])],
entry_points={
"console_scripts": [
"ilorest = ilorest.rdmc:ilorestcommand",
],
},
install_requires=[
"urllib3 >= 1.26.2",
"pyaes >= 1.6.1",
"colorama >= 0.4.4",
"jsonpointer >= 2.0",
"six >= 1.15.0",
"ply",
"requests",
"decorator >= 4.4.2",
"jsonpatch >= 1.28",
"jsonpath-rw >= 1.4.0",
'setproctitle >= 1.1.8; platform_system == "Linux"',
"jsondiff >= 1.2.0",
"tabulate >= 0.8.7",
"prompt_toolkit",
"certifi >= 2020.12.5",
'pywin32; platform_system == "Windows"',
"wcwidth >= 0.2.5",
"pyudev",
"future",
'enum; python_version <= "2.7.19"',
'futures; python_version <= "2.7.19"',
"python-ilorest-library >= 7.1.0.0",
],
)