Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fix under pyproject-hooks 1.2 #824

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions tests/packages/test-no-prepare/backend_no_prepare.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
# SPDX-License-Identifier: MIT

from setuptools.build_meta import build_sdist as build_sdist
from setuptools.build_meta import build_wheel as build_wheel

def build_wheel(wheel_directory, config_settings=None, metadata_directory=None):
import os.path
import zipfile

from build._compat import tomllib

with open('pyproject.toml', 'rb') as f:
metadata = tomllib.load(f)

wheel_basename = f"{metadata['project']['name'].replace('-', '_')}-{metadata['project']['version']}"
with zipfile.ZipFile(os.path.join(wheel_directory, f'{wheel_basename}-py3-none-any.whl'), 'w') as wheel:
wheel.writestr(
f'{wheel_basename}.dist-info/METADATA',
f"""\
Metadata-Version: 2.2
Name: {metadata['project']['name']}
Version: {metadata['project']['version']}
Summary: {metadata['project']['description']}
""",
)

return wheel.filename
7 changes: 6 additions & 1 deletion tests/packages/test-no-prepare/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
[build-system]
build-backend = 'backend_no_prepare'
backend-path = ['.']
requires = ['setuptools >= 42.0.0']
requires = []

[project]
name = "test-no-prepare"
version = "1.0.0"
description = "Test extracting metadata from a backend w/out `prepare_metadata_for_build_wheel` hook"
3 changes: 0 additions & 3 deletions tests/packages/test-no-prepare/setup.cfg

This file was deleted.

3 changes: 1 addition & 2 deletions tests/test_projectbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,7 @@ def test_metadata_path_no_prepare(tmp_dir, package_test_no_prepare):
pathlib.Path(builder.metadata_path(tmp_dir)),
).metadata

# Setuptools < v69.0.3 (https://github.com/pypa/setuptools/pull/4159) normalized this to dashes
assert metadata['name'].replace('-', '_') == 'test_no_prepare'
assert metadata['name'] == 'test-no-prepare'
assert metadata['Version'] == '1.0.0'


Expand Down
Loading