-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
103 lines (90 loc) · 3.52 KB
/
setup.py
File metadata and controls
103 lines (90 loc) · 3.52 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
# Ulto - Imperative Reversible Programming Language
#
# setup.py
#
# Aman Thapa Magar <at719@sussex.ac.uk>
import os
import platform
import sys
from pathlib import Path
from setuptools import setup, find_packages
class Setup:
def __init__(self):
print('+------------------------------------------------------+')
print('| Installing Ulto - v1.0.0 |')
print('| Developed By Aman Thapa Magar |')
print('+------------------------------------------------------+')
print("| Operating System : " + platform.system())
print("| Release : " + platform.release())
print("| Ulto Version : v1.0.0 |")
def setup_link(self):
""" Setup symbolic links or shortcuts based on the OS """
if platform.system() == "Linux":
print('| Unix-like install route |')
self.unix_install_route()
elif platform.system() == "Windows":
print('| Windows install route |')
self.windows_install_route()
else:
print('| Unsupported OS |')
print("+------------------------------------------------------+")
def unix_install_route(self):
""" Unix-like Install Route """
bin_path = Path('/usr/local/bin/ulto')
target_path = Path(__file__).resolve().parent / 'src' / 'main.py'
if not bin_path.exists():
bin_path.symlink_to(target_path)
print(f"| Symbolic link created at {bin_path} -> {target_path}")
else:
print("| Symbolic link already exists at /usr/local/bin/ulto")
def windows_install_route(self):
""" Windows Install Route """
try:
import win32com.client
except ImportError:
print("pywin32 is required on Windows. Please install it using 'pip install pywin32'.")
return
shell = win32com.client.Dispatch('WScript.Shell')
script_path = Path(__file__).resolve().parent / 'src' / 'main.py'
link_path = Path(os.environ['APPDATA']) / 'Microsoft' / 'Windows' / 'Start Menu' / 'Programs' / 'Ultolink.lnk'
if not link_path.exists():
shortcut = shell.CreateShortCut(str(link_path))
shortcut.Targetpath = sys.executable
shortcut.Arguments = f'"{script_path}"'
shortcut.WorkingDirectory = str(script_path.parent)
shortcut.IconLocation = sys.executable
shortcut.save()
print(f"| Shortcut created at {link_path}")
else:
print(f"| Shortcut already exists at {link_path}")
if __name__ == "__main__":
installer = Setup()
installer.setup_link()
setup(
name='ulto',
version='1.0.0',
author='Aman Thapa Magar',
author_email='at719@sussex.ac.uk',
description='Ulto - Imperative Reversible Programming Language',
packages=find_packages(),
install_requires=[
'sortedcontainers',
'pywin32; platform_system=="Windows"',
],
entry_points={
'console_scripts': [
'ulto=src.main:main',
],
},
classifiers=[
'Development Status :: 1 - Alpha',
'Programming Language :: Ulto :: 1',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
],
python_requires='>=3.6',
package_data={
'src': ['operations.dll', 'liboperations.so'],
},
include_package_data=True,
)