From 65f39dd70e75cedb1473f691a4212bc77251e33d Mon Sep 17 00:00:00 2001 From: Frankie Dintino Date: Thu, 11 Jul 2024 11:37:37 -0400 Subject: [PATCH] fix: remove pkg_resources dependency --- selenosis/__init__.py | 6 +----- setup.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/selenosis/__init__.py b/selenosis/__init__.py index 4563971..a87492b 100644 --- a/selenosis/__init__.py +++ b/selenosis/__init__.py @@ -5,14 +5,10 @@ # # without running afoul of the strict import order required by Django 1.9+. # This implementation is shamelessly stolen from werkzeug's ``__init__.py``. -import pkg_resources import sys from types import ModuleType -try: - __version__ = pkg_resources.get_distribution('django-selenosis').version -except pkg_resources.DistributionNotFound: - __version__ = None +__version__ = "2.0.5" # import mapping to objects in other modules all_by_module = { diff --git a/setup.py b/setup.py index 4841b81..99e82e5 100755 --- a/setup.py +++ b/setup.py @@ -1,9 +1,23 @@ #!/usr/bin/env python from os import path +import re from setuptools import setup, find_packages +# Find the package version in __init__.py without importing it +init_file = path.join(path.dirname(__file__), "selenosis", "__init__.py") +with open(init_file) as f: + for line in f: + m = re.search(r"""^__version__ = (['"])(.+?)\1$""", line) + if m is not None: + version = m.group(2) + break + else: + raise LookupError("Unable to find __version__ in " + init_file) + + + def read(*parts): file_path = path.join(path.dirname(__file__), *parts) return open(file_path).read() @@ -11,7 +25,7 @@ def read(*parts): setup( name='django-selenosis', - version='2.0.5', + version=version, license='BSD', description='Helpers for writing selenium tests for Django', long_description=read('README.rst'),