95 lines
1.6 KiB
Python
95 lines
1.6 KiB
Python
import subprocess, sys
|
|
|
|
|
|
submodules = [
|
|
'http_server',
|
|
'requests_client',
|
|
'sql',
|
|
'template',
|
|
'tinydb'
|
|
]
|
|
|
|
submodule_names = [
|
|
'IzzyLib-Base',
|
|
'IzzyLib-Database',
|
|
'IzzyLib-HTTP-Server',
|
|
'IzzyLib-Requests-Client',
|
|
'IzzyLib-SQL',
|
|
'IzzyLib-Templates',
|
|
'IzzyLib-TinyDB',
|
|
]
|
|
|
|
|
|
def main(*args):
|
|
if not len(args):
|
|
print('Missing command')
|
|
return cmd_help()
|
|
|
|
command = args[0]
|
|
|
|
if command not in ['install', 'uninstall', 'dev']:
|
|
print('Invalid command:', command)
|
|
return cmd_help()
|
|
|
|
if command == 'uninstall':
|
|
subprocess.run([sys.executable, '-m', 'pip', 'uninstall', '-y', *submodule_names])
|
|
return
|
|
|
|
submodule_args = []
|
|
|
|
if len(args) > 1:
|
|
if args[1] == 'all':
|
|
submodule_args = [f'./{module}' for module in modinstall]
|
|
|
|
else:
|
|
submodule_args = [f'./{module}' for module in args[1:]]
|
|
|
|
for mod in submodules:
|
|
if mod not in submodules:
|
|
print('Invalid submodule:', mod)
|
|
return cmd_help()
|
|
|
|
options = ['-m', 'pip', 'install', './base', *submodule_args]
|
|
|
|
if command == 'dev':
|
|
options.insert(3, '--use-feature=in-tree-build')
|
|
|
|
print(options)
|
|
|
|
subprocess.run([sys.executable, *options])
|
|
|
|
|
|
def cmd_help(*args):
|
|
text = f'''IzzyLib manager
|
|
|
|
Commands:
|
|
install [submodules: space-separated list]:
|
|
Install IzzyLib as well as any sub-modules if any are required
|
|
|
|
uninstall [submodules]
|
|
Uninstall IzzyLib and any installed submodules
|
|
|
|
Valid Submodules:
|
|
{', '.join(submodules)}
|
|
'''
|
|
|
|
print(text)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
args = sys.argv[1:]
|
|
|
|
except IndexError:
|
|
args = []
|
|
|
|
try:
|
|
if not args:
|
|
cmd_help()
|
|
|
|
else:
|
|
main(*args)
|
|
|
|
except KeyboardInterrupt:
|
|
print('Bye! UvU')
|