Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 28, 2022
1 parent a52d040 commit a620db8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
17 changes: 12 additions & 5 deletions src/poetry/core/masonry/builders/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import shutil
import stat
import subprocess
import sys
import tempfile
import zipfile
import sys

from base64 import urlsafe_b64encode
from io import StringIO
Expand Down Expand Up @@ -185,7 +185,11 @@ def _build(self, wheel: zipfile.ZipFile) -> None:
python_version_minor = sys.version_info[1]
build_dir = self._path / "build"
libs: list[Path] = list(build_dir.glob("lib.*"))
scripts: list[Path] = list(build_dir.glob(f"scripts-{python_version_major}.{python_version_minor}/*"))
scripts: list[Path] = list(
build_dir.glob(
f"scripts-{python_version_major}.{python_version_minor}/*"
)
)
if libs:
lib = libs[0]

Expand All @@ -198,7 +202,7 @@ def _build(self, wheel: zipfile.ZipFile) -> None:
if rel_path in wheel.namelist():
continue

#logger.debug(f"Adding: {rel_path}")
# logger.debug(f"Adding: {rel_path}")
print(f"Adding: {rel_path}")

self._add_file(wheel, pkg, rel_path)
Expand All @@ -210,10 +214,13 @@ def _build(self, wheel: zipfile.ZipFile) -> None:
self._add_file(
wheel,
abs_path,
Path.joinpath(Path(self.wheel_data_folder), "scripts", abs_path.name),
Path.joinpath(
Path(self.wheel_data_folder),
"scripts",
abs_path.name,
),
)


# The result of building the extensions
# does not exist, this may due to conditional
# builds, so we assume that it's okay
Expand Down
12 changes: 10 additions & 2 deletions tests/masonry/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,18 +93,26 @@ def test_build_wheel_extended() -> None:
assert whl.exists()
validate_wheel_contents(name="extended", version="0.1", path=whl.as_posix())


@pytest.mark.skipif(
sys.platform == "win32"
and sys.version_info <= (3, 6)
or platform.python_implementation().lower() == "pypy",
reason="Disable test on Windows for Python <=3.6 and for PyPy",
)
def test_build_wheel_script_generated() -> None:
with temporary_directory() as tmp_dir, cwd(os.path.join(fixtures, "script_generated")):
with temporary_directory() as tmp_dir, cwd(
os.path.join(fixtures, "script_generated")
):
filename = api.build_wheel(tmp_dir)
whl = Path(tmp_dir) / filename
assert whl.exists()
validate_wheel_contents(name="script_generated", version="0.1", path=whl.as_posix(), data_files=["scripts/file.py"])
validate_wheel_contents(
name="script_generated",
version="0.1",
path=whl.as_posix(),
data_files=["scripts/file.py"],
)


def test_build_sdist() -> None:
Expand Down
6 changes: 5 additions & 1 deletion tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ def subprocess_run(*args: str, **kwargs: Any) -> subprocess.CompletedProcess[str


def validate_wheel_contents(
name: str, version: str, path: str, files: list[str] | None = None, data_files: list[str] | None = None
name: str,
version: str,
path: str,
files: list[str] | None = None,
data_files: list[str] | None = None,
) -> None:
dist_info = f"{name}-{version}.dist-info"
dist_data = f"{name}-{version}.data"
Expand Down

0 comments on commit a620db8

Please sign in to comment.