forked from netlandish/django-amp-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
92 lines (78 loc) · 2.79 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
from distutils.core import setup
PROJECT_NAME = 'amp_tools'
ROOT = os.path.abspath(os.path.dirname(__file__))
VENV = os.path.join(ROOT, '.venv')
VENV_LINK = os.path.join(VENV, 'local')
install_requires = [
'django>=1.11.0',
]
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)
data_files = []
for dirpath, dirnames, filenames in os.walk(PROJECT_NAME):
for i, dirname in enumerate(dirnames):
if dirname.startswith('.'):
del dirnames[i]
if '__init__.py' in filenames:
continue
elif filenames:
for f in filenames:
data_files.append(os.path.join(
dirpath[len(PROJECT_NAME) + 1:], f))
def read(filename):
return open(os.path.join(ROOT, filename)).read()
class VenvLinkDeleted(object):
restore_link = False
def __enter__(self):
"""Remove the link."""
if os.path.islink(VENV_LINK):
os.remove(VENV_LINK)
self.restore_link = True
def __exit__(self, exc_type, exc_val, exc_tb):
"""Restore the link."""
if self.restore_link:
os.symlink(VENV, VENV_LINK)
with VenvLinkDeleted():
setup(
name='django-amp-tools',
version=get_version('amp_tools'),
packages=[
PROJECT_NAME,
'{0}.templatetags'.format(PROJECT_NAME),
],
package_data={PROJECT_NAME: data_files},
include_package_data=True,
license='MIT License',
description='Accelerated mobile pages (AMP) in django.',
keywords='django AMP accelerated',
long_description=read('README.rst'),
url='http://github.com/shtalinberg/django-amp-tools',
author='Oleksandr Shtalinberg',
author_email='O.Shtalinberg@gmail.com',
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: Web Environment',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License', # example license
'Operating System :: OS Independent',
'Programming Language :: Python',
# Replace these appropriately if you are stuck on Python 2.
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.6',
'Topic :: Internet :: WWW/HTTP',
'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
],
install_requires=install_requires,
zip_safe=False,
)