diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 67d2aca..4b22b21 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,9 @@ +0.2.2: +- Fixed the automatic download of the validate_email/data directory on + package install time. The source distribution MUST NOT include the + data directory, local installs have to fetch them when they are + executed. + 0.2.1: - Added a validate_email_or_fail function that will raise an exception (base class validate_email.exceptions.EmailValidationError) when the diff --git a/MANIFEST.in b/MANIFEST.in index bfb3387..6be948f 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -3,8 +3,6 @@ include LICENSE include README.rst include CHANGELOG.txt recursive-include validate_email * -prune tests -prune validate_email/data recursive-exclude tests * recursive-exclude * __pycache__ recursive-exclude * *.pyc diff --git a/setup.py b/setup.py index b358fa3..ea08cb4 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,12 @@ from pathlib import Path +from shutil import move, rmtree from subprocess import check_call +from tempfile import mkdtemp from setuptools import find_packages, setup from setuptools.command.develop import develop from setuptools.command.install import install +from setuptools.command.sdist import sdist try: # OSX Homebrew fix: https://stackoverflow.com/a/53190037/1067833 @@ -16,8 +19,8 @@ with open(Path(__file__).parent.joinpath('README.rst')) as fd: _LONG_DESC = fd.read() -class PostInstallCommand(install): - 'Post-installation command.' +class InstallCommand(install): + 'Install command.' def run(self): if self.dry_run: @@ -35,8 +38,8 @@ class PostInstallCommand(install): super().run() -class PostDevelopCommand(develop): - 'Post-installation command.' +class DevelopCommand(develop): + 'Develop command.' def run(self): if self.dry_run: @@ -54,9 +57,34 @@ class PostDevelopCommand(develop): super().run() +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) + + setup( name='py3-validate-email', - version='0.2.1', + version='0.2.2', packages=find_packages(exclude=['tests']), install_requires=_DEPENDENCIES, author='László Károlyi', @@ -67,6 +95,7 @@ setup( long_description_content_type='text/x-rst', keywords='email validation verification mx verify', url='http://github.com/karolyi/py3-validate-email', - cmdclass=dict(install=PostInstallCommand, develop=PostDevelopCommand), + cmdclass=dict( + develop=DevelopCommand, install=InstallCommand, sdist=SdistCommand), license='LGPL', )