|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import json |
4 | | -import sys |
5 | | -from functools import lru_cache |
| 4 | +from functools import cache |
6 | 5 | from typing import TYPE_CHECKING, Any, Literal |
7 | 6 |
|
8 | 7 | from hatch.utils.fs import Path |
@@ -295,58 +294,33 @@ def get_core_metadata(self, *, output_dir: str, project_root: str) -> str: |
295 | 294 | ) |
296 | 295 |
|
297 | 296 |
|
298 | | -if sys.version_info[:2] >= (3, 9): |
| 297 | +@cache |
| 298 | +def hook_caller_script() -> str: |
| 299 | + from importlib.resources import files |
299 | 300 |
|
300 | | - @lru_cache(maxsize=None) |
301 | | - def hook_caller_script() -> str: |
302 | | - from importlib.resources import files |
| 301 | + script = files('pyproject_hooks._in_process') / '_in_process.py' |
| 302 | + return script.read_text(encoding='utf-8') |
303 | 303 |
|
304 | | - script = files('pyproject_hooks._in_process') / '_in_process.py' |
305 | | - return script.read_text(encoding='utf-8') |
306 | 304 |
|
307 | | - @lru_cache(maxsize=None) |
308 | | - def runner_script() -> str: |
309 | | - from importlib.resources import files |
| 305 | +@cache |
| 306 | +def runner_script() -> str: |
| 307 | + from importlib.resources import files |
310 | 308 |
|
311 | | - script = files('hatch.project.frontend.scripts') / 'standard.py' |
312 | | - return script.read_text(encoding='utf-8') |
| 309 | + script = files('hatch.project.frontend.scripts') / 'standard.py' |
| 310 | + return script.read_text(encoding='utf-8') |
313 | 311 |
|
314 | | - @lru_cache(maxsize=None) |
315 | | - def hatch_build_deps_script() -> str: |
316 | | - from importlib.resources import files |
317 | 312 |
|
318 | | - script = files('hatch.project.frontend.scripts') / 'build_deps.py' |
319 | | - return script.read_text(encoding='utf-8') |
| 313 | +@cache |
| 314 | +def hatch_build_deps_script() -> str: |
| 315 | + from importlib.resources import files |
320 | 316 |
|
321 | | - @lru_cache(maxsize=None) |
322 | | - def hatch_core_metadata_script() -> str: |
323 | | - from importlib.resources import files |
| 317 | + script = files('hatch.project.frontend.scripts') / 'build_deps.py' |
| 318 | + return script.read_text(encoding='utf-8') |
324 | 319 |
|
325 | | - script = files('hatch.project.frontend.scripts') / 'core_metadata.py' |
326 | | - return script.read_text(encoding='utf-8') |
327 | 320 |
|
328 | | -else: |
| 321 | +@cache |
| 322 | +def hatch_core_metadata_script() -> str: |
| 323 | + from importlib.resources import files |
329 | 324 |
|
330 | | - @lru_cache(maxsize=None) |
331 | | - def hook_caller_script() -> str: |
332 | | - from importlib.resources import read_text |
333 | | - |
334 | | - return read_text('pyproject_hooks._in_process', '_in_process.py') |
335 | | - |
336 | | - @lru_cache(maxsize=None) |
337 | | - def runner_script() -> str: |
338 | | - from importlib.resources import read_text |
339 | | - |
340 | | - return read_text('hatch.project.frontend.scripts', 'standard.py') |
341 | | - |
342 | | - @lru_cache(maxsize=None) |
343 | | - def hatch_build_deps_script() -> str: |
344 | | - from importlib.resources import read_text |
345 | | - |
346 | | - return read_text('hatch.project.frontend.scripts', 'build_deps.py') |
347 | | - |
348 | | - @lru_cache(maxsize=None) |
349 | | - def hatch_core_metadata_script() -> str: |
350 | | - from importlib.resources import read_text |
351 | | - |
352 | | - return read_text('hatch.project.frontend.scripts', 'core_metadata.py') |
| 325 | + script = files('hatch.project.frontend.scripts') / 'core_metadata.py' |
| 326 | + return script.read_text(encoding='utf-8') |
0 commit comments