]> git.armaanb.net Git - lightcards.git/blob - setup.py
Don't overwrite existing local config file
[lightcards.git] / setup.py
1 from setuptools import setup
2 import os
3 import shutil
4
5 pwd = os.path.abspath(os.path.dirname(__file__))
6 with open(os.path.join(pwd, "README.md"), encoding="utf-8") as f:
7     long_description = f.read()
8
9
10 def mkdir(dir):
11     try:
12         os.makedirs(dir)
13     except FileExistsError:
14         pass
15
16
17 if os.geteuid() == 0:
18     mkdir("/etc/lightcards/")
19     shutil.copyfile("./config.py", "/etc/lightcards/config.py")
20 else:
21     xdg = os.environ.get("XDG_CONFIG_HOME")
22     xdg_dest = f"{xdg}/lightcards/config.py"
23
24     home = os.path.expanduser("~")
25     home_dest = f"{home}/.config/lightcards/config.py"
26
27     if xdg and not os.path.exists(xdg_dest):
28         mkdir(f"{xdg}/lightcards")
29         shutil.copyfile("./config.py", xdg_dest)
30     elif not os.path.exists(home_dest):
31         mkdir(f"{home}/.config/lightcards")
32         shutil.copyfile("./config.py", home_dest)
33
34
35 setup(
36     name="lightcards",
37     version="0.7.0",
38     description="Terminal flashcards from Markdown",
39     long_description=long_description,
40     long_description_content_type="text/markdown",
41     url="https://sr.ht/~armaan/lightcards",
42     author="Armaan Bhojwani",
43     author_email="me@armaanb.net",
44     license="MIT",
45     packages=["lightcards"],
46     install_requires=["beautifulsoup4", "markdown"],
47     data_files=[
48         ("man/man1", ["man/lightcards.1"]),
49         ("man/man5", ["man/lightcards-config.5"]),
50     ],
51     entry_points={
52         "console_scripts": ["lightcards=lightcards:main"],
53     },
54     classifiers=[
55         "Intended Audience :: Education",
56         "Environment :: Console :: Curses",
57         "License :: OSI Approved :: MIT License",
58         "Topic :: Education",
59     ],
60 )