From fde0a0bf99227f1da4c1283e87968f40d56d92b4 Mon Sep 17 00:00:00 2001 From: Andrew Wilkinson Date: Thu, 4 Jul 2024 12:43:55 +0100 Subject: [PATCH] chore: Update setup.py to allow installing from a source bundle, and only build the sdist package. --- pyproject.toml | 2 +- setup.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 96ad328..338b4c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ tag_format = "v{version}" version_variables = [ "glowprom/__init__.py:__version__" ] -build_command = "python3 setup.py sdist bdist_wheel" +build_command = "python3 setup.py sdist" [semantic_release.branches.main] match = "(main|master)" diff --git a/setup.py b/setup.py index 406c18f..6c38c0c 100644 --- a/setup.py +++ b/setup.py @@ -14,14 +14,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +import os + import setuptools -from glowprom import __version__ +try: + from glowprom import __version__ +except ImportError: + import re + + with open('glowprom.egg-info/PKG-INFO') as f: + __version__ = re.search("^Version: (.*)$", f.read(), re.MULTILINE).group(1) with open("README.md", "r") as fh: long_description = fh.read() -with open('requirements.txt') as f: +with open('requirements.txt' if os.path.exists('requirements.txt') else 'glowprom.egg-info/requires.txt') as f: requirements = f.read().splitlines() setuptools.setup(