Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into abi3
Browse files Browse the repository at this point in the history
  • Loading branch information
joerick committed Apr 29, 2022
2 parents e3ff027 + f324c9a commit acc0796
Show file tree
Hide file tree
Showing 14 changed files with 475 additions and 148 deletions.
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -142,25 +142,25 @@ Here are some repos that use cibuildwheel.
|-----------------------------------|----|----|:------|
| [scikit-learn][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The machine learning library. A complex but clean config using many of cibuildwheel's features to build a large project with Cython and C++ extensions. |
| [Tornado][] | ![travisci icon][] | ![apple icon][] ![linux icon][] | Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed. |
| [NumPy][] | ![github icon][] ![travisci icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The fundamental package for scientific computing with Python. |
| [pytorch-fairseq][] | ![github icon][] | ![apple icon][] ![linux icon][] | Facebook AI Research Sequence-to-Sequence Toolkit written in Python. |
| [Matplotlib][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | The venerable Matplotlib, a Python library with C++ portions |
| [MyPy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | MyPyC, the compiled component of MyPy. |
| [Kivy][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Open source UI framework written in Python, running on Windows, Linux, macOS, Android and iOS |
| [NCNN][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | ncnn is a high-performance neural network inference framework optimized for the mobile platform |
| [Prophet][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Tool for producing high quality forecasts for time series data that has multiple seasonality with linear or non-linear growth. |
| [MyPy][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | The compiled version of MyPy using MyPyC. |
| [pydantic][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Data parsing and validation using Python type hints |
| [uvloop][] | ![github icon][] | ![apple icon][] ![linux icon][] | Ultra fast asyncio event loop. |
| [psutil][] | ![github icon][] | ![windows icon][] ![apple icon][] ![linux icon][] | Cross-platform lib for process and system monitoring in Python |
| [vaex][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | Out-of-Core hybrid Apache Arrow/NumPy DataFrame for Python, ML, visualization and exploration of big tabular data at a billion rows per second 馃殌 |
| [Google Benchmark][] | ![github icon][] | ![apple icon][] ![linux icon][] ![windows icon][] | A microbenchmark support library |

[scikit-learn]: https://github.com/scikit-learn/scikit-learn
[Tornado]: https://github.com/tornadoweb/tornado
[NumPy]: https://github.com/numpy/numpy
[pytorch-fairseq]: https://github.com/pytorch/fairseq
[Matplotlib]: https://github.com/matplotlib/matplotlib
[Kivy]: https://github.com/kivy/kivy
[NCNN]: https://github.com/Tencent/ncnn
[Prophet]: https://github.com/facebook/prophet
[MyPy]: https://github.com/mypyc/mypy_mypyc-wheels
[pydantic]: https://github.com/samuelcolvin/pydantic
[uvloop]: https://github.com/MagicStack/uvloop
[psutil]: https://github.com/giampaolo/psutil
[vaex]: https://github.com/vaexio/vaex
[Google Benchmark]: https://github.com/google/benchmark

[appveyor icon]: docs/data/readme_icons/appveyor.svg
[github icon]: docs/data/readme_icons/github.svg
Expand Down
59 changes: 50 additions & 9 deletions cibuildwheel/__main__.py
Expand Up @@ -2,6 +2,8 @@
import os
import shutil
import sys
import tarfile
import tempfile
import textwrap
from pathlib import Path
from tempfile import mkdtemp
Expand All @@ -20,13 +22,12 @@
CIBW_CACHE_PATH,
BuildSelector,
Unbuffered,
chdir,
detect_ci_provider,
)


def main() -> None:
platform: PlatformName

parser = argparse.ArgumentParser(
description="Build wheels for all the platforms.",
epilog="""
Expand Down Expand Up @@ -65,27 +66,35 @@ def main() -> None:

parser.add_argument(
"--output-dir",
type=Path,
default=Path(os.environ.get("CIBW_OUTPUT_DIR", "wheelhouse")),
help="Destination folder for the wheels. Default: wheelhouse.",
)

parser.add_argument(
"--config-file",
default="",
help="""
TOML config file. Default: "", meaning {package}/pyproject.toml,
if it exists.
TOML config file. Default: "", meaning {package}/pyproject.toml, if
it exists. To refer to a project inside your project, use {package};
this matters if you build from an SDist.
""",
)

parser.add_argument(
"package_dir",
default=".",
metavar="PACKAGE",
default=Path("."),
type=Path,
nargs="?",
help="""
Path to the package that you want wheels for. Must be a subdirectory of
the working directory. When set, the working directory is still
considered the 'project' and is copied into the Docker container on
Linux. Default: the working directory.
Path to the package that you want wheels for. Default: the working
directory. Can be a directory inside the working directory, or an
sdist. When set to a directory, the working directory is still
considered the 'project' and is copied into the Docker container
on Linux. When set to a tar.gz sdist file, --config-file
and --output-dir are relative to the current directory, and other
paths are relative to the expanded SDist directory.
""",
)

Expand All @@ -109,6 +118,38 @@ def main() -> None:

args = parser.parse_args(namespace=CommandLineArguments())

args.package_dir = args.package_dir.resolve()

# This are always relative to the base directory, even in SDist builds
args.output_dir = args.output_dir.resolve()

# Standard builds if a directory or non-existent path is given
if not args.package_dir.is_file() and not args.package_dir.name.endswith("tar.gz"):
build_in_directory(args)
return

# Tarfile builds require extraction and changing the directory
with tempfile.TemporaryDirectory(prefix="cibw-sdist-") as temp_dir_str:
temp_dir = Path(temp_dir_str)
with tarfile.open(args.package_dir) as tar:
tar.extractall(path=temp_dir)

# The extract directory is now the project dir
try:
(project_dir,) = temp_dir.iterdir()
except ValueError:
raise SystemExit("invalid sdist: didn't contain a single dir") from None

# This is now the new package dir
args.package_dir = project_dir.resolve()

with chdir(temp_dir):
build_in_directory(args)


def build_in_directory(args: CommandLineArguments) -> None:
platform: PlatformName

if args.platform != "auto":
platform = args.platform
else:
Expand Down
20 changes: 9 additions & 11 deletions cibuildwheel/options.py
Expand Up @@ -8,7 +8,7 @@
from typing import (
Any,
Dict,
Iterator,
Generator,
List,
Mapping,
NamedTuple,
Expand All @@ -22,6 +22,7 @@
import tomllib
else:
import tomli as tomllib

from packaging.specifiers import SpecifierSet

from .architecture import Architecture
Expand All @@ -36,6 +37,7 @@
DependencyConstraints,
TestSelector,
cached_property,
format_safe,
resources_dir,
selector_matches,
strtobool,
Expand All @@ -46,9 +48,9 @@
class CommandLineArguments:
platform: Literal["auto", "linux", "macos", "windows"]
archs: Optional[str]
output_dir: Optional[str]
output_dir: Path
config_file: str
package_dir: str
package_dir: Path
print_build_identifiers: bool
allow_empty: bool
prerelease_pythons: bool
Expand Down Expand Up @@ -263,7 +265,7 @@ def active_config_overrides(self) -> List[Override]:
]

@contextmanager
def identifier(self, identifier: Optional[str]) -> Iterator[None]:
def identifier(self, identifier: Optional[str]) -> Generator[None, None, None]:
self.current_identifier = identifier
try:
yield
Expand Down Expand Up @@ -344,7 +346,7 @@ def config_file_path(self) -> Optional[Path]:
args = self.command_line_arguments

if args.config_file:
return Path(args.config_file.format(package=args.package_dir))
return Path(format_safe(args.config_file, package=args.package_dir))

# return pyproject.toml, if it's available
pyproject_toml_path = Path(args.package_dir) / "pyproject.toml"
Expand All @@ -361,12 +363,8 @@ def package_requires_python_str(self) -> Optional[str]:
@property
def globals(self) -> GlobalOptions:
args = self.command_line_arguments
package_dir = Path(args.package_dir)
output_dir = Path(
args.output_dir
if args.output_dir is not None
else os.environ.get("CIBW_OUTPUT_DIR", "wheelhouse")
)
package_dir = args.package_dir
output_dir = args.output_dir

build_config = self.reader.get("build", env_plat=False, sep=" ") or "*"
skip_config = self.reader.get("skip", env_plat=False, sep=" ")
Expand Down
19 changes: 17 additions & 2 deletions cibuildwheel/util.py
Expand Up @@ -19,14 +19,15 @@
Any,
ClassVar,
Dict,
Generator,
Iterable,
Iterator,
List,
NamedTuple,
Optional,
Sequence,
TextIO,
TypeVar,
Union,
cast,
overload,
)
Expand Down Expand Up @@ -61,6 +62,7 @@
"selector_matches",
"strtobool",
"cached_property",
"chdir",
]

resources_dir: Final = Path(__file__).parent / "resources"
Expand Down Expand Up @@ -417,7 +419,7 @@ def unwrap(text: str) -> str:


@contextlib.contextmanager
def print_new_wheels(msg: str, output_dir: Path) -> Iterator[None]:
def print_new_wheels(msg: str, output_dir: Path) -> Generator[None, None, None]:
"""
Prints the new items in a directory upon exiting. The message to display
can include {n} for number of wheels, {s} for total number of seconds,
Expand Down Expand Up @@ -609,3 +611,16 @@ def find_compatible_abi3_wheel(wheels: Sequence[T], identifier: str) -> Optional
from functools import cached_property
else:
from .functools_cached_property_38 import cached_property


# Can be replaced by contextlib.chdir in Python 3.11
@contextlib.contextmanager
def chdir(new_path: Union[Path, str]) -> Generator[None, None, None]:
"""Non thread-safe context manager to change the current working directory."""

cwd = os.getcwd()
try:
os.chdir(new_path)
yield
finally:
os.chdir(cwd)
2 changes: 1 addition & 1 deletion docs/cpp_standards.md
Expand Up @@ -14,7 +14,7 @@ The old `manylinux1` image (based on CentOS 5) contains a version of GCC and lib

OS X/macOS allows you to specify a so-called "deployment target" version that will ensure backwards compatibility with older versions of macOS. One way to do this is by setting the `MACOSX_DEPLOYMENT_TARGET` environment variable.

However, to enable modern C++ standards, the deploment target needs to be set high enough (since older OS X/macOS versions did not have the necessary modern C++ standard library).
However, to enable modern C++ standards, the deployment target needs to be set high enough (since older OS X/macOS versions did not have the necessary modern C++ standard library).

To get C++11 and C++14 support, `MACOSX_DEPLOYMENT_TARGET` needs to be set to (at least) `"10.9"`. By default, `cibuildwheel` already does this, building 64-bit-only wheels for macOS 10.9 and later.

Expand Down
65 changes: 63 additions & 2 deletions docs/data/projects.yml
Expand Up @@ -287,7 +287,7 @@
pypi: mypy
ci: [github]
os: [apple, linux, windows]
notes: MyPyC, the compiled component of MyPy.
notes: The compiled version of MyPy using MyPyC.

- name: Imagecodecs (fork)
gh: czaki/imagecodecs_build
Expand Down Expand Up @@ -521,10 +521,71 @@
gh: arbor-sim/arbor
ci: [github]
os: [apple, linux]
pypi: arbor
notes: >
Arbor is a multi-compartment neuron simulation library; compatible with
next-generation accelerators; best-practices applied to research software;
focused on community-driven development. Includes a
[small script](https://github.com/arbor-sim/arbor/blob/master/scripts/patchwheel.py)
patching `rpath` in bundled libraries.
- name: Kivy
gh: kivy/kivy
ci: [github]
os: [windows, apple, linux]

- name: NCNN
gh: Tencent/ncnn
ci: [github]
os: [windows, apple, linux]

- name: Prophet
gh: facebook/prophet
ci: [github]
os: [windows, apple, linux]

- name: MemRay
gh: bloomberg/memray
ci: [github]
os: [linux]

- name: PyGame
gh: pygame/pygame
ci: [github]
os: [apple, linux]

- name: UltraJSON
gh: ultrajson/ultrajson
ci: [github]
os: [windows, apple, linux]

- name: NumPy
gh: numpy/numpy
ci: [github, travisci]
os: [windows, apple, linux]

- name: Wrapt
gh: GrahamDumpleton/wrapt
ci: [github]
os: [windows, apple, linux]

- name: SimpleJSON
gh: simplejson/simplejson
ci: [github]
os: [windows, apple, linux]

- name: Implicit
gh: benfred/implicit
ci: [github]
os: [windows, apple, linux]
notes: Includes GPU support for linux wheels

- name: power-grid-model
gh: alliander-opensource/power-grid-model
ci: [github]
os: [windows, apple, linux]
notes: Python/C++ library for distribution power system analysis

- name: Python-WebRTC
gh: MarshalX/python-webrtc
ci: [github]
os: [windows, apple, linux]

0 comments on commit acc0796

Please sign in to comment.