py3-validate-email/setup.py

76 lines
2.5 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:
2021-11-16 23:38:37 +01:00
from updater import ( # type: ignore
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()
2021-11-16 23:38:37 +01:00
if not self.dry_run: # type: ignore
run_initial_updater(path=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',
2022-10-29 12:03:49 +02:00
version='1.0.8',
2019-03-02 02:17:12 +01:00
packages=find_packages(exclude=['tests']),
2022-10-29 12:03:49 +02:00
install_requires=[
'dnspython~=2.2', 'idna~=3.3', 'filelock~=3.7',
'typing_extensions~=4.4'],
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.'),
2021-11-16 23:38:37 +01:00
long_description=Path(__file__).parent.joinpath('README.md').read_text(),
long_description_content_type='text/markdown',
2019-03-01 20:37:52 +01:00
keywords='email validation verification mx verify',
2021-11-16 23:38:37 +01:00
url='http://gitea.ksol.io/karolyi/py3-validate-email',
cmdclass=dict(
build_py=BuildPyCommand, develop=DevelopCommand), # type: ignore
2021-02-11 17:49:29 +01:00
license='LGPL')