-
Notifications
You must be signed in to change notification settings - Fork 39
/
setup.py
125 lines (104 loc) · 3.56 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# -*- coding: utf-8 -*-
import os
import codecs
import re
import sys
import shutil
from setuptools import setup
from pip._internal.req import parse_requirements
PACKAGE = "business_logic"
NAME = "django-business-logic"
DESCRIPTION = "Visual DSL framework for django"
AUTHOR = "Dmitry Kuksinsky"
AUTHOR_EMAIL = "[email protected]"
URL = "https://github.com/dgk/django-business-logic"
def get_version(package):
"""
Return package version as listed in `__version__` in `init.py`.
"""
init_py = open(os.path.join(package, '__init__.py')).read()
return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
version = get_version(PACKAGE)
def get_packages(package):
"""
Return root package and all sub-packages.
"""
return [
dirpath for dirpath, dirnames, filenames in os.walk(package)
if os.path.exists(os.path.join(dirpath, '__init__.py'))
]
def get_package_data(package):
"""
Return all files under the root package, that are not in a
package themselves.
"""
walk = [(dirpath.replace(package + os.sep, '', 1), filenames)
for dirpath, dirnames, filenames in os.walk(package)
if not os.path.exists(os.path.join(dirpath, '__init__.py'))]
filepaths = []
for base, filenames in walk:
filepaths.extend([os.path.join(base, filename) for filename in filenames])
return {package: filepaths}
def abs_path(*parts):
return os.path.join(os.path.dirname(__file__), *parts)
def clean():
for d in ('dist', 'build', '{}.egg-info'.format(NAME.replace('-', '_'))):
if os.path.exists(d):
shutil.rmtree(d)
if sys.argv[-1] == 'publish':
clean()
os.system("python setup.py sdist bdist_wheel") and sys.exit(1)
os.system("twine upload dist/*") and sys.exit(1)
print("You probably want to also tag the version now:")
print(" git tag -a %s -m 'version %s'" % (version, version))
print(" git push --tags")
sys.exit()
setup(
name=NAME,
version=get_version(PACKAGE),
description=DESCRIPTION,
long_description=codecs.open(abs_path('README.rst'), encoding='utf-8').read(),
author=AUTHOR,
author_email=AUTHOR_EMAIL,
url=URL,
download_url='{}/archive/{}.tar.gz'.format(URL, version),
packages=get_packages(PACKAGE),
package_data={
PACKAGE: [
'locale/*/LC_MESSAGES/django.[mp]o',
'static/business_logic/*.html',
'static/business_logic/*.js',
'static/business_logic/*.map',
'static/business_logic/blockly/*',
'static/business_logic/src/assets/fonts/*',
]
},
license='MIT',
keywords=[
'django',
],
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
'Framework :: Django',
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
],
zip_safe=False,
install_requires=[
x.requirement
for x in parse_requirements(abs_path('requirements.txt'), session=False)
],
)