X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=setup.py;h=639de5353195fb4c91d698192e3ff31455684537;hb=967023aae085b303fa35a3c9572311b953ae8ae9;hp=2373f3f82dcdcdbb2cc99b0f16cf33a22a1848b3;hpb=dd109cb4a1b49f920e36e5732417c4a3d5582821;p=lightcards.git diff --git a/setup.py b/setup.py index 2373f3f..639de53 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,37 @@ 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") + xdg_dest = f"{xdg}/lightcards/config.py" + + home = os.path.expanduser("~") + home_dest = f"{home}/.config/lightcards/config.py" + + if xdg and not os.path.exists(xdg_dest): + mkdir(f"{xdg}/lightcards") + shutil.copyfile("./config.py", xdg_dest) + elif not os.path.exists(home_dest): + mkdir(f"{home}/.config/lightcards") + shutil.copyfile("./config.py", home_dest) + + setup( name="lightcards", version="0.7.0", @@ -19,15 +46,7 @@ setup( install_requires=["beautifulsoup4", "markdown"], data_files=[ ("man/man1", ["man/lightcards.1"]), - ( - "share/doc/lightcards/", - [ - "./config.py", - "./README.md", - "man/lightcards.1.md", - "./LICENSE", - ], - ), + ("man/man5", ["man/lightcards-config.5"]), ], entry_points={ "console_scripts": ["lightcards=lightcards:main"],