Skip to content

Comments

chore(sdk): migrate build system to pyproject.toml (#12245)#12840

Open
Anchit-04 wants to merge 1 commit intokubeflow:masterfrom
Anchit-04:chore/migrate-sdk-to-pyproject-toml
Open

chore(sdk): migrate build system to pyproject.toml (#12245)#12840
Anchit-04 wants to merge 1 commit intokubeflow:masterfrom
Anchit-04:chore/migrate-sdk-to-pyproject-toml

Conversation

@Anchit-04
Copy link

I have migrated the Python SDK from the old setup.py to the modern pyproject.toml using hatchling as the build backend. This is part of the modernization task for issue #12245.

List of Changes I have made:

  1. Orchestrated metadata migration by creating pyproject.toml, which acts as the new blueprint for project metadata and entrypoints
  2. Added docstring-parser and kfp-server-api to the dependencies list. These are essential for the cli to function properly
  3. updated protobuf requirement to >=3.13.0 to support runtime checks found in recent generated artifacts
  4. Reduced setup.py to a standard shim that delegates all build responsibilities to the hatchling backend while preserving compatibility for pip install -e . workflows.

Checklist:

Signed-off-by: Anchit <anchit1234deshpande@gmail.com>
Copilot AI review requested due to automatic review settings February 17, 2026 12:43
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mprahl for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions
Copy link

🎉 Welcome to the Kubeflow Pipelines repo! 🎉

Thanks for opening your first PR! We're excited to have you onboard 🚀

Next steps:

Feel free to ask questions in the comments.

@google-oss-prow
Copy link

Hi @Anchit-04. Thanks for your PR.

I'm waiting for a kubeflow member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the sdk/python (KFP Python SDK) packaging configuration toward a PEP 517/518 + PEP 621 workflow by introducing pyproject.toml with hatchling as the build backend, while attempting to keep setup.py present for legacy workflows.

Changes:

  • Added sdk/python/pyproject.toml with project metadata, dependencies, entry points, and hatch versioning.
  • Updated sdk/python/setup.py to add an additional setup() invocation under __main__.
  • Declared optional dependency groups (extras) and console scripts in pyproject.toml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
sdk/python/setup.py Adds a setup() call intended to support legacy invocation paths.
sdk/python/pyproject.toml Introduces hatchling-based build config and moves metadata/dependencies into PEP 621 format.

Comment on lines +113 to +115

if __name__ == "__main__":
setup()
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

setup.py currently invokes setuptools.setup(...) at import time and then calls setup() again under if __name__ == "__main__". When setup.py is executed by build/install tooling, this results in two setup() invocations in one process, which can cause failures or undefined behavior during packaging.

Suggested fix:

  • Remove the second setup() call, or refactor the file into a true shim (i.e., avoid calling setuptools.setup(...) unconditionally and delegate to the PEP 517 backend instead).
Suggested change
if __name__ == "__main__":
setup()

Copilot uses AI. Check for mistakes.
Comment on lines 19 to 21
import setuptools
from setuptools import setup

Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

from setuptools import setup is only used for the new setup() call under __main__. If the intent is to keep setuptools.setup(...) as the single entrypoint (or to turn this file into a shim), this import should be removed to avoid confusion and accidental double-setup behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +46
"urllib3 < 2.0.0",
"protobuf >= 3.13.0",
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The dependency set in pyproject.toml does not match the SDK’s existing published requirements (requirements.in / requirements.txt) that setup.py currently installs. This will make PEP 517 builds (from pyproject.toml) install a materially different dependency set than legacy installs/editables, and is likely to break runtime imports.

Concrete issues in this block:

  • kfp-pipeline-spec and google-api-core are missing even though the code imports kfp.pipeline_spec.* and prior requirements pin google-api-core.
  • Several bounds differ from the established constraints (e.g., protobuf lowered to >=3.13.0 vs requirements.in’s protobuf>=6.31.1,<7.0, urllib3<2.0.0 vs <3.0.0, requests-toolbelt upper bound, kubernetes upper bound).

Suggested fix:

  • Make pyproject.toml dependencies identical to requirements.in (including environment markers and upper bounds), or adopt a single source of truth (e.g., drive both from one file/tool) to avoid divergence.
Suggested change
"urllib3 < 2.0.0",
"protobuf >= 3.13.0",
"urllib3 < 3.0.0",
"protobuf >= 6.31.1, < 7.0",
"kfp-pipeline-spec",
"google-api-core",

Copilot uses AI. Check for mistakes.
]

[project.optional-dependencies]
kubernetes = ["kfp-kubernetes"]
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

The kubernetes extra previously pinned kfp-kubernetes to the exact SDK version (see setup.py’s kfp-kubernetes=={_version}), which helps keep the extension layer compatible with the installed SDK. In pyproject.toml it is now unpinned ("kfp-kubernetes"), which can lead to installing an incompatible kfp-kubernetes version.

Suggested fix:

  • Restore an explicit compatible version constraint for kfp-kubernetes (ideally aligned to the SDK versioning policy used elsewhere in the repo), rather than leaving it unconstrained.
Suggested change
kubernetes = ["kfp-kubernetes"]
kubernetes = ["kfp-kubernetes >= 2.0.0, < 3.0.0dev"]

Copilot uses AI. Check for mistakes.
]
docker = ["docker"]
all = [
"kfp[kubernetes,notebooks,docker]"
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

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

all = ["kfp[kubernetes,notebooks,docker]"] makes the project’s all extra depend on the same project again with different extras. This self-referential dependency can confuse resolvers and is avoidable; the prior setup.py expands all to the union of the extra dependency lists directly.

Suggested fix:

  • Expand all to directly list the union of dependencies from kubernetes, notebooks, and docker instead of referencing kfp[...].
Suggested change
"kfp[kubernetes,notebooks,docker]"
"kfp-kubernetes",
"nbclient >= 0.10, < 1",
"ipykernel >= 6, < 7",
"jupyter_client >= 7, < 9",
"docker",

Copilot uses AI. Check for mistakes.
@hbelmiro
Copy link
Contributor

This probably should be synced with #12770.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants