summaryrefslogtreecommitdiff
path: root/install.py
blob: fc27bc098ebe816824b07c547c529462f226f44c (plain)
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
import sys
import shutil
import ply, ply.lex, ply.yacc
from pathlib import Path

TARGET = "ply"

def main(argv):
    user = False
    if len(argv) > 1:
        if argv[1] != '--user':
            raise SystemExit('usage: python install.py [--user]')
        else:
            user = True
    site_packages = [p for p in sys.path if p.endswith('site-packages')]
    path = Path(site_packages[0] if user else site_packages[-1]) / TARGET
    if path.exists():
        shutil.rmtree(path)
    shutil.copytree(TARGET, path)
    print(f'{TARGET} installed at {path}')

if __name__ == '__main__':
    main(sys.argv)