From 000ae2c75a8cba345890525031d96de8a6712992 Mon Sep 17 00:00:00 2001 From: ammounce Date: Sun, 15 Sep 2024 13:55:23 -0600 Subject: [PATCH] fix: fixed version upload and autochange --- pyproject.toml | 10 ++++++++-- src/itemattribute/__init__.py | 14 ++++++++++++++ src/itemattribute/version.json | 4 +--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 40d12ba..87e887b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools >= 61.0"] +requires = ["setuptools >= 61.0", "setuptools-scm>=8.0"] build-backend = "setuptools.build_meta" [project] @@ -11,8 +11,14 @@ requires-python = ">= 3.7" authors = [{name = "Andy Mounce", email = "ammounce@gmail.com"}] description = "Python class that allows dict item syntax for attribute access" readme = {file = "README.txt", content-type = "text/markdown"} -license = {file = "LICENSE"} +license = { file = "LICENSE" } [project.urls] Homepage = "https://github.com/ammounce/itemattribute" Issues = "https://github.com/ammounce/itemattribute/issues" + +[tools.setuptools] +packages = ["itemattribute"] + +[tool.setuptools.dynamic] +version = {attr = "itemattribute.__version__"} diff --git a/src/itemattribute/__init__.py b/src/itemattribute/__init__.py index ddec175..0be1365 100644 --- a/src/itemattribute/__init__.py +++ b/src/itemattribute/__init__.py @@ -1 +1,15 @@ from .item_attribute import ItemAttribute + +import importlib.resources +import json +import os + +dir = os.path.dirname(os.path.abspath(__file__)) +# with importlib.resources.open_text("itemattribute", "version.json") as file: +# __version__ = json.load(file)['version'] +try: + with open(dir + '/version.json') as file: + __version__ = json.load(file) +except FileNotFoundError: + with importlib.resources.open_text("itemattribute", "version.json") as file: + __version__ = json.load(file)['version'] diff --git a/src/itemattribute/version.json b/src/itemattribute/version.json index ca5c488..a582d77 100644 --- a/src/itemattribute/version.json +++ b/src/itemattribute/version.json @@ -1,3 +1 @@ -{ - "version": "0.0.2" -} +"0.0.2"