forked from syrusakbary/validate_email
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
71 lines (58 loc) · 2.36 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
import sys
from distutils import log
from pathlib import Path
from setuptools import find_packages, setup
from setuptools.command.build_py import build_py
from setuptools.command.develop import develop
def run_initial_updater(path: Path):
'Download an initial blacklist.txt on install time.'
# Only import the updater module to avoid requiring all the dependencies
# and auto-running the updater.
sys.path.append(str(path.joinpath('validate_email')))
orig_dont_write_bytecode = sys.dont_write_bytecode
sys.dont_write_bytecode = True
try:
from updater import BLACKLIST_FILEPATH_INSTALLED, BlacklistUpdater
log.info(f'downloading blacklist to {BLACKLIST_FILEPATH_INSTALLED}')
BlacklistUpdater()._install()
finally:
sys.path = sys.path[:-1]
sys.dont_write_bytecode = orig_dont_write_bytecode
class DevelopCommand(develop):
"""
Adapted version of the 'develop' command.
After finishing the usual build run, download the blacklist and
store it into the source directory, because that is from where the
library will run in a developer install.
"""
def run(self):
super().run()
if not self.dry_run:
run_initial_updater(Path(__file__).parent)
class BuildPyCommand(build_py):
"""
Adapted version of the 'build_py' command.
After finishing the usual build run, download the blacklist and
store it into the build directory. A subsequent 'install' step will
copy the full contents of the build directory to the install
target, thus including the blacklist.
"""
def run(self):
super().run()
if not self.dry_run:
run_initial_updater(Path(self.build_lib))
setup(
name='py3-validate-email',
version='0.2.15',
packages=find_packages(exclude=['tests']),
install_requires=['dnspython~=2.0', 'idna~=2.10', 'filelock~=3.0'],
author='László Károlyi',
author_email='laszlo@karolyi.hu',
description=(
'Email validator with regex, blacklisted domains and SMTP checking.'),
long_description=Path(__file__).parent.joinpath('README.rst').read_text(),
long_description_content_type='text/x-rst',
keywords='email validation verification mx verify',
url='http://github.com/karolyi/py3-validate-email',
cmdclass=dict(build_py=BuildPyCommand, develop=DevelopCommand),
license='LGPL')