-
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
Integrate manpage builds into PEP 517 build backend #79606
Integrate manpage builds into PEP 517 build backend #79606
Conversation
d6f8b5d
to
195e874
Compare
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.
I am not knowledgeable enough to +1 the code implementation, but the idea behind it. Anything that can be baked in the code directly, rather than needing documentation is a big +1
e604bf8
to
c13ce75
Compare
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.
I'm not opposed to this in principle, but it does feel like a slippery slope in some ways- back to the bad old days of custom DistUtils commands that we're still cleaning up in other projects 😆 . But there's definitely some benefit in being able to have declarative (and dynamic) build deps that we can test, so I'm like +0.75 for the overall thing if we can make it a little more robust.
rst_in.unlink() | ||
|
||
rst2man_cmd = ( | ||
sys.executable, |
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.
Why not just do this inline in our interpreter with docutils.core.publish_file
(or one of the other ones that takes string input, since we've already read the source in to hack on it anyway)? Locating the wrapper script that basically does the same thing feels brittle...
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.
Because I was converting a series of calls across makefiles and wasn't implementing this from scratch. So I never checked what APIs are available. FWIW, I was trying to scope this effort to reproduce what makefiles do w/o changes, so it's easier to verify that it's doing the same thing. Optimization/refactoring could be a separate PR IMO.
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.
This appears to do the same thing sans subprocess, script and intermediate file:
from docutils.core import publish_file
from docutils.writers import manpage
from io import StringIO
templated_rst_doc = rst_in.read_text().replace('%VERSION%', version_number)
rst_in.unlink()
publish_file(source=StringIO(templated_rst_doc), destination_path=rst_in.with_suffix('').with_suffix(''), writer=manpage.Writer())
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.
@nitzmahone still, I wouldn't want to couple refactoring of the manpage builds with the packaging aspects. How do you feel about having this in a separate PR?
P.S. Pro tip: StringIO
/BytesIO
should be used as context managers, otherwise, they need to be closed explicitly to clean up the resources correctly. This is not always a problem, but is a nice principle to follow for consistency with other I/O interactions.
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.
I may be mostly projecting my own behavior here 😉, but "I'll fix it later" will probably be written on my tombstone. I can live with it "as-is", but would definitely like to see it simplified with direct calls and fewer/no writes into the source tree at some point.
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.
For me, it may end up being a never-ending PR refactoring that needs more and more testing, though. It'll end up blocked for longer this way.
def _make_in_tree_ansible_importable(): | ||
"""Add the library directory to module lookup paths.""" | ||
lib_path = str(Path.cwd() / 'lib/') | ||
os.environ['PYTHONPATH'] = lib_path # NOTE: for subprocesses |
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.
This probably wouldn't be necessary if the docutils publish was called directly instead of as a subprocess (see below)
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.
Can we agree to move this to a separate PR?
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.
I'm fine with making this change in another PR.
a83a258
to
a12ac37
Compare
I rewrote the smoke testing in Python and tightened the pins. With this, It think that they main blocking concerns are addressed now. I'd like to keep things that are out of the scope separate. |
test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt
Outdated
Show resolved
Hide resolved
test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt
Outdated
Show resolved
Hide resolved
test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt
Outdated
Show resolved
Hide resolved
ffc6434
to
6747d70
Compare
4619aea
to
9cd3989
Compare
@mattclay I think this is ready for the next round of reviews. |
This patch creates a thin wrapper around the `setuptools`' PEP 517 build backend in-tree. It features an ability to request generating the manpage files in the process of building a source distribution. This toggle is implemented using the `config_settings` mechanism of PEP 517. One must explicitly pass it a CLI option to the build front-end to trigger said behavior. Roughly, the packagers are expected to use the following call: python -m build --config-setting=--build-manpages This option has no effect on building wheels. Co-authored-by: Matt Clay <matt@mystile.com>
This test runs building and re-building sdists and wheels with and without the `--build-manpages` config setting under the oldest-supported and new `setuptools` pinned. It is intended to preserve the interoperability of the packaging setup across Python runtimes. Co-authored-by: Matt Clay <matt@mystile.com>
9cd3989
to
38c4d22
Compare
test/integration/targets/canonical-pep517-self-packaging/minimum-build-constraints.txt
Outdated
Show resolved
Hide resolved
Co-authored-by: Matt Clay <matt@mystile.com>
SUMMARY
This patch creates a thin wrapper around the
setuptools
' PEP 517 build backend in-tree. It features an ability to request generating the manpage files in the process of building a source distribution. This toggle is implemented using theconfig_settings
mechanism of PEP 517.One must explicitly pass it a CLI option to the build front-end to trigger said behavior. Roughly, the packagers are expected to use the following call:
This option has no effect on building wheels.
Related to: #79469 (comment)
ISSUE TYPE
COMPONENT NAME
packaging/pep517_backend
pyproject.toml
setup.cfg
ADDITIONAL INFORMATION