From 516e03e5830a57bc88eba56c686e987e46f778f1 Mon Sep 17 00:00:00 2001 From: Ilkka-LBL Date: Mon, 28 Oct 2024 17:11:51 +0000 Subject: [PATCH] release version file functionality --- docs/source/conf.py | 9 +++++++-- setup.py | 11 +++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index bf36f6e..e6fcb43 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -10,8 +10,13 @@ # Add the parent directory to sys.path to allow imports sys.path.insert(0, os.path.abspath('../../')) -with open('./release.txt') as f: - version = f.read() +from pathlib import Path + +# Get the path to the release.txt file +release_file = Path(__file__).resolve().parent.parent / 'release.txt' + +with open(release_file) as f: + version = f.read().strip() project = 'Consensus' copyright = '2024, Ilkka Sipila - Lewisham Council Data Science and Insight team' diff --git a/setup.py b/setup.py index 7e6f14d..7cf8275 100644 --- a/setup.py +++ b/setup.py @@ -8,12 +8,15 @@ import shutil import os from setuptools import setup, find_packages, Command +from pathlib import Path with open('README.md') as f: long_description = f.read() -with open('release.txt') as f: - version = f.read() + +def read_release_version(): + # Get the path to the release.txt file + return (Path(__file__).parent / 'release.txt').read_text().strip() class CleanCommand(Command): @@ -48,10 +51,10 @@ def package_files(directory): setup( name='Consensus', - version=version, + version=read_release_version(), author='Ilkka Sipila', author_email='ilkka.sipila@lewisham.gov.uk', - website='https://ilkka-lbl.github.io/Consensus/', + url='https://ilkka-lbl.github.io/Consensus/', packages=find_packages(), include_package_data=True, package_data={