Skip to content

Commit

Permalink
Maybe fix use of {project} in pysam [tool.cibuildwheel]
Browse files Browse the repository at this point in the history
  • Loading branch information
natefoo committed Nov 29, 2023
1 parent 90f3f0d commit 27d5d64
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions recipes/pysam/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---
name: pysam
version: 0.22.0
# as of 0.22.0 {project} in pyproject.toml [tool.cibuildwheel] expects to be the package dir
run_in_sdist: true
16 changes: 13 additions & 3 deletions wheel_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
package_name = meta["name"]
package_version = meta["version"]
is_package_pure = meta.get("purepy", False)
run_in_sdist = meta.get("run_in_sdist", False)

# Find the sdist url using the PyPI warehouse API https://warehouse.pypa.io/api-reference/json.html
pypi_url = f"https://pypi.org/pypi/{package_name}/{package_version}/json"
Expand Down Expand Up @@ -60,7 +61,11 @@
env_file = os.path.join(folder, "env.sh")
if os.path.exists(env_file):
commands.append(f". '{env_file}'")
if is_package_pure:

extracted_sdist_dir = None
package_path = sdist_filepath
wheelhouse = os.path.join(os.getcwd(), "wheelhouse")
if is_package_pure or run_in_dist:
tar_temp_dir = Path(tempfile.mkdtemp(dir=temp_dir))
with tarfile.open(sdist_filepath) as tar:
tar.extractall(path=tar_temp_dir)
Expand All @@ -70,11 +75,16 @@
except ValueError:
raise Exception("Invalid sdist: didn't contain a single directory")

commands.append(f"python3 -m build --wheel --outdir wheelhouse '{extracted_sdist_dir}'")
package_path = "."

if is_package_pure:
commands.append(f"python3 -m build --wheel --outdir '{wheelhouse}' '{extracted_sdist_dir}'")
else:
check_commands = commands.copy()
check_commands.append("cibuildwheel --print-build-identifiers")
commands.append(f"cibuildwheel --output-dir wheelhouse '{sdist_filepath}'")
if run_in_dist:
commands.append(f"cd '{extracted_sdist_dir}'")
commands.append(f"cibuildwheel --output-dir '{wheelhouse}' '{package_path}'")
joined_command = " && ".join(commands)
joined_check_command = " && ".join(check_commands)

Expand Down

0 comments on commit 27d5d64

Please sign in to comment.