From 6e2e380854901cca22d69dea258299d9d1d897b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Sat, 21 Oct 2017 14:34:22 +0300 Subject: Added a workaround for import troubles with PyInstaller et al --- apscheduler/__init__.py | 10 ++++++++-- docs/versionhistory.rst | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apscheduler/__init__.py b/apscheduler/__init__.py index cda59d4..7bf2c15 100644 --- a/apscheduler/__init__.py +++ b/apscheduler/__init__.py @@ -1,4 +1,10 @@ -# These will be removed in APScheduler 4.0. -release = __import__('pkg_resources').get_distribution('APScheduler').version.split('-')[0] +from pkg_resources import get_distribution, DistributionNotFound + +try: + release = get_distribution('APScheduler').version.split('-')[0] +except DistributionNotFound: + release = '3.4.0' + version_info = tuple(int(x) if x.isdigit() else x for x in release.split('.')) version = __version__ = '.'.join(str(x) for x in version_info[:3]) +del get_distribution, DistributionNotFound diff --git a/docs/versionhistory.rst b/docs/versionhistory.rst index 198ee74..34da4c0 100644 --- a/docs/versionhistory.rst +++ b/docs/versionhistory.rst @@ -10,6 +10,8 @@ APScheduler, see the :doc:`migration section `. * Dropped support for Python 3.3 * Added the ability to specify the table schema for ``SQLAlchemyJobStore`` (thanks to Meir Tseitlin) +* Added a workaround for the ``ImportError`` when used with PyInstaller and the likes + (caused by the missing packaging metadata when APScheduler is packaged with these tools) 3.3.1 -- cgit v1.2.1