Skip to content

Commit

Permalink
import packages test does not require setuptools anymore if not avail…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
dlohmeier committed Aug 20, 2024
1 parent 9e62bb0 commit 6277b7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ Changelog = "https://github.com/e2nIEE/pandapipes/blob/develop/CHANGELOG.rst"
[project.optional-dependencies]
docs = ["numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex", "sphinx-pyproject"]
plotting = ["plotly", "igraph"]
test = ["pytest", "pytest-xdist", "nbmake", "setuptools; python_version >= '3.12'"]
test = ["pytest", "pytest-xdist", "nbmake"]
all = [
"numpydoc", "sphinx", "sphinx_rtd_theme", "sphinxcontrib.bibtex",
"plotly", "igraph", "pytest", "pytest-xdist", "nbmake", "setuptools; python_version >= '3.12'"
"plotly", "igraph", "pytest", "pytest-xdist", "nbmake"
]

[tool.setuptools.packages.find]
Expand Down
21 changes: 19 additions & 2 deletions src/pandapipes/test/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,28 @@

import pytest
from pandapipes import pp_dir
from setuptools import find_packages
try:
from setuptools import find_packages
SETUPTOOLS_AVAILABLE = True
except ImportError:
SETUPTOOLS_AVAILABLE = False


def test_import_packages():
all_packages = find_packages(pp_dir)
if SETUPTOOLS_AVAILABLE:
all_packages = find_packages(pp_dir)
else:
all_packages = []
for root, dirs, files in os.walk(pp_dir):
for file in files:
if file != "__init__.py":
continue
path = os.path.relpath(root, pp_dir)
if path == ".":
continue
pck = path.replace(os.sep, ".")
all_packages.append(pck)

for pck in all_packages:
spec = importlib.util.find_spec(os.path.split(pp_dir)[-1] + "." + pck)
new_module = importlib.util.module_from_spec(spec)
Expand Down

0 comments on commit 6277b7c

Please sign in to comment.