From 76e07ff25d24096e893a3425c3ac23adece3ed2a Mon Sep 17 00:00:00 2001 From: f-marschall Date: Tue, 2 Jun 2026 10:59:55 +0200 Subject: [PATCH 1/2] Add pyproject.toml with numpy as build dependency to fix pip isolated builds --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..4973c84 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "wheel", "numpy"] +build-backend = "setuptools.build_meta" From a1c3cb620371677c423c6abc3b7d130cae403e83 Mon Sep 17 00:00:00 2001 From: f-marschall Date: Tue, 2 Jun 2026 11:08:03 +0200 Subject: [PATCH 2/2] Fix setup.py: read version statically instead of importing package at build time --- setup.py | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index e709474..75a549a 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,28 @@ import setuptools -from multilabel_oversampling import __version__ -print(__version__) +import re +import os -with open("README.md", "r") as file: +# Read version from __init__.py without importing the package (avoids build-time dependency issues) +_init_path = os.path.join(os.path.dirname(__file__), "multilabel_oversampling", "__init__.py") +with open(_init_path, "r", encoding="utf-8") as f: + _content = f.read() +# Accept either single or double quotes for the version string +_version_match = re.search(r"__version__\s*=\s*['\"]([^'\"]+)['\"]", _content) +if _version_match is None: + raise RuntimeError("Unable to find version string in __init__.py") +__version__ = _version_match.group(1) + +with open("README.md", "r", encoding="utf-8") as file: long_description = file.read() -with open("requirements.txt") as file: - required = file.read().splitlines() - +# Read runtime requirements from requirements.txt and ignore blank/comment lines +with open("requirements.txt", "r", encoding="utf-8") as file: + required = [l.strip() for l in file if l.strip() and not l.strip().startswith("#")] + + setuptools.setup( name="multilabel-oversampling", - version=__version__, + version=__version__, author="Philipp J. Rösch", author_email="phiyodr@gmail.com", description="Multilabel Oversampling", @@ -18,20 +30,14 @@ long_description_content_type="text/markdown", url="https://github.com/phiyodr/multilabel-oversampling", classifiers=[ - "Topic :: Scientific/Engineering :: Artificial Intelligence", + "Topic :: Scientific/Engineering :: Artificial Intelligence", "Programming Language :: Python :: 3", ], packages=setuptools.find_packages(), python_requires='>=3.6', package_data={ # If any package contains *.txt or *.rst files, include them: - "": ["*.txt", "*.csv", "*.json"]}, - install_requires=[ - "numpy", - "scikit-learn", - "pandas", - "seaborn", - "tqdm", - "matplotlib" - ] - ) + "": ["*.txt", "*.csv", "*.json"], + }, + install_requires=required, +)