Skip to content

Switch to pyproject.toml + PEP621 #2688

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

Merged
merged 8 commits into from
May 19, 2025

Conversation

UnknownPlatypus
Copy link
Contributor

@UnknownPlatypus UnknownPlatypus commented May 18, 2025

Fixes #1570
Fixes #2641

This revives and update #1570 allowing us to use PEP621 and remove the SETUPTOOLS_ENABLE_FEATURES=legacy-editable we had to use and that broke ci recently.

The pyproject.toml was intially generated using hatch new --init and tweaked to keep existing ordering / comments.

I've checked what differs between the pypi current dist and what is build here and found the following differences:

  • we no longer ship the tests folders ( which is good ?)
  • we no longer ship the django_stubs.egg-info folder in the sdist distribution which I believe is expected since it's a setuptools artifact

Test plan

  • python -m build ext/ && python -m build
  • pip install -r ./requirements.txt && run the whole ci locally

Funding = "https://github.com/sponsors/typeddjango"
"Release notes" = "https://github.com/typeddjango/django-stubs/releases"

[tool.hatch.build]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Sort tool block alphabetically, i.e. move after [tool.codespell]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kinda want to keep it close to the rest of the package metadata since it's use to build. No strong feeling tho

@ngnpope
Copy link
Contributor

ngnpope commented May 19, 2025

Also wondering if we could replace ./scripts/stubtest.sh with hatch's scripts so that you can just run hatch run stubtest? 🤔

@UnknownPlatypus
Copy link
Contributor Author

Also wondering if we could replace ./scripts/stubtest.sh with hatch's scripts so that you can just run hatch run stubtest? 🤔

I think this should be in a separate pr and we might have to consider UV too for that.

This pr currently doesn't use hatch but only the hatchling build backend

@ngnpope
Copy link
Contributor

ngnpope commented May 19, 2025

This pr currently doesn't use hatch but only the hatchling build backend

Ah, yes, got muddled by the [tool.hatch.build] 🙃

I think this should be in a separate pr and we might have to consider UV too for that.

If you're considering uv instead, then have you thought about the uv build backend instead of hatchling?

@sobolevn
Copy link
Member

let's please not replace sh scripts with hatch 🙏
I am using sh for 15+ years now and I have no idea what hatch is.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

One last question: right now our build-and-check-metadata uses different flags from the final release

python3 -m build --sdist --wheel .
python3 -m build --sdist --wheel ext/

Is it ok? Or should we adjust python -m build flags?

@UnknownPlatypus
Copy link
Contributor Author

Is it ok? Or should we adjust python -m build flags?

I tested running python3 -m build --sdist --wheel . and python3 -m build . and got exactly the same sdist and wheel.

python3 -m build --help does say it's slightly different but recommend to not use any flags so I've removed them.

usage: python -m build [-h] [--version] [--verbose] [--sdist] [--wheel] [--outdir PATH] [--skip-dependency-check]
                       [--no-isolation | --installer {pip,uv}] [--config-setting KEY[=VALUE]]
                       [srcdir]

    A simple, correct Python build frontend.

    By default, a source distribution (sdist) is built from {srcdir}
    and a binary distribution (wheel) is built from the sdist.
    This is recommended as it will ensure the sdist can be used
    to build wheels.

    Pass -s/--sdist and/or -w/--wheel to build a specific distribution.
    If you do this, the default behavior will be disabled, and all
    artifacts will be built from {srcdir} (even if you combine
    -w/--wheel with -s/--sdist, the wheel will be built from {srcdir}).

@sobolevn sobolevn requested a review from ngnpope May 19, 2025 20:51
Copy link
Contributor

@ngnpope ngnpope left a comment

Choose a reason for hiding this comment

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

👍🏻

@sobolevn sobolevn merged commit 3899c61 into typeddjango:master May 19, 2025
37 checks passed
@sobolevn
Copy link
Member

Thanks everyone!

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

Successfully merging this pull request may close these issues.

3 participants