Skip to content

Commit

Permalink
Fix the project metadata command (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek authored Dec 4, 2023
1 parent 2137d89 commit fe663ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/history/hatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix nushell activation
- Better handling of flat storage directory hierarchies for the `virtual` environment type
- Display useful information when running the `version` command outside of a project rather than erroring
- Fix the `project metadata` command by only capturing stdout from the backend
- Properly support Google Artifact Registry

## [1.7.0](https://github.com/pypa/hatch/releases/tag/hatch-v1.7.0) - 2023-04-03 ## {: #hatch-v1.7.0 }
Expand Down
7 changes: 5 additions & 2 deletions src/hatch/cli/project/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ def metadata(app, field):
) as status, environment.build_environment(app.project.metadata.build.requires):
status.stop()

command = ['python', '-u', '-m', 'hatchling', 'metadata', '--compact']
output = app.platform.check_command_output(command)
output = app.platform.check_command_output(
['python', '-u', '-m', 'hatchling', 'metadata', '--compact'],
# Only capture stdout
stderr=None,
)
project_metadata = json.loads(output)

if field:
Expand Down
11 changes: 4 additions & 7 deletions src/hatch/utils/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,11 @@ def check_command_output(self, command: str | list[str], *, shell: bool = False,
[capture_process](utilities.md#hatch.utils.platform.Platform.capture_process),
but non-zero exit codes will gracefully end program execution.
"""
kwargs.setdefault('stdout', self.modules.subprocess.PIPE)
kwargs.setdefault('stderr', self.modules.subprocess.STDOUT)
self.populate_default_popen_kwargs(kwargs, shell=shell)
process = self.modules.subprocess.run(
command,
shell=shell,
stdout=self.modules.subprocess.PIPE,
stderr=self.modules.subprocess.STDOUT,
**kwargs,
)

process = self.modules.subprocess.run(command, shell=shell, **kwargs)
if process.returncode:
self.__display_func(process.stdout.decode('utf-8'))
self.exit_with_code(process.returncode)
Expand Down

0 comments on commit fe663ba

Please sign in to comment.