py3-validate-email/setup.py

72 lines
2.4 KiB
Python
Raw Normal View History

import sys
from distutils import log
2020-04-11 23:32:02 +02:00
from pathlib import Path
2019-03-02 02:17:12 +01:00
from setuptools import find_packages, setup
2020-04-12 16:40:04 +02:00
from setuptools.command.build_py import build_py
2019-11-24 18:13:02 +01:00
from setuptools.command.develop import develop
2019-03-02 00:59:23 +01:00
2020-04-11 23:32:02 +02:00
def run_initial_updater(path: Path):
2020-04-12 16:40:04 +02:00
'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
2020-04-12 16:40:04 +02:00
class DevelopCommand(develop):
"""
Adapted version of the 'develop' command.
2019-03-02 00:59:23 +01:00
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)
2020-04-12 16:40:04 +02:00
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.
"""
2020-04-12 16:40:04 +02:00
def run(self):
super().run()
if not self.dry_run:
run_initial_updater(Path(self.build_lib))
2020-04-12 16:40:04 +02:00
2018-05-31 13:13:28 +02:00
setup(
2019-03-01 23:29:01 +01:00
name='py3-validate-email',
2021-03-14 14:27:13 +01:00
version='1.0.0',
2019-03-02 02:17:12 +01:00
packages=find_packages(exclude=['tests']),
2021-03-14 14:06:46 +01:00
install_requires=['dnspython~=2.0', 'idna~=3.0', 'filelock~=3.0'],
2019-03-01 23:29:01 +01:00
author='László Károlyi',
2019-03-01 20:37:52 +01:00
author_email='laszlo@karolyi.hu',
2019-11-24 18:13:02 +01:00
description=(
'Email validator with regex, blacklisted domains and SMTP checking.'),
long_description=Path(__file__).parent.joinpath('README.rst').read_text(),
2019-03-02 03:26:58 +01:00
long_description_content_type='text/x-rst',
2019-03-01 20:37:52 +01:00
keywords='email validation verification mx verify',
2019-03-01 23:29:01 +01:00
url='http://github.com/karolyi/py3-validate-email',
cmdclass=dict(build_py=BuildPyCommand, develop=DevelopCommand),
2021-02-11 17:49:29 +01:00
license='LGPL')