From 6e823beec80665c5f309c91642921462c7f135bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Tue, 23 Jul 2024 10:47:56 +0200 Subject: [PATCH] read version from lib --- labhw/__init__.py | 2 ++ setup.py | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/labhw/__init__.py b/labhw/__init__.py index 206a4f6..f6ad046 100644 --- a/labhw/__init__.py +++ b/labhw/__init__.py @@ -1,3 +1,5 @@ +__version__ == '0.1.2' + from .LTS import * from .USBdev import * from .interactive import * diff --git a/setup.py b/setup.py index e65810f..dae2d50 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,24 @@ #!/usr/bin/env python +import os +import re from setuptools import setup, find_packages -from os import path -# Function to read the requirements from the requirements.txt file +def read_version(): + with open(os.path.join(os.path.dirname(__file__), 'labhw', '__init__.py')) as f: + for line in f: + match = re.match(r"^__version__ = ['\"]([^'\"]*)['\"]", line) + if match: + return match.group(1) + raise RuntimeError("Unable to find version string.") + def parse_requirements(filename): with open(filename, 'r') as file: return file.read().splitlines() # Get the long description from the README file -here = path.abspath(path.dirname(__file__)) -with open(path.join(here, 'README.md'), encoding='utf-8') as f: +here = os.path.abspath(os.path.dirname(__file__)) +with open(os.path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read()