Skip to content

feat: support bazel (rules_python) as a PEP-517 backend #1103

Open

Description

@aarnphm

🚀 feature request

Probably very low priority, but having support for pyproject.toml would be awesome. Maybe for the first pass rules_python can support parsing [project] and other fields as metadata

Relevant Rules

py_wheel

Description

A clear and concise description of the problem or missing capability...

Describe the solution you'd like

An example pyproject.toml:

[build-system]
requires = ["setuptools>=65", "setuptools_scm[toml]>=7", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "my_project"
description = "description"
readme = { file = "README.md", content-type = "text/markdown" } # P1?
requires-python = ">=3.8"
version = "0.0.1"
classifiers = [
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "License :: OSI Approved :: Apache Software License",
    "Operating System :: POSIX :: Linux",
    "Topic :: Scientific/Engineering",
    "Topic :: Scientific/Engineering :: Mathematics",
    "Topic :: Scientific/Engineering :: Artificial Intelligence",
    "Topic :: Software Development",
    "Topic :: Software Development :: Libraries",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Programming Language :: Python",
    "Programming Language :: Python :: 3 :: Only",
    "Programming Language :: Python :: 3.8",
    "Programming Language :: Python :: 3.9",
    "Programming Language :: Python :: 3.10",
    "Programming Language :: Python :: 3.11",
]

and its corresponding rule:

py_wheel(
  name = "my_wheel",
  pyproject_toml = "://pyproject.toml"
)

Describe alternatives you've considered.

I can contribute the implementation upstream if this makes sense. I believe we already have tomli available so it should be relatively straightforward for implementation.

Activity

  1. github-actions commented on Aug 26, 2023

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
    Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!

  2. aarnphm commented on Aug 27, 2023

    @aarnphm
    Author

    Any update on this?

    cc @rickeylev

  3. groodt commented on Aug 27, 2023

    @groodt
    Contributor

    Can you describe why this would be useful?

    When a wheel is built and distributed (via PyPI or alternative artifact repositories) the pyproject.toml file is not leveraged by package installers.

  4. aarnphm commented on Aug 27, 2023

    @aarnphm
    Author

    https://peps.python.org/pep-0621/

    The PEP describe the current generation of Python packaging system. A lot of these components help streamline Python project, and a lot of Python packages has adopted this (i.e numpy, scipy, pandas, and so on).

    This makes it for a repo that setup pyproject.toml to set up adoption with bazel. We are evaluating bazel as build tool to make it consistent across our multiple projects.

  5. groodt commented on Aug 27, 2023

    @groodt
    Contributor

    I think I understand what you’re asking for. Are you asking for support of specifying the third-party dependencies of the project? Then the issue description isn’t clear.

    The only table in PEP-621 that would be relevant for consumption via the rules would be the dependencies table. Possibly requires_python.

    The current mechanism for consuming third-party dependencies in the rules would be pip_parse or compile_pip_requirements. py_wheel is for building wheels.

  6. aarnphm commented on Aug 27, 2023

    @aarnphm
    Author

    Right, sorry for not making it clear. I think in terms of implementation rules_python will need to be able to parse requires_python and build_system in order to compile the wheel. Python specific build system such as hatch, flit, pdm has PEP517-compatible format designed for packaging.

    I believe the currently limitation for rules_python is that it depends on setuptools iirc. So in order to support pyproject, rules_python might need to add build to support parsing this pyproject.toml

    additionally, all of the metadata can be used with distribution and wheel metadata generation.

    I don't think this is specifically for parsing third-party dependencies.

  7. groodt commented on Aug 27, 2023

    @groodt
    Contributor

    Got it. So you want bazel to be usable as a PEP-517 compatible build backend?

  8. changed the title [-]feat(wheel): support pyproject.toml[/-] [+]feat: support bazel (rules_python) as a PEP-517 backend[/+] on Nov 20, 2023
  9. github-actions commented on May 18, 2024

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had any activity for 180 days. It will be closed if no further activity occurs in 30 days.
    Collaborators can add an assignee to keep this open indefinitely. Thanks for your contributions to rules_python!

  10. github-actions commented on Jun 17, 2024

    @github-actions
    Contributor

    This issue was automatically closed because it went 30 days without a reply since it was labeled "Can Close?"

  11. reopened this on Dec 2, 2024
  12. aignas commented on Dec 7, 2024

    @aignas
    Collaborator

    I think @nicholasjng has created something of interest to address this ticket https://github.com/nicholasjng/bazelbuild

  13. removed
    Can Close?Will close in 30 days if there is no new activity
    on Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions