From 08b16f5a0ccc998f2a03d068d097ce922a253b1a Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 25 Nov 2022 23:24:38 +0000 Subject: [PATCH] Switch to PEP517 standard for builds (#887) * Sync setup.cfg with requirements.txt * Include tests in PyPI tarballs And exclude them from setuptools * Set version number only once Switch to PEP517 standard (pyproject.toml) for builds --- MANIFEST.in | 1 + app/__init__.py | 3 ++- setup.py => app/version.py | 3 +-- pyproject.toml | 3 +++ setup.cfg | 7 ++++++- 5 files changed, 13 insertions(+), 4 deletions(-) rename setup.py => app/version.py (62%) create mode 100644 pyproject.toml diff --git a/MANIFEST.in b/MANIFEST.in index d3a0ad4..c853358 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,5 @@ graft app/static graft app/templates graft app/misc include requirements.txt +recursive-include test global-exclude *.pyc diff --git a/app/__init__.py b/app/__init__.py index 9118e0c..a9b6f81 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -16,6 +16,7 @@ from dotenv import load_dotenv from werkzeug.middleware.proxy_fix import ProxyFix from app.utils.misc import read_config_bool +from app.version import __version__ app = Flask(__name__, static_folder=os.path.dirname( os.path.abspath(__file__)) + '/static') @@ -36,7 +37,7 @@ if read_config_bool('HTTPS_ONLY'): app.config['SESSION_COOKIE_NAME'] = '__Secure-session' app.config['SESSION_COOKIE_SECURE'] = True -app.config['VERSION_NUMBER'] = '0.8.0' +app.config['VERSION_NUMBER'] = __version__ app.config['APP_ROOT'] = os.getenv( 'APP_ROOT', os.path.dirname(os.path.abspath(__file__))) diff --git a/setup.py b/app/version.py similarity index 62% rename from setup.py rename to app/version.py index 62b68e9..e7ab91e 100644 --- a/setup.py +++ b/app/version.py @@ -1,8 +1,7 @@ import os -import setuptools optional_dev_tag = '' if os.getenv('DEV_BUILD'): optional_dev_tag = '.dev' + os.getenv('DEV_BUILD') -setuptools.setup(version='0.8.0' + optional_dev_tag) +__version__ = '0.8.0' + optional_dev_tag diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9787c3b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index 5171ef4..01bdec7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,6 @@ [metadata] name = whoogle-search +version = attr: app.version.__version__ url = https://github.com/benbusby/whoogle-search description = Self-hosted, ad-free, privacy-respecting metasearch engine long_description = file: README.md @@ -18,11 +19,11 @@ packages = find: include_package_data = True install_requires= beautifulsoup4 + brotli cssutils cryptography defusedxml Flask - Flask-Session python-dotenv requests stem @@ -34,6 +35,10 @@ test = python-dateutil dev = pycodestyle +[options.packages.find] +exclude = + test* + [options.entry_points] console_scripts = whoogle-search = app.routes:run_app