Debian Codegraph @

setup.py

raw symbols SCIP
1 #!/usr/bin/env python3
2
3 from setuptools import setup
4 import re
5 import os
6 import sys
7
8
9 name = 'django-menu-generator-ng'
10 package = 'menu_generator'
11 description = "A straightforward menu generator for Django"
12 url = 'https://edugit.org/AlekSIS/libs/django-menu-generator-ng'
13 author = 'The AlekSIS Team'
14 author_email = '[email protected]'
15 keywords = "django navigation menu generator"
16 license = 'MIT'
17 install_requires = []
18 classifiers = [
19 'Development Status :: 5 - Production/Stable',
20 'Environment :: Web Environment',
21 'Intended Audience :: Developers',
22 'License :: OSI Approved :: MIT License',
23 'Operating System :: OS Independent',
24 'Programming Language :: Python',
25 "Programming Language :: Python :: 3",
26 "Framework :: Django",
27 'Topic :: Utilities'
28 ]
29
30
31 def get_version(package):
32 """
33 Return package version as listed in `__version__` in `init.py`.
34 """
35 init_py = open(os.path.join(package, '__init__.py')).read()
36 return re.search("^__version__ = ['\"]([^'\"]+)['\"]", init_py, re.MULTILINE).group(1)
37
38
39 def get_packages(package):
40 """
41 Return root package and all sub-packages.
42 """
43 return [dirpath
44 for dirpath, dirnames, filenames in os.walk(package)
45 if os.path.exists(os.path.join(dirpath, '__init__.py'))]
46
47
48 def get_package_data(package):
49 """
50 Return all files under the root package, that are not in a
51 package themselves.
52 """
53 walk = [(dirpath.replace(package + os.sep, '', 1), filenames)
54 for dirpath, dirnames, filenames in os.walk(package)
55 if not os.path.exists(os.path.join(dirpath, '__init__.py'))]
56
57 filepaths = []
58 for base, filenames in walk:
59 filepaths.extend([os.path.join(base, filename)
60 for filename in filenames])
61 return {package: filepaths}
62
63
64 if sys.argv[-1] == 'publish':
65 os.system("python setup.py sdist upload")
66 args = {'version': get_version(package)}
67 print("You probably want to also tag the version now:")
68 print(" git tag -a %(version)s -m 'version %(version)s' && git push --tags" % args)
69 sys.exit()
70
71
72 setup(
73 name=name,
74 version=get_version(package),
75 url=url,
76 license=license,
77 description=description,
78 author=author,
79 author_email=author_email,
80 packages=get_packages(package),
81 package_data=get_package_data(package),
82 install_requires=install_requires,
83 classifiers=classifiers,
84 )