Skip to content

Commit

Permalink
e3-pypi-closure: Use pip wheel to build wheels
Browse files Browse the repository at this point in the history
This allows us to build projects that use pyproject.toml and/or setup.py.
  • Loading branch information
leocardao committed Feb 27, 2024
1 parent 5408462 commit 06d189b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/e3/python/wheel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations
import os
import sys
import zipfile
import tempfile
from pkg_resources import Requirement
Expand Down Expand Up @@ -54,23 +53,26 @@ def build(cls, source_dir: str, dest_dir: str, python_tag: str = "py3") -> Wheel
"""
with tempfile.TemporaryDirectory() as build_dir:
p = Run(
[
sys.executable,
"./setup.py",
python_script("pip")
+ [
"wheel",
".",
"-q",
"bdist_wheel",
f"--python-tag={python_tag}",
"-d",
"--no-deps",
f"-C--python-tag={python_tag}",
"-w",
build_dir,
],
cwd=source_dir,
)

if p.status != 0:
raise WheelError(f"Error during wheel creation:\n{p.out}")

tmp_whl_path = ls(os.path.join(build_dir, "*.whl"))[0]
dest_whl_path = os.path.join(dest_dir, os.path.basename(tmp_whl_path))
mv(tmp_whl_path, dest_whl_path)

return Wheel(path=dest_whl_path)

def install(self) -> None:
Expand Down

0 comments on commit 06d189b

Please sign in to comment.