From 82ee859c35eaa250f593489ca0cd5d0f3af7f0bd Mon Sep 17 00:00:00 2001 From: Daniel Fett Date: Fri, 15 Sep 2023 08:56:55 +0200 Subject: [PATCH] Fix version number fetching --- setup.py | 23 ++++++++++++++++++++--- ssllabs/vars.py | 3 +-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index bc5fb99..ccaf689 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,29 @@ from setuptools import setup -from ssllabs import vars + +# Read the value of the 'version' variable from ssllabs/vars.py without importing it. +# Importing vars.py would cause the installation to fail if dependencies of ssllabs/__init__.py are not met. + +import pathlib +import re + +version = None + +with open(pathlib.Path(__file__).parent / 'ssllabs' / 'vars.py') as f: + for line in f: + match = re.match(r'version = \'(.*)\'', line) + if match: + version = match.group(1) + break + +if not version: + raise RuntimeError('Could not determine version from ssllabs/vars.py') setup(name='python-ssllabs', - version=vars.version, + version=version, packages=['ssllabs'], scripts=['ssllabs-cli.py'], install_requires=['requests'], url='https://github.com/takeshixx/python-ssllabs', - license=vars.license, + license='Apache 2.0', author='takeshix', author_email='takeshix@adversec.com') diff --git a/ssllabs/vars.py b/ssllabs/vars.py index 6508445..71ed960 100644 --- a/ssllabs/vars.py +++ b/ssllabs/vars.py @@ -1,2 +1 @@ -version = '1.4' -license = 'Apache 2.0' \ No newline at end of file +version = '1.4' \ No newline at end of file