Passing options to setup.py from %pyproject_wheel
This came up during a fix towards making dlib builds reproducible: https://build.opensuse.org/request/show/1169495 but perhaps the issue with pyproject_wheel is more general. If the user (packager) needs to pass options to `setup.py`, as in the case of dlib where it needs to be passed `--no USE_AVX_INSTRUCTIONS` for example, it seems there is no way to pass this from the %pyproject_wheel macro and we need to revert back to the older %python_build macro instead. Actually, from my reading of the definitions in macros.python_all, specifically the snippet below: %pyproject_wheel_args \\\ --verbose --progress-bar off --disable-pip-version-check \\\ %{?py_setup_args:--build-option %{py_setup_args}} \\\ --use-pep517 --no-build-isolation \\\ --no-deps \\\ --wheel-dir %{_pyproject_wheeldir} it does seem one should be able to define the options as a macro called `py_setup_args` and they would be passed as part of the `--build-option`. However, in fact, the use of `--use-pep517` right after nullifies this — build-options are no longer passed, and I see a warning that says as much: "ignoring build-options because of --use-pep517" (I am paraphrasing). I, therefore, have two questions, if someone may be kind enough to help me: * Why allow a way to set --build-option in `%pyproject_wheel_args` if it is ignored due to `--use-pep517` anyway, and * Since --build-option cannot be set, is there a way to pass options to `setup.py` at all, or is it recommended that if such options are needed that we switch back to the older `%python_build` instead (as I did in the above sr)? Thanks in advance and best wishes, -- Atri
Hi Atri, Am 23.04.24 um 13:32 schrieb Atri Bhattacharya:
This came up during a fix towards making dlib builds reproducible: https://build.opensuse.org/request/show/1169495 but perhaps the issue with pyproject_wheel is more general.
If the user (packager) needs to pass options to `setup.py`, as in the case of dlib where it needs to be passed `--no USE_AVX_INSTRUCTIONS` for example, it seems there is no way to pass this from the %pyproject_wheel macro and we need to revert back to the older %python_build macro instead.
Actually, from my reading of the definitions in macros.python_all, specifically the snippet below:
%pyproject_wheel_args \\\ --verbose --progress-bar off --disable-pip-version-check \\\ %{?py_setup_args:--build-option %{py_setup_args}} \\\ --use-pep517 --no-build-isolation \\\ --no-deps \\\ --wheel-dir %{_pyproject_wheeldir}
it does seem one should be able to define the options as a macro called `py_setup_args` and they would be passed as part of the `--build-option`. However, in fact, the use of `--use-pep517` right after nullifies this — build-options are no longer passed, and I see a warning that says as much: "ignoring build-options because of --use-pep517" (I am paraphrasing).
I, therefore, have two questions, if someone may be kind enough to help me:
* Why allow a way to set --build-option in `%pyproject_wheel_args` if it is ignored due to `--use-pep517` anyway, and * Since --build-option cannot be set, is there a way to pass options to `setup.py` at all, or is it recommended that if such options are needed that we switch back to the older `%python_build` instead (as I did in the above sr)?
Thanks in advance and best wishes, -- Atri
We have an open issue at https://github.com/openSUSE/python-rpm-macros/issues/165 about it. Try setting the environment variable PIP_CONFIG_SETTINGS as a workaround, but I am not sure if setuptools currently ignores that setting or not. Regards, Ben
Ben Greiner wrote:
Hi Atri,
Am 23.04.24 um 13:32 schrieb Atri Bhattacharya:
This came up during a fix towards making dlib builds reproducible: https://build.opensuse.org/request/show/1169495 but perhaps the issue with pyproject_wheel is more general. If the user (packager) needs to pass options to `setup.py`, as in the case of dlib where it needs to be passed `--no USE_AVX_INSTRUCTIONS` for example, it seems there is no way to pass this from the %pyproject_wheel macro and we need to revert back to the older %python_build macro instead.
Try setting the environment variable PIP_CONFIG_SETTINGS as a workaround, but I am not sure if setuptools currently ignores that setting or not.
In this specific case, it seems to not work, but thanks for the suggestion. Perhaps it will be useful for some other package, definitely something I shall keep in mind. Cheers, -- Atri
On mar, 2024-04-23 at 11:32 +0000, Atri Bhattacharya wrote:
This came up during a fix towards making dlib builds reproducible: https://build.opensuse.org/request/show/1169495 but perhaps the issue with pyproject_wheel is more general.
If the user (packager) needs to pass options to `setup.py`, as in the case of dlib where it needs to be passed `--no USE_AVX_INSTRUCTIONS` for example, it seems there is no way to pass this from the %pyproject_wheel macro and we need to revert back to the older %python_build macro instead.
Actually, from my reading of the definitions in macros.python_all, specifically the snippet below:
%pyproject_wheel_args \\\ --verbose --progress-bar off --disable-pip-version-check \\\ %{?py_setup_args:--build-option %{py_setup_args}} \\\ --use-pep517 --no-build-isolation \\\ --no-deps \\\ --wheel-dir %{_pyproject_wheeldir}
it does seem one should be able to define the options as a macro called `py_setup_args` and they would be passed as part of the `--build-option`. However, in fact, the use of `--use-pep517` right after nullifies this — build-options are no longer passed, and I see a warning that says as much: "ignoring build-options because of --use-pep517" (I am paraphrasing).
I, therefore, have two questions, if someone may be kind enough to help me:
* Why allow a way to set --build-option in `%pyproject_wheel_args` if it is ignored due to `--use-pep517` anyway, and * Since --build-option cannot be set, is there a way to pass options to `setup.py` at all, or is it recommended that if such options are needed that we switch back to the older `%python_build` instead (as I did in the above sr)?
Looks like this issue was reported in python-rpm-macros project: https://github.com/openSUSE/python-rpm-macros/issues/165 As far as I know, in this specific case it's not possible to change the cmake arguments without calling setup.py directly, looks like it's looking for options in sys.argv directly [1], so it will never work with %pyproject_wheel. [1] https://github.com/davisking/dlib/blob/master/setup.py#L51
daniel.garcia@suse.com wrote:
On mar, 2024-04-23 at 11:32 +0000, Atri Bhattacharya wrote:
This came up during a fix towards making dlib builds reproducible: https://build.opensuse.org/request/show/1169495 but perhaps the issue with pyproject_wheel is more general. If the user (packager) needs to pass options to `setup.py`, as in the case of dlib where it needs to be passed `--no USE_AVX_INSTRUCTIONS` for example, it seems there is no way to pass this from the %pyproject_wheel macro and we need to revert back to the older %python_build macro instead.
As far as I know, in this specific case it's not possible to change the cmake arguments without calling setup.py directly, looks like it's looking for options in sys.argv directly [1], so it will never work with %pyproject_wheel.
[1] https://github.com/davisking/dlib/blob/master/setup.py#L51
Thanks, that is what I understood as well. I hope the %python_build macros will stick around for a while still, will they? Cheers, -- Atri
participants (3)
-
Atri Bhattacharya
-
Ben Greiner
-
daniel.garcia@suse.com