-
Notifications
You must be signed in to change notification settings - Fork 15
/
setup.py
118 lines (101 loc) · 3.96 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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
from __future__ import absolute_import
from __future__ import print_function
import codecs
from glob import glob
from os.path import basename
from os.path import dirname
from os.path import join
from os.path import splitext
from setuptools import Command
from setuptools import find_packages
from setuptools import setup
def read(filename):
"""
Return the filename unicode text content stripping some reST lines and
updating some defaults"""
lines = [l for l in codecs.open(join(dirname(__file__), filename), encoding='utf8')
if not l.strip().startswith(('.. ', ':',))]
return u''.join(lines)
class UpdatePslCommand(Command):
"""
A setuptools command to update the vendored public suffix list to the latest.
"""
user_options = []
def initialize_options(self): pass
def finalize_options(self): pass
def run(self):
"""
Update the vendored public suffix list to the latest list from
publicsuffix.org saved in the src directory of this package.
Also create an ABOUT file with download info including the download UTC
date/time as the version (see http://aboutcode.org)
"""
from contextlib import closing
from datetime import datetime
import os
import sys
import requests
PSL_URL = 'https://publicsuffix.org/list/public_suffix_list.dat'
BASE_DIR = os.path.join(os.path.dirname(__file__), 'src', 'publicsuffix2')
PSL_FILE = os.path.join(BASE_DIR, 'public_suffix_list.dat')
ABOUT_PSL_FILE = os.path.join(BASE_DIR, 'public_suffix_list.ABOUT')
ABOUT_TEMPLATE = '''
about_resource: public_suffix_list.dat
name: Public Suffix List
version: %(version)s
download_url: %(PSL_URL)s
home_url: https://publicsuffix.org/
owner: Mozilla
copyright: Copyright (c) Mozilla and others
license: mpl-2.0
license_text_file: mpl-2.0.LICENSE
'''
# current date and time as an ISO time stamp string
version = datetime.isoformat(datetime.utcnow()).partition('.')[0]
glocals = locals()
print('Fetching latest list from: %(PSL_URL)s on: %(version)s' % glocals)
fetched= requests.get(PSL_URL).content
with open(PSL_FILE, 'wb') as pslout:
pslout.write(fetched)
mode = 'wb' if sys.version_info[0] == 2 else 'w'
with open(ABOUT_PSL_FILE, mode) as about:
about.write(ABOUT_TEMPLATE % glocals)
print('Saved updated %(PSL_FILE)s and %(ABOUT_PSL_FILE)s' % glocals)
setup(
name='publicsuffix2',
version='2.20200127',
license='MIT and MPL-2.0',
description='Get a public suffix for a domain name using the Public Suffix '
'List. Forked from and using the same API as the publicsuffix package.',
long_description_content_type = 'text/x-rst',
long_description='%s\n%s' % (read('README.rst'), read('CHANGELOG.rst')),
author='nexB Inc., Tomaz Solc, David Wilson and others.',
author_email='info@nexb.com',
url='https://github.com/nexb/python-publicsuffix2',
packages=find_packages('src'),
package_dir={'': 'src'},
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')],
include_package_data=True,
zip_safe=False,
setup_requires = [
'requests >= 2.7.0',
],
classifiers=[
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Internet :: Name Service (DNS)',
'Topic :: Utilities',
'Development Status :: 5 - Production/Stable',
],
keywords=[
'domain', 'public suffix', 'suffix', 'dns', 'tld', 'sld', 'psl', 'idna',
],
# run this to update the Public Suffix list data "python setup.py update_psl"
cmdclass={'update_psl': UpdatePslCommand},
)