2020-04-11 23:32:02 +02:00
|
|
|
from pathlib import Path
|
2020-04-12 13:57:10 +02:00
|
|
|
from shutil import move, rmtree
|
2020-04-11 23:32:02 +02:00
|
|
|
from subprocess import check_call
|
2020-04-12 13:57:10 +02:00
|
|
|
from tempfile import mkdtemp
|
2020-04-11 23:32:02 +02:00
|
|
|
|
2019-03-02 02:17:12 +01:00
|
|
|
from setuptools import find_packages, setup
|
2019-11-24 18:13:02 +01:00
|
|
|
from setuptools.command.develop import develop
|
|
|
|
from setuptools.command.install import install
|
2020-04-12 13:57:10 +02:00
|
|
|
from setuptools.command.sdist import sdist
|
2019-03-02 00:59:23 +01:00
|
|
|
|
2020-04-11 23:32:02 +02:00
|
|
|
try:
|
2020-04-12 09:26:13 +02:00
|
|
|
# OSX Homebrew fix: https://stackoverflow.com/a/53190037/1067833
|
2020-04-11 23:32:02 +02:00
|
|
|
from sys import _base_executable as executable
|
|
|
|
except ImportError:
|
|
|
|
from sys import executable
|
|
|
|
|
|
|
|
_DEPENDENCIES = ['dnspython>=1.16.0', 'idna>=2.8', 'filelock>=3.0.12']
|
|
|
|
with open(Path(__file__).parent.joinpath('README.rst')) as fd:
|
|
|
|
_LONG_DESC = fd.read()
|
|
|
|
|
2019-03-02 00:59:23 +01:00
|
|
|
|
2020-04-12 13:57:10 +02:00
|
|
|
class InstallCommand(install):
|
|
|
|
'Install command.'
|
2019-11-24 18:13:02 +01:00
|
|
|
|
|
|
|
def run(self):
|
|
|
|
if self.dry_run:
|
|
|
|
return super().run()
|
2020-04-11 23:32:02 +02:00
|
|
|
# Install dependencies so the initial update can run
|
|
|
|
check_call([executable, '-m', 'pip', 'install'] + _DEPENDENCIES)
|
2020-04-11 14:21:52 +02:00
|
|
|
# The updater will walk code stack frames and see if this
|
|
|
|
# variable is set in locals() to determine if it is run from the
|
|
|
|
# setup, in which case it won't autoupdate.
|
|
|
|
_IS_VALIDATEEMAIL_SETUP = True
|
2020-04-12 14:42:20 +02:00
|
|
|
from validate_email.updater import BlacklistUpdater, LIB_PATH_DEFAULT
|
|
|
|
LIB_PATH_DEFAULT.mkdir(exist_ok=True)
|
2019-11-24 18:13:02 +01:00
|
|
|
blacklist_updater = BlacklistUpdater()
|
2020-04-11 14:21:52 +02:00
|
|
|
blacklist_updater._is_install_time = _IS_VALIDATEEMAIL_SETUP
|
2019-11-24 18:13:02 +01:00
|
|
|
blacklist_updater.process(force=True)
|
|
|
|
super().run()
|
|
|
|
|
|
|
|
|
2020-04-12 13:57:10 +02:00
|
|
|
class DevelopCommand(develop):
|
|
|
|
'Develop command.'
|
2019-03-02 00:59:23 +01:00
|
|
|
|
|
|
|
def run(self):
|
2019-03-02 02:17:12 +01:00
|
|
|
if self.dry_run:
|
|
|
|
return super().run()
|
2020-04-11 23:32:02 +02:00
|
|
|
# Install dependencies so the initial update can run
|
|
|
|
check_call([executable, '-m', 'pip', 'install'] + _DEPENDENCIES)
|
2020-04-11 14:21:52 +02:00
|
|
|
# The updater will walk code stack frames and see if this
|
|
|
|
# variable is set in locals() to determine if it is run from the
|
|
|
|
# setup, in which case it won't autoupdate.
|
|
|
|
_IS_VALIDATEEMAIL_SETUP = True
|
2020-04-12 14:42:20 +02:00
|
|
|
from validate_email.updater import BlacklistUpdater, LIB_PATH_DEFAULT
|
|
|
|
LIB_PATH_DEFAULT.mkdir(exist_ok=True)
|
2019-11-24 14:18:07 +01:00
|
|
|
blacklist_updater = BlacklistUpdater()
|
2020-04-11 14:21:52 +02:00
|
|
|
blacklist_updater._is_install_time = _IS_VALIDATEEMAIL_SETUP
|
2019-11-24 14:18:07 +01:00
|
|
|
blacklist_updater.process(force=True)
|
2019-03-02 00:59:23 +01:00
|
|
|
super().run()
|
|
|
|
|
2012-04-07 23:05:57 +02:00
|
|
|
|
2020-04-12 13:57:10 +02:00
|
|
|
class SdistCommand(sdist):
|
|
|
|
'Sdist command.'
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
"""
|
|
|
|
Manually remove the data directory before creating the
|
|
|
|
distribution package, every install will create it for
|
|
|
|
themselves when installing created the python wheel.
|
|
|
|
`MANIFEST.in` should not remove the data dir since install and
|
|
|
|
develop/install would exclude it!
|
|
|
|
"""
|
|
|
|
if self.dry_run:
|
|
|
|
return super().run()
|
|
|
|
tempdir = Path(mkdtemp()).joinpath('data')
|
|
|
|
data_dir = Path(
|
|
|
|
__file__).absolute().parent.joinpath('validate_email', 'data')
|
|
|
|
do_move = data_dir.exists()
|
|
|
|
if do_move:
|
|
|
|
move(src=data_dir, dst=tempdir)
|
|
|
|
super().run()
|
|
|
|
if do_move:
|
|
|
|
move(src=tempdir, dst=data_dir)
|
|
|
|
rmtree(path=tempdir.parent)
|
|
|
|
|
|
|
|
|
2018-05-31 13:13:28 +02:00
|
|
|
setup(
|
2019-03-01 23:29:01 +01:00
|
|
|
name='py3-validate-email',
|
2020-04-12 14:42:20 +02:00
|
|
|
version='0.2.4',
|
2019-03-02 02:17:12 +01:00
|
|
|
packages=find_packages(exclude=['tests']),
|
2020-04-11 23:32:02 +02:00
|
|
|
install_requires=_DEPENDENCIES,
|
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.'),
|
2020-04-11 23:32:02 +02:00
|
|
|
long_description=_LONG_DESC,
|
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',
|
2020-04-12 13:57:10 +02:00
|
|
|
cmdclass=dict(
|
|
|
|
develop=DevelopCommand, install=InstallCommand, sdist=SdistCommand),
|
2019-03-01 20:37:52 +01:00
|
|
|
license='LGPL',
|
2018-05-31 13:13:28 +02:00
|
|
|
)
|