A PEP-517 `build_wheel()` function. Also called by `handle_argv()` to handle the `bdist_wheel` command. Returns leafname of generated wheel within `wheel_directory`.
(self,
wheel_directory,
config_settings=None,
metadata_directory=None,
)
| 661 | |
| 662 | |
| 663 | def build_wheel(self, |
| 664 | wheel_directory, |
| 665 | config_settings=None, |
| 666 | metadata_directory=None, |
| 667 | ): |
| 668 | ''' |
| 669 | A PEP-517 `build_wheel()` function. |
| 670 | |
| 671 | Also called by `handle_argv()` to handle the `bdist_wheel` command. |
| 672 | |
| 673 | Returns leafname of generated wheel within `wheel_directory`. |
| 674 | ''' |
| 675 | log2( |
| 676 | f' wheel_directory={wheel_directory!r}' |
| 677 | f' config_settings={config_settings!r}' |
| 678 | f' metadata_directory={metadata_directory!r}' |
| 679 | ) |
| 680 | |
| 681 | if os.environ.get('CIBUILDWHEEL') == '1': |
| 682 | # Don't special-case graal builds when running under cibuildwheel. |
| 683 | pass |
| 684 | elif sys.implementation.name == 'graalpy': |
| 685 | # We build for Graal by building a native Python wheel with Graal |
| 686 | # Python's include paths and library directory. We then rename the |
| 687 | # wheel to contain graal's tag etc. |
| 688 | # |
| 689 | log0(f'### Graal build: deferring to cpython.') |
| 690 | python_native = os.environ.get('PIPCL_GRAAL_PYTHON') |
| 691 | assert python_native, f'Graal build requires that PIPCL_GRAAL_PYTHON is set.' |
| 692 | env_extra = dict( |
| 693 | PIPCL_SYSCONFIG_PATH_include = sysconfig.get_path('include'), |
| 694 | PIPCL_SYSCONFIG_PATH_platinclude = sysconfig.get_path('platinclude'), |
| 695 | PIPCL_SYSCONFIG_CONFIG_VAR_LIBDIR = sysconfig.get_config_var('LIBDIR'), |
| 696 | ) |
| 697 | # Tell native build to run pipcl.py itself to get python-config |
| 698 | # information about include paths etc. |
| 699 | if self.graal_legacy_python_config: |
| 700 | env_extra['PIPCL_PYTHON_CONFIG'] = f'{python_native} {os.path.abspath(__file__)} --graal-legacy-python-config' |
| 701 | |
| 702 | # Create venv. |
| 703 | venv_name = os.environ.get('PIPCL_GRAAL_NATIVE_VENV') |
| 704 | if venv_name: |
| 705 | log1(f'Graal using pre-existing {venv_name=}') |
| 706 | else: |
| 707 | venv_name = 'venv-pipcl-graal-native' |
| 708 | run(f'{shlex.quote(python_native)} -m venv {venv_name}') |
| 709 | log1(f'Graal using {venv_name=}') |
| 710 | |
| 711 | newfiles = NewFiles(f'{wheel_directory}/*.whl') |
| 712 | run( |
| 713 | f'. {venv_name}/bin/activate && python setup.py --dist-dir {shlex.quote(wheel_directory)} bdist_wheel', |
| 714 | env_extra = env_extra, |
| 715 | prefix = f'pipcl.py graal {python_native}: ', |
| 716 | ) |
| 717 | wheel = newfiles.get_one() |
| 718 | wheel_leaf = os.path.basename(wheel) |
| 719 | python_major_minor = run(f'{shlex.quote(python_native)} -c "import platform; import sys; sys.stdout.write(str().join(platform.python_version_tuple()[:2]))"', capture=1) |
| 720 | cpabi = f'cp{python_major_minor}-abi3' |
no test coverage detected