-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
packaging: add ANSIBLE_PEP517_BUILD_MANPAGES envvar #80363
Conversation
The test
|
) | ||
build_manpages_requested = True # FIXME: Once pypa/build#559 is addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this work-around is being removed, we might as well remove the --build-manpages
option entirely, since it's not functional. The package-data
sanity test, as well as the canonical-pep517-self-packaging
integration test will need to be updated to use the env var as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add `ANSIBLE_PEP517_BUILD_MANPAGES` envvar to internal pyproject build backend to control whether or not to build manpages `build` does not pass config_settings to `get_requires_build_sdist()`, and some tooling (e.g. Fedora's pyproject-rpm-macros) doesn't support passing config_settings down to `build_sdist()` either. This commit adds a fallback to $ANSIBLE_PEP517_BUILD_MANPAGES when the `--build-manpages` config setting isn't passed to the backend. It also removes the workaround that unconditionally enables building manpages.
If this change is merged, it should probably be backported. However, the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for bringing my attention to this! The migration to the standardized PEP 517 in-tree build backend is intended to bring us closer to what the wider Python community is used to, removing all the crutches and cruft we used to have. This allows providing standard interface for building our distributions, should one need to. Although, most pip users would not go through this process and would rely on the built wheels anyway.
The downstream packaging ecosystems also standardize around the same interface nowadays which allows for better interoperability and lower maintenance burden.
I also noticed that this patch will not work for you because:
- The spec file uses
pyproject_wheel
which is essentially a call topip wheel
. - Our in-tree PEP 517 build backend only generates manpages for sdists but not for wheels. Moreover, it would be pointless to run manpage generation when building wheels since the manpages are located outside of the Python importable packages and don't make it inside the wheel files.
pyproject-rpm-macros
do not implement building sdists — they expect building wheels right from the source distribution which you're not even using currently. OTOH, it would be correct to build from sdists which would go through the same path aspip install src-dir
— building an sdist, followed by building a wheel out of that sdist and not from the source checkout.- You use
make PYTHON=%{python3} docs
on the download directory. This would've never been necessary, if you were to just use our official sdists that already ship these manpages...
That said I don't think that this approach is acceptable since it reinvents the wheel abusing the environment side-effects outside the PEP 517 standard, plus it essentially reverses the progress we've made. For example, PEP 517 does not declare any guarantees that the build front-ends should provide access to outer env vars. The only configuration interface is config_settings
, under the standard.
If some downstream front-ends have bugs in this area, they should be fixed instead of trying to build layers of hacks around this.
Besides, this is not an obstacle for Fedora packaging. With, #80255 our official upstream packages don't make use of the in-tree build backend and bundle the manpages. Anybody using those sdists, will get them without needing to generate the manpage files from jinja2 templates.
This means that you can even delete related build deps like https://src.fedoraproject.org/rpms/ansible-core/blob/de2bcead78ad982ed54ac78089120b4b1e59b319/f/ansible-core.spec#_51
I see that the specfile uses Git archives for some mysterious reason: https://src.fedoraproject.org/rpms/ansible-core/blob/de2bcead78ad982ed54ac78089120b4b1e59b319/f/ansible-core.spec#_14. Instead, it's best to rely on the official upstream source distributions rather than the unstandardized source archives.
Just change it as follows:
Source: https://github.com/ansible/ansible/archive/v%{uversion}/%{name}-%{uversion}.tar.gz
Source: %{pypi_source}
And it should do the trick (along with deleting now-unnecessary BuildRequires: python%{python3_pkgversion}-straight-plugin
, BuildRequires: python%{python3_pkgversion}-docutils
and getting rid of make PYTHON=%{python3} docs
)
If you really want to keep building from Git checkout, you can use the same trick I did here: https://github.com/ansible/ansible/pull/80357/files#diff-cb62aeaa58754404408ea0c07b30aca399edff7a282c6465a06e0ade1969ef36R14-R19 — add pypa/build to the build deps, pre-build an sdist using the proper build command and then, feed it to your macros.
Finally, you could also make a local patch file and apply it within your RPM infra. Although, it'd probably do nothing based on my observations above, you seem to have suggested this PR based on fundamentally incorrect assumptions.
P.S. It's sad that pyproject-rpm-macros
doesn't seem to support passing config_settings
to build backends which is why it's a good opportunity to ask them for the implementation. It shouldn't be hard to accept an extra option and pass it around. Other downsteam distributions support it, for example gpep517 >= 3
accepts --config-json
.
Correct, it won't work for us. I explained this in #80368. I realized part way through writing the patch that this was the case, but I figured I'd submit the PR regardless. This solution is better than the nonfuctional
I suggested building the manpages and including them in the wheel's
Maybe it's not part of the standard, but I don't know of any frontend/build tool that doesn't pass env vars down to the backend. Other build backends such as hatchling liberally use env vars for configuration. Meanwhile, config_settings is not supported properly in setuptools (pypa/setuptools#2491) and it isn't fully supported by all build tools. However, we established that this doesn't impact anyone other than upstream's releases to PyPI, so I won't push too hard for this.
I chose to use the Github archive, as I'd prefer to build the manpages from source rather than rely on pre-generated files. I only prefer PyPI sdists when packaging projects that use setuptools_scm, as setuptools_scm does not work well with Github archives (some of these issues have been fixed recently, so I may reconsider).
This is definitely a step back. You should not have to build an sdist and extract files from it just to render manpages. We already extract the source archive once. I respect having the backend automatically include these in sdists, but that should not be the only way to generate manpages Also, your solution doesn't work. The
I agree. I will discuss this with the maintainer. |
With my PyPA hat on, I'd argue that anything that tries to skip the standard and rely on undocumented side-effects is not better but worse, by definition 🤷♂️
This feature is controversial and undesired in general. Knowing that It was clearly marked as deprecated in the setuptools docs in 2021. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-data-files.
You also seem incorrect about the install prefix. It's been pointed out in pypa/setuptools#2648, for example. Also, this test in pip https://github.com/pypa/pip/blob/fded808c8cab13e9fef65f3ac8256ec37a27d743/tests/functional/test_install_wheel.py#L218-L245 suggests that they go somewhere closer to A lot of discussions over the years call this feature misleading:
Besides, even with
The point still stands, relying on side-effects is not the best option. When the build tools fix their problems, they should implement the standard and not a set of random assumptions various packaged distributions decided to make. FWIW, env vars is a factor that have a potential to contribute to non-reproducible builds and weird side-effects. So maybe, it's worth improving the standard asking the front-ends to put protections in place even.
You can easily replace I disagree that it's a step back, not for us. Using internal build helpers worked in non-official environments by accident. I don't think it was ever documented to be guaranteed. We used to have different downstream packaging definitions right in this repository but got rid of them at some point. I've checked how different downstreams package ansible-core and none seem to have a problem relying on the official source distribution, instead of the source archive. We don't even test the usability of said Git archives — in fact, we've been saying people not to use them for as long as I can remember (I personally wish, we'd switched to setuptools-scm even; but because of certain limitations said Git archives did not always work as intended). This means, that we'd be forced to maintain an extra way of doing the same thing, special-casing patches for Fedora upstream basically. It sounds like shifting the maintenance burden back to upstream. I also imagine that Fedora wouldn't notify us when it's possible to remove the hacks when they stop using them and migrate to using the proper build flow, right? So it may hang in here forever... |
Closing per #80368 (comment) |
Summary
Add
ANSIBLE_PEP517_BUILD_MANPAGES
envvar to internal pyproject build backend to control whether or not to build manpagesISSUE TYPE
COMPONENT NAME
packaging
ADDITIONAL INFORMATION
build
does not pass config_settings toget_requires_build_sdist()
, and some tooling (e.g. Fedora's pyproject-rpm-macros) doesn't support passing config_settings down tobuild_sdist()
either.This commit adds a fallback to $ANSIBLE_PEP517_BUILD_MANPAGES when the
--build-manpages
config setting isn't passed to the backend. It also removes the workaround that unconditionally enables building manpages./cc @webknjaz