Skip to content

Commit 42fe418

Browse files
v2.18.10 (#542)
* chore: remove unused dependencies (#535) * chore: remove unused dependencies * Use Optional for energyplus_location (#536) * test: add energyplus interface coverage (#537) * Replace deprecated pkg_resources with importlib.metadata (#541) * Fix a typing issue * Replace deprecated pkg_resources with importlib.metadata pkg_resources was removed in setuptools 82. Use importlib.metadata (stdlib since Python 3.8) to resolve package version at runtime. https://claude.ai/code/session_01931BKYPT56MDrWgY3maT8D * Add PackageNotFoundError fallback in docs/conf.py Prevents Sphinx build from crashing if archetypal is not installed in the docs build environment. * Fix Sphinx version/release assignment in docs/conf.py Split the chained assignment so `release` retains the full version string (e.g. "2.18.9") and only `version` is truncated to major.minor. * Apply ruff auto-fixes (import sorting, __all__ ordering) * Bump version to 2.18.10
1 parent b3e3e1a commit 42fe418

14 files changed

+2483
-1610
lines changed

archetypal/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
from __future__ import annotations
88

99
import logging as lg
10+
11+
# Version of the package
12+
from importlib.metadata import PackageNotFoundError, version
1013
from pathlib import Path
11-
from typing import Any, ClassVar, Literal
14+
from typing import Any, ClassVar, Literal, Optional
1215

1316
from energy_pandas.units import unit_registry
1417

15-
# Version of the package
16-
from pkg_resources import DistributionNotFound, get_distribution
17-
1818
try:
1919
from pydantic_settings import BaseSettings
2020
except ImportError:
@@ -171,7 +171,7 @@ class Settings(BaseSettings, arbitrary_types_allowed=True, validate_assignment=T
171171
"for ENERGYPLUS_VERSION in os.environ",
172172
)
173173

174-
energyplus_location: DirectoryPath | None = Field(
174+
energyplus_location: Optional[DirectoryPath] = Field(
175175
None,
176176
validation_alias="ENERGYPLUS_LOCATION",
177177
description="Root directory of the EnergyPlus install.",
@@ -205,8 +205,8 @@ def initialize_units(cls, v):
205205
from .utils import clear_cache, config, parallel_process # noqa: E402
206206

207207
try:
208-
__version__ = get_distribution("archetypal").version
209-
except DistributionNotFound:
208+
__version__ = version("archetypal")
209+
except PackageNotFoundError:
210210
# package is not installed
211211
__version__ = "0.0.0" # should happen only if package is copied, not installed.
212212
else:
@@ -219,16 +219,16 @@ def initialize_units(cls, v):
219219
warn_if_not_compatible()
220220

221221
__all__ = [
222-
"settings",
223-
"Settings",
224-
"__version__",
225-
"utils",
226-
"dataportal",
227222
"IDF",
228-
"EnergyPlusVersion",
229223
"BuildingTemplate",
224+
"EnergyPlusVersion",
225+
"Settings",
230226
"UmiTemplateLibrary",
227+
"__version__",
231228
"clear_cache",
232229
"config",
230+
"dataportal",
233231
"parallel_process",
232+
"settings",
233+
"utils",
234234
]

docs/conf.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#
1616
import os
1717
import sys
18-
19-
from pkg_resources import get_distribution
18+
from importlib.metadata import PackageNotFoundError
19+
from importlib.metadata import version as get_version
2020

2121
sys.path.insert(0, os.path.abspath("."))
2222
sys.path.insert(0, os.path.abspath("archetypal"))
@@ -28,9 +28,12 @@
2828
author = "Samuel Letellier-Duchesne"
2929

3030
# The full version, including alpha/beta/rc tags
31-
release = get_distribution("archetypal").version
31+
try:
32+
release = get_version("archetypal")
33+
except PackageNotFoundError:
34+
release = "0.0.0"
3235
# for example take major/minor
33-
version = release = ".".join(release.split(".")[:2])
36+
version = ".".join(release.split(".")[:2])
3437

3538
# -- General configuration ---------------------------------------------------
3639

poetry.lock

Lines changed: 2387 additions & 1572 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "archetypal"
3-
version = "2.18.9"
3+
version = "2.18.10"
44
description = "Retrieve, construct, simulate, convert and analyse building archetypes"
55
authors = ["Samuel Letellier-Duchesne <samuelduchesne@me.com>"]
66
license = "MIT License"
@@ -20,43 +20,25 @@ scikit-learn = "^1.5.0"
2020
pandas = ">=2.0.3"
2121
tqdm = "^4.66.4"
2222
click = "^8.1.7"
23-
outdated = "^0.2.2"
24-
deprecation = "^2.1.0"
2523
sigfig = "^1.3.3"
2624
requests = "^2.32.3"
2725
coolprop = "^6.6.0"
2826
energy_pandas = "^0.4.1"
2927
validator-collection = "^1.5.0"
30-
typing-extensions = "^4.12.2"
3128
pydantic-settings = "^2.3.2"
3229
path = ">=17.1.0" # fix an issue with Path.copy returning a str instead of a Path object
3330
numpy = [
3431
{version = "^2.0.2", python = "<=3.9"},
3532
{version = "^2.1.1", python = "3.10"}
3633
]
37-
eval-type-backport = {version = "^0.2.0", python = "3.9"}
3834

3935
# geomeppy.dependencies
4036
shapely = "^2.0.6"
41-
beautifulsoup4 = "<=4.8"
42-
contourpy = "^1.2.1"
43-
cycler = "^0.12.1"
44-
decorator = "^5.1.1"
4537
esoreader = "^1.2.3"
46-
fonttools = "^4.53.0"
47-
future = "^1.0.0"
48-
kiwisolver = "^1.4.5"
49-
lxml = "^5.2.2"
50-
munch = "^4.0.0"
5138
packaging = "^24.1"
52-
pillow = "^10.3.0"
5339
pyclipper = "^1.3.0.post5"
54-
pydot3k = "^1.0.17"
55-
pyparsing = "^3.1.2"
5640
pypoly2tri = "^0.0.3"
57-
python-dateutil = "^2.9.0.post0"
5841
six = "^1.16.0"
59-
soupsieve = "^2.5"
6042
tomli = "^2.0.1"
6143
transforms3d = "^0.4.1"
6244

@@ -86,6 +68,9 @@ archetypal = "archetypal.cli:cli"
8668

8769
[tool.pytest.ini_options]
8870
testpaths = ["tests"]
71+
markers = [
72+
"slow: marks tests as slow that require EnergyPlus or long processing"
73+
]
8974

9075
[tool.ruff]
9176
target-version = "py39"

tests/conftest.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def clean_config(config):
5252
d.rmtree_p()
5353

5454

55-
# List fixtures that are located outiside of conftest.py so that they can be
55+
# List fixtures that are located outside of conftest.py so that they can be
5656
# used in other tests
57-
pytest_plugins = ["tests.test_dataportals"]
57+
# Removed import of test_dataportals as plugin to avoid unnecessary test loading
5858

5959
ALL = set("darwin linux win32".split())
6060

@@ -85,3 +85,15 @@ def safe_int_cast(val, default=0):
8585
return int(val)
8686
except (ValueError, TypeError):
8787
return default
88+
89+
90+
def pytest_addoption(parser):
91+
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
92+
93+
94+
def pytest_collection_modifyitems(config, items):
95+
if not config.getoption("--runslow"):
96+
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
97+
for item in items:
98+
if "slow" in item.keywords:
99+
item.add_marker(skip_slow)

tests/test_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from .conftest import data_dir
1212

13+
pytestmark = pytest.mark.slow
14+
1315

1416
class TestCli:
1517
"""Defines tests for usage of the archetypal Command Line Interface"""

tests/test_dataportals.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
from .conftest import data_dir
1111

12+
pytestmark = pytest.mark.slow
13+
1214

1315
def test_tabula_available_country(config):
1416
# First, let's try the API call

tests/test_end_use_balance.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from archetypal import IDF
66
from archetypal.idfclass.end_use_balance import EndUseBalance
77

8+
pytestmark = pytest.mark.slow
9+
810

911
class TestEndUseBalance:
1012
@pytest.fixture()

tests/test_energypandas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
from .conftest import data_dir
99

10+
pytestmark = pytest.mark.slow
11+
1012

1113
@pytest.fixture(scope="module")
1214
def idf(config):

tests/test_energyplus_interface.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import pytest
2+
from path import Path
3+
4+
from archetypal.eplus_interface.energy_plus import EnergyPlusExe, EnergyPlusProgram
5+
from archetypal.eplus_interface.exceptions import EnergyPlusVersionError
6+
from archetypal.eplus_interface.version import EnergyPlusVersion
7+
8+
9+
def test_energyplus_exe_cmd(tmp_path, mocker):
10+
exe = Path(tmp_path / "energyplus")
11+
exe.write_text("")
12+
weather = Path(tmp_path / "weather")
13+
weather.write_text("")
14+
mocker.patch("eppy.runner.run_functions.install_paths", return_value=(str(exe), str(weather)))
15+
version = EnergyPlusVersion("9.2.0")
16+
ep = EnergyPlusExe("in.idf", "in.epw", Path(tmp_path), version, annual=True, readvars=False)
17+
cmd = ep.cmd()
18+
assert str(exe) in str(cmd[0])
19+
assert "-a" in cmd
20+
assert "-r" not in cmd
21+
assert "in.idf" in cmd[-1]
22+
23+
24+
def test_energyplus_exe_missing(tmp_path, mocker):
25+
mocker.patch(
26+
"eppy.runner.run_functions.install_paths",
27+
return_value=(str(Path(tmp_path) / "missing"), str(tmp_path)),
28+
)
29+
version = EnergyPlusVersion("9.2.0")
30+
with pytest.raises(EnergyPlusVersionError):
31+
EnergyPlusExe("in.idf", "in.epw", Path(tmp_path), version)
32+
33+
34+
def test_energyplus_program_home(tmp_path):
35+
version = EnergyPlusVersion("9.2.0")
36+
version.install_locations = {version.dash: Path(tmp_path)}
37+
idf = type("IDF", (), {"file_version": version})()
38+
program = EnergyPlusProgram(idf)
39+
assert program.eplus_home == Path(tmp_path)

0 commit comments

Comments
 (0)