-
-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of the metadata and Python resolution
- Loading branch information
Showing
2 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Any | ||
|
||
if TYPE_CHECKING: | ||
from hatch.env.plugin.interface import EnvironmentInterface | ||
|
||
|
||
def get_project_metadata(environment: EnvironmentInterface) -> dict[str, Any]: | ||
from hatchling.dep.core import dependencies_in_sync | ||
|
||
if not environment.metadata.hatch.metadata.hook_config or dependencies_in_sync( | ||
environment.metadata.build.requires_complex | ||
): | ||
from hatchling.metadata.utils import resolve_metadata_fields | ||
|
||
with environment.root.as_cwd(): | ||
return resolve_metadata_fields(environment.metadata) | ||
|
||
try: | ||
environment.check_compatibility() | ||
except Exception as e: | ||
environment.app.abort(f'Environment `{environment.name}` is incompatible: {e}') | ||
|
||
import json | ||
|
||
with environment.root.as_cwd(), environment.build_environment(environment.metadata.build.requires): | ||
command = ['python', '-u', '-W', 'ignore', '-m', 'hatchling', 'metadata', '--app', '--compact'] | ||
process = environment.platform.capture_process(command) | ||
return json.loads(environment.app.read_builder(process)) |