Skip to content
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

automatic dependency checking for python 3 modules #53326

Closed
wants to merge 13 commits into from

Conversation

classabbyamp
Copy link
Member

@classabbyamp classabbyamp commented Dec 3, 2024

Goal: lower the incidence of missing dependencies for python module packages (like #53257), by checking what the upstream has indicated are dependencies and cross-referencing against what's been provided in the template.

Secondary goal: provide some infrastructure for decentralising shlibs tracking (working towards what paper started in #40698)

  • xbps: ignore /provides file in xbps-create
    • needed for new provides handling
    • no longer needed
  • New package: python3-flit_core-bootstrap-3.9.0
    • dependency of python3-packaging-bootstrap and python3-installer-bootstrap
  • New package: python3-installer-bootstrap-0.7.0
    • dependency of python3-installer-bootstrap
  • New package: python3-packaging-bootstrap-24.1
    • needed for parse-py-metadata script
  • common/environment/build-style/python3-*.sh: add python3-packaging-bootstrap
    • only if verifying python dependencies. needed for python module dependency verification hook
    • without this, it would be prohibitively complex to parse python module dependency notation
  • xbps-src: adjust help for -s
    • it's now used for python dependency verification too
  • common/hooks/post-install/04-create-xbps-metadata-scripts.sh: handle python bootstrap
    • several bootstrap python3 modules put packages in ${py3_sitelib}-bootstrap to prevent conflicts and keep them out of the normal PYTHONPATH. this allows the pycompile_module hook to work for those modules.
  • common/environment/setup-subpkg/subpkg: add variables for python dep verification
    • see Manual.md for usage notes
  • common/hooks: use file for managing provides
    • this will allow provides to be generated from things like package contents and saved into the file for package generation
  • common/scripts/parse-py-metadata.py: add script to parse python module metadata
    • this script uses python3-packaging-bootstrap to extract information about python modules, including their names and dependencies for use by xbps-src hooks
  • common/hooks/pre-pkg/04-generate-provides: generate provides for python modules
  • common/hooks/pre-pkg/06-verify-python-deps: add hook
    • compares rdeps and Python module metadata to find missing dependencies for python packages. this uses virtual packages to map python canonical package names to void packages.

Testing the changes

  • I tested the changes in this PR: YES (extensive testing still in progress)

Output

strict mode enabled:

image

strict mode disabled:

image

Related PRs

@classabbyamp classabbyamp added the xbps-src xbps-src related label Dec 3, 2024
@classabbyamp classabbyamp requested a review from ahesford December 3, 2024 21:34
classabbyamp added a commit to classabbyamp/xtools that referenced this pull request Dec 3, 2024
@classabbyamp classabbyamp force-pushed the python-autodeps branch 3 times, most recently from 3439667 to a010408 Compare December 4, 2024 00:21
@icp1994
Copy link
Contributor

icp1994 commented Dec 4, 2024

Is there no way to incorporate pip check rather than hand rolling the metadata verification?

@classabbyamp
Copy link
Member Author

  • I'd rather not have pip always installed
  • I don't want to do version compatibility checking
  • pip check would require installing depends on the chroot, it seems
  • introducing py3: provides has other benefits, like being able to find python modules by canonical name

ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 4, 2024
ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 4, 2024
ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 4, 2024
@ahesford
Copy link
Member

ahesford commented Dec 4, 2024

First issue: what's the suggested approach to broken builds like libxml2 when they build Python modules but don't use one of the python build styles (or helper; at least a few packages explicitly cannot use the helper because the default environment breaks their builds)? Should we

  • Force the template to explicitly skip verification;
  • Detect import failures in your dependency parser and just exit without error;
  • Force the template to manually include python3-packaging-bootstrap; or
  • Some other mechanism?

@classabbyamp
Copy link
Member Author

i think dropping a warning if it can't import packaging (so that python3-packaging-bootstrap can be manually included in the template) is the way to go

@classabbyamp
Copy link
Member Author

classabbyamp commented Dec 4, 2024

fixups add a warning if it can't import packaging (this does not get escalated with -s):
image

ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 4, 2024
Copy link
Member

@ahesford ahesford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notionally, this looks good. I'm running through full py3.13 rebuilds now and see the virtuals as expected. I can pull this patchset along with the final py3.13 merge, unless you see a reason to merge stuff piecemeal ahead of time.

I'm looking to merge py3.13 this weekend or next, and I'd like to get at least two other maintainers to sign off on this structural change before including it in the bump.

@classabbyamp
Copy link
Member Author

classabbyamp commented Dec 5, 2024

if this gets merged, I'd like to split off the xbps backport and merge that before the rest of the python bump to ensure the builders get it for their chroots

@ahesford
Copy link
Member

ahesford commented Dec 7, 2024

I think you should go ahead with the xbps merge, and ideally have xtools ready this week so we can drop the throwaway commit in this PR.

@classabbyamp
Copy link
Member Author

i have an idea for a way to do this without the xbps change

to XBPS_STATEDIR. There's no need for them to pollute PKGDESTDIR. Keep
INSTALL.msg/REMOVE.msg handling as-is for now because it's a little more
complex. Keep the pkglints for these files because xbps still ignores
them.
dependency of python3-{installer,packaging}-bootstrap
dependency of python3-packaging-bootstrap
needed for verifying python module dependencies
…otstrap

...if verifying python dependencies. needed for python module dependency
verification hook
it's now used for python dependency verification too
python bootstrap

several bootstrap python3 modules put packages in ${py3_sitelib}-bootstrap to
prevent conflicts and keep them out of the normal PYTHONPATH. this allows the
pycompile_module hook to work for those modules
this will allow provides to be generated from things like package
contents and saved into the file for package generation.
ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 7, 2024
ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 8, 2024
…e metadata

this script uses python3-packaging-bootstrap to extract information
about python modules, including their names and dependencies for use by
xbps-src hooks
compares rdeps and Python module metadata to find missing dependencies
for python packages. this uses virtual packages to map python canonical
package names to void packages.
ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 9, 2024
ahesford pushed a commit to ahesford/void-packages that referenced this pull request Dec 12, 2024
leahneukirchen pushed a commit to leahneukirchen/xtools that referenced this pull request Dec 12, 2024
@ahesford
Copy link
Member

ada7d18

@ahesford ahesford closed this Dec 14, 2024
@classabbyamp classabbyamp deleted the python-autodeps branch December 14, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
xbps-src xbps-src related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants