X-Git-Url: https://git.armaanb.net/?p=lightcards.git;a=blobdiff_plain;f=setup.py;fp=setup.py;h=939a7218a215c98921d608bc8cc4da21aed0b3fc;hp=d028ea7ae9cd12c718ae04c245fd9f7444458228;hb=686515f147fb81974eb96246e9ceedf8b2d471ae;hpb=ea55d7a18ee925988e2d71b92cfb4b2f3bfcfedc diff --git a/setup.py b/setup.py index d028ea7..939a721 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,34 @@ from setuptools import setup -from os import path +import os +import shutil -pwd = path.abspath(path.dirname(__file__)) -with open(path.join(pwd, "README.md"), encoding="utf-8") as f: +pwd = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(pwd, "README.md"), encoding="utf-8") as f: long_description = f.read() + +def mkdir(dir): + try: + os.makedirs(dir) + except FileExistsError: + pass + + +if os.geteuid() == 0: + mkdir("/etc/lightcards/") + shutil.copyfile("./config.py", "/etc/lightcards/config.py") +else: + xdg = os.environ.get("XDG_CONFIG_HOME") + home = os.path.expanduser("~") + + if xdg: + mkdir(f"{xdg}/lightcards") + shutil.copyfile("./config.py", f"{xdg}/lightcards/config.py") + else: + mkdir(f"{home}/.config/lightcards") + shutil.copyfile("./config.py", f"{home}/.config/lightcards/config.py") + + setup( name="lightcards", version="0.7.0", @@ -20,16 +44,6 @@ setup( data_files=[ ("man/man1", ["man/lightcards.1"]), ("man/man5", ["man/lightcards-config.5"]), - ( - "share/doc/lightcards/", - [ - "./config.py", - "./README.md", - "man/lightcards.1.md", - "man/lightcards-config.5.md", - "./LICENSE", - ], - ), ], entry_points={ "console_scripts": ["lightcards=lightcards:main"],