|
1 | | -from . import tranci |
| 1 | +import os |
| 2 | +import shutil |
| 3 | +import sys |
2 | 4 | from setuptools import setup, find_packages |
3 | | -from pathlib import Path |
| 5 | + |
| 6 | +version = None |
| 7 | + |
| 8 | +with open("tranci/__init__.py", "r") as f: |
| 9 | + for line in f.readlines(): |
| 10 | + if line.startswith("__version__"): |
| 11 | + version = line.split("=", 1)[1].strip().replace('"', "") |
| 12 | + |
| 13 | +if version is None: |
| 14 | + print("where's the version?!?!??!!") |
| 15 | + sys.exit(1) |
| 16 | + |
| 17 | +print(f"version {version}") |
| 18 | + |
| 19 | +with open("README.md", "r") as f: |
| 20 | + long_description = f.read() |
| 21 | + |
| 22 | +current_dir_mess = os.listdir(".") |
| 23 | + |
| 24 | +if any( |
| 25 | + ( |
| 26 | + "dist" in current_dir_mess, |
| 27 | + "tranci.egg-info" in current_dir_mess, |
| 28 | + "build" in current_dir_mess, |
| 29 | + ) |
| 30 | +): |
| 31 | + print("cleaning up your previous mess...") |
| 32 | + |
| 33 | + shutil.rmtree("dist", ignore_errors=True) |
| 34 | + shutil.rmtree("tranci.egg-info", ignore_errors=True) |
| 35 | + shutil.rmtree("build", ignore_errors=True) |
| 36 | + |
| 37 | + print("done!") |
4 | 38 |
|
5 | 39 | setup( |
6 | 40 | name="tranci", |
7 | | - version=tranci.__version__, |
| 41 | + version=version, |
8 | 42 | description="Tranci: a no-dependencies, lightweight, easy-to-use ANSI library", |
9 | | - long_description=(Path(__file__).parent / "README.md").read_text(encoding="utf-8"), |
| 43 | + long_description=long_description, |
10 | 44 | long_description_content_type="text/markdown", |
11 | 45 | author="Butterroach", |
12 | 46 | |
|
0 commit comments