-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
executable file
·55 lines (43 loc) · 1.35 KB
/
setup.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from setuptools import setup, find_packages
import os
from configparser import ConfigParser
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
PROJECT_INI = os.path.join(PROJECT_DIR, "project.ini")
config = ConfigParser()
config.read(PROJECT_INI)
def get_config(opt):
return config.get("project", opt)
NAME = get_config('name')
DESCRIPTION = get_config('description')
URL = get_config('url')
AUTHOR = 'nonamenix'
AUTHOR_EMAIL = '[email protected]'
README_TXT = 'README.txt'
README = 'README.rst'
LONG_DESCRIPTION = open(os.path.join(PROJECT_DIR, README), encoding='utf8').read()
REQUIREMENTS_FILE = 'requirements.txt'
REQUIREMENTS = open(os.path.join(PROJECT_DIR, REQUIREMENTS_FILE)).readlines()
VERSION = get_config('version')
DEV_VERSION = os.environ.get('DEV_VERSION')
if DEV_VERSION:
VERSION = '{}.dev{}'.format(VERSION, DEV_VERSION)
config.set("project", 'version', VERSION)
with open(PROJECT_INI, 'w') as f:
config.write(f)
# create a README.txt file from .rst
with open(README_TXT, 'wb') as f:
f.write(LONG_DESCRIPTION.encode())
setup(
name=NAME,
version=VERSION,
description=DESCRIPTION,
long_description='',
author=AUTHOR,
author_email=AUTHOR_EMAIL,
url=URL,
include_package_data=True,
packages=find_packages(),
install_requires=REQUIREMENTS,
)
# delete README.txt
os.remove(README_TXT)