-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
91 lines (75 loc) · 2.67 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
# -*- coding: utf-8 -*-
"""Python packaging."""
from os.path import abspath
from os.path import dirname
from os.path import join
from setuptools import setup
def read_relative_file(filename):
"""Returns contents of the given file, which path is supposed relative
to this module."""
with open(join(dirname(abspath(__file__)), filename)) as f:
return f.read()
def packages(project_name):
"""Return list of packages distributed by project based on its name.
>>> packages('foo')
['foo']
>>> packages('foo.bar')
['foo', 'foo.bar']
>>> packages('foo.bar.baz')
['foo', 'foo.bar', 'foo.bar.baz']
>>> packages('FooBar')
['foobar']
Implements "Use a single name" convention described in :pep:`423`.
"""
name = str(project_name).lower()
if '.' in name: # Using namespace packages.
parts = name.split('.')
return ['.'.join(parts[0:i]) for i in range(1, len(parts) + 1)]
else: # One root package or module.
return [name]
def namespace_packages(project_name):
"""Return list of namespace packages distributed in this project, based on
project name.
>>> namespace_packages('foo')
[]
>>> namespace_packages('foo.bar')
['foo']
>>> namespace_packages('foo.bar.baz')
['foo', 'foo.bar']
>>> namespace_packages('Foo.BaR.BAZ') == namespace_packages('foo.bar.baz')
True
Implements "Use a single name" convention described in :pep:`423`.
"""
package_list = packages(project_name)
package_list.pop() # Ignore last element.
# Remaining packages are supposed to be namespace packages.
return package_list
name = 'django-esutils'
version = read_relative_file('VERSION').strip()
readme = read_relative_file('README.rst')
if __name__ == '__main__': # ``import setup`` doesn't trigger setup().
setup(name=name,
version=version,
description="""Django Esutils.""",
long_description=readme,
classifiers=[
'Development Status :: 3 - Alpha',
'Programming Language :: Python',
'Framework :: Django',
'License :: OSI Approved :: MIT License',
],
keywords='',
author='Novapost',
author_email='florent.pigout@novapost.fr',
url='https://github.com/novapost/%s' % name,
license='MIT License',
packages=packages(name.replace('-', '_')),
namespace_packages=namespace_packages(name),
include_package_data=True,
zip_safe=False,
install_requires=[
'django',
'djangorestframework',
'elasticutils'
],
dependency_links=[])