Skip to content

feat: teach find_python_dependencies to scan pyproject.toml and uv.lock - #735

Open
irfanuddinahmad wants to merge 1 commit into
openedx:masterfrom
irfanuddinahmad:irfanuddinahmad/find-python-dependencies-pyproject-uv
Open

feat: teach find_python_dependencies to scan pyproject.toml and uv.lock#735
irfanuddinahmad wants to merge 1 commit into
openedx:masterfrom
irfanuddinahmad:irfanuddinahmad/find-python-dependencies-pyproject-uv

Conversation

@irfanuddinahmad

Copy link
Copy Markdown
Contributor

What

find_python_dependencies previously only knew how to scan pip-compile style requirements.txt files (via requirements-parser) for dependencies whose PyPI-registered homepage belongs to a "second party" org (edx-unsupported, mitodl, overhangio, open-craft, eduNEXT, raccoongang) rather than openedx itself, so they can be flagged for review/migration.

Repos migrating from pip-compile to pyproject.toml + uv per the org-wide Python packaging modernization (openedx/public-engineering#506) have no flat requirements file left for it to scan. This forced openedx-platform to disable its Check Python Dependencies workflow entirely as part of its own migration (openedx/openedx-platform#38915), rather than have it silently no-op after requirements/edx/{base,testing}.txt were removed.

This closes #725.

How

iter_requirement_names() now branches on the input file name:

  • uv.lock: reads the fully-resolved [[package]] list — this matches the same direct+transitive dependency closure a pip-compile'd requirements.txt used to represent, so it's the most faithful drop-in replacement for the old --req-file requirements/edx/base.txt usage.
  • pyproject.toml: reads [project.dependencies], [project.optional-dependencies], and [dependency-groups], resolving {include-group = "..."} references recursively.
  • anything else: falls back to the existing requirements.txt parsing, unchanged.

main() also now dedupes names-per-file before hitting the PyPI API, since [dependency-groups] commonly yields the same package name more than once via include-group.

Verification

  • Added tests/test_find_python_dependencies.py covering all three input formats plus two main()-level tests (one that should flag a second-party dependency, one that should respect --ignore).
  • Ran the new tests and the full existing suite: 97 passed.
  • Sanity-checked iter_requirement_names() directly against openedx-platform's real pyproject.toml (202 names) and uv.lock (445 names) to confirm it doesn't choke on a real-world file.

Follow-up

Once this is released, openedx-platform's check_python_dependencies.yml can point --req-file at pyproject.toml (or uv.lock) and be re-enabled (currently workflow_dispatch-only + if: false, per the comment there referencing this issue).

find_python_dependencies previously only understood pip-compile style
requirements.txt files (via requirements-parser). Repos migrating from
pip-compile to pyproject.toml + uv (openedx/public-engineering#506)
have no flat requirements file left for it to scan, which forced
openedx-platform to disable its Check Python Dependencies workflow
entirely (openedx/openedx-platform#38915, tracked in
openedx#725).

iter_requirement_names() now detects the input file by name:
- uv.lock: reads the fully-resolved [[package]] list, matching the
  same direct+transitive closure a pip-compile'd requirements.txt used
  to represent.
- pyproject.toml: reads [project.dependencies],
  [project.optional-dependencies], and [dependency-groups], resolving
  {include-group = "..."} references.
- anything else: falls back to the existing requirements.txt parsing,
  unchanged.

Verified against openedx-platform's actual pyproject.toml (202 names)
and uv.lock (445 names).

Closes openedx#725
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jul 21, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @irfanuddinahmad!

This repository is currently maintained by @openedx/axim-engineering.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 21, 2026
irfanuddinahmad pushed a commit to openedx/openedx-platform that referenced this pull request Jul 21, 2026
openedx/repo-tools#725 (find_python_dependencies needs to scan
pyproject.toml/uv.lock) now has a proposed fix at
openedx/repo-tools#735 -- linking it from the disabled-check comment
so re-enabling this workflow is easy to track once it merges/releases.
irfanuddinahmad pushed a commit to irfanuddinahmad/edx-platform that referenced this pull request Jul 27, 2026
openedx/repo-tools#725 (find_python_dependencies needs to scan
pyproject.toml/uv.lock) now has a proposed fix at
openedx/repo-tools#735 -- linking it from the disabled-check comment
so re-enabling this workflow is easy to track once it merges/releases.
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jul 27, 2026
@mphilbrick211

Copy link
Copy Markdown

@openedx/axim-engineering hi there! Would someone be able to take a look at this?

@feanil
feanil self-requested a review July 29, 2026 12:38

@feanil feanil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@irfanuddinahmad this looks good, I don't think it's valuable to parse the pyproject dependencies and also I think it may be a bit misleading. Let's drop that and bump the version and then I think this is good to merge and release.

yield from _dependency_group_names(all_groups.get(included, []), all_groups, seen)


def _names_from_pyproject_toml(data):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure how valuable this is to have. These aren't the resolved full dependencies and so if someone ran the tool against this, they might be mislead into thinking that this tool resolves all the sub-dependencies if we pass the pyproject file instead of a lock file of some sort.

At the very least, we should document that we don't resolve dependencies via the find_python_dependencies tool. But I think it might be better to only support compiled file types like the uv.lock and *.txt files. That way the intent is clear and since we're moving everything to uv.lock, we don't need this at the moment anyway so let's not add more code than we need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

find_python_dependencies: support pyproject.toml / uv.lock, not just requirements/*.txt

4 participants