From 75bb69f0fde8e69942d97edd8d72afc9fb0d28ef Mon Sep 17 00:00:00 2001 From: pictuga Date: Sat, 11 Sep 2021 12:12:51 +0200 Subject: [PATCH] Make mysql optdep --- morss/crawler.py | 10 ++++++++-- setup.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/morss/crawler.py b/morss/crawler.py index b7cd1e3..2026ce6 100644 --- a/morss/crawler.py +++ b/morss/crawler.py @@ -630,7 +630,10 @@ class BaseCache: return True -import sqlite3 # isort:skip +try: + import sqlite3 # isort:skip +except ImportError: + pass class SQLiteCache(BaseCache): @@ -667,7 +670,10 @@ class SQLiteCache(BaseCache): self.con.execute('INSERT INTO data VALUES (?,?,?,?,?,?) ON CONFLICT(url) DO UPDATE SET code=?, msg=?, headers=?, data=?, timestamp=?', (url,) + value + value) -import pymysql.cursors # isort:skip +try: + import pymysql.cursors # isort:skip +except ImportError: + pass class MySQLCacheHandler(BaseCache): diff --git a/setup.py b/setup.py index 9b584ad..2c72ed4 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,8 @@ setup( download_url = 'https://git.pictuga.com/pictuga/morss', license = 'AGPL v3', packages = [package_name], - install_requires = ['lxml', 'bs4', 'python-dateutil', 'chardet', 'pymysql'], + install_requires = ['lxml', 'bs4', 'python-dateutil', 'chardet'], + extras_require = {'full': ['pymysql']}, package_data = {package_name: ['feedify.ini']}, data_files = [ ('share/' + package_name, ['README.md', 'LICENSE']),