Closed tuanpham96 closed 10 months ago
This is a good idea. Thanks @tuanpham96. It should be a relatively easy change. I'll give it a try this week. We will have to do this in all of the NWB python packages too.
For reference, pip 23.1 is targeted for release in April 2023.
Great, thank you!
I tried somewhat on an extension I'm developing. While most fields are straightforward, the _copy_spec_files
was a bit tricky. I had to customize setuptools.build_meta
a bit.
#./pyproject.toml
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "backend"
backend-path = ["_custom_build"]
And this is the content of backend.py
inside a _custom_build
folder.
# ./_custom_build/backend.py
import os
from setuptools import build_meta as _orig
from shutil import copy2
prepare_metadata_for_build_wheel = _orig.prepare_metadata_for_build_wheel
build_wheel = _orig.build_wheel
build_sdist = _orig.build_sdist
get_requires_for_build_sdist = _orig.get_requires_for_build_sdist
def _copy_spec_files(project_dir):
# copy from original `setup.py`
def get_requires_for_build_wheel(self, config_settings=None):
# hijacking this function to copy necessary spec files
# unclear of potential side effects
_copy_spec_files(os.path.join(os.path.dirname(__file__), '..'))
return _orig.get_requires_for_build_wheel(config_settings)
It works but may not be optimized? Do you know whether pyproject.toml
has a field for pre-install/pre-build custom script?
When I do
pip install .
, I see this warning of deprecation ofsetup.py
. While I can use--use-pep517
to silence the warning, since many packages are switching topyproject.toml
anyway, I think it would be nice to start slowly migrating to it.