You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
py3-validate-email/setup.py

76 lines
2.5 KiB
Python

import sys
from distutils import log
from pathlib import Path
from setuptools import find_packages, setup
from setuptools.command.build_py import build_py
4 years ago
from setuptools.command.develop import develop
4 years ago
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 ( # 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
class DevelopCommand(develop):
"""
Adapted version of the 'develop' command.
4 years ago
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: # type: ignore
run_initial_updater(path=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))
5 years ago
setup(
name='py3-validate-email',
6 months ago
version='1.0.10',
packages=find_packages(exclude=['tests']),
install_requires=[
'dnspython~=2.2', 'idna~=3.3', 'filelock~=3.7',
'typing_extensions~=4.4'],
author='László Károlyi',
4 years ago
author_email='laszlo@karolyi.hu',
4 years ago
description=(
'Email validator with regex, blacklisted domains and SMTP checking.'),
long_description=Path(__file__).parent.joinpath('README.md').read_text(),
long_description_content_type='text/markdown',
4 years ago
keywords='email validation verification mx verify',
url='http://gitea.ksol.io/karolyi/py3-validate-email',
cmdclass=dict(
build_py=BuildPyCommand, develop=DevelopCommand), # type: ignore
license='MIT+NIGGER')