Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Build & release to PyPI via trusted publishing#148

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
hugovk merged 9 commits intopython:mainfromhugovk:main
Oct 1, 2023

Conversation

hugovk
Copy link
Member

@hugovkhugovk commentedAug 20, 2023
edited
Loading

We discussed in the last monthly docs meeting to automate PyPI deploys using the new "Trusted Publishing", and the consensus was it's a good idea:

This would make releasing easier, and also open the release process to other core devs with the commit bit.

Here's a PR to set up the workflow, we'll also need to set up trusted publishing on TestPyPI and PyPI.


This workflow does three things:

image

It is based on@hynek's neathttps://github.com/python-attrs/attrs/blob/main/.github/workflows/pypi-package.yml, which I'm successfully using in my own projects.

1.

For all runs, it builds and lints the PyPI sdist and wheel. This makes sure the non-publishing steps are working smoothly, ahead of uploading. It uses@hynek's excellenthttps://github.com/hynek/build-and-inspect-python-package action, which creates a nice summary, for example:

image

We can see it creates three handy zips if we want to check what would be uploaded to PyPI, and three handy toggles that show the contents. Try it here:

https://github.com/python/python-docs-theme/actions/runs/5919197594?pr=148

2.

For commits tomain we publish to TestPyPI. This helps us know the publishing process is nicely oiled to avoid surprises on release day. It uses the packages that were already created in step 1.

3.

For published GitHub releases we publish to the real PyPI. Also uses packages created in step 1.


TODO

screenshotimage

@willingc I see you're the only maintainer forhttps://test.pypi.org/project/python-docs-theme/, please could you set up the above for TestPyPI? It's probably a good opportunity to add some extra owners/maintainers such as@Mariatta, to improve the bus factor.

@willingc You're also one of the maintainers forhttps://pypi.org/project/python-docs-theme/, so perhaps you could do PyPI too?

Copy link
Member

@AA-TurnerAA-Turner left a comment

Choose a reason for hiding this comment

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

I've reviewed this back-to-front -- sorry. I'm a tad uncertain if we should be going with this though. Overarching thoughts:

  • I think that the 'check the package is alright' step could happen via a linting run, e.g. just runningtwine check, which avoids the kerfuffle with uploading artefacts & to Test PyPI
  • On Test PyPI, I'm unconvinced that we should use it for every commit -- we know that the package works, and there are limited resources on Test PyPI, even if the distribution is small, so I think we ought be conservative in what we upload.
  • I'm unsure what's behindhynek/build-and-inspect-python-package -- whilst I could go and look it up, it adds a layer of indirection when (to my understanding) this workflow should be replicating the release steps one would run locally -- e.g.python -m build; twine upload. Making it explicit what's going on I think is useful to observability and just having fewer moving parts in general (I'd have the same objection topypa/gh-action-pypi-publish, save that it implements the OIDC flow for us).

Sorry again for several comments, but I hope this outlines my position to some extent.

A

@hugovk
Copy link
MemberAuthor

  • I think that the 'check the package is alright' step could happen via a linting run, e.g. just runningtwine check, which avoids the kerfuffle with uploading artefacts & to Test PyPI

There is no linter that does all the checks that PyPI does.

twine check only does a subset of the checks. I've seen packages passtwine check yet fail to upload.

It's no kerfuffle, this PR adds automation so machines take care of it for us. 🤖

@hugovk
Copy link
MemberAuthor

hugovk commentedAug 21, 2023
edited
Loading

  • On Test PyPI, I'm unconvinced that we should use it for every commit -- we know that the package works, and there are limited resources on Test PyPI, even if the distribution is small, so I think we ought be conservative in what we upload.

We only know for sure the package works and can be uploaded by uploading it.

These pure Python packages are very small, especially when compared to those with C extensions which may have 60+ multi-MB wheels.

Resources are indeed limited on TestPyPI, and I doubt we'll ever reach the project limit. If we do, we can safely delete old uploads.

Disregard, removed:#148 (comment)

@hugovk
Copy link
MemberAuthor

  • I'm unsure what's behindhynek/build-and-inspect-python-package -- whilst I could go and look it up, it adds a layer of indirection when (to my understanding) this workflow should be replicating the release steps one would run locally -- e.g.python -m build; twine upload. Making it explicit what's going on I think is useful to observability and just having fewer moving parts in general (I'd have the same objection topypa/gh-action-pypi-publish, save that it implements the OIDC flow for us).

I find the build and content summaries can be useful. It does lots of extra lint checks beyondtwine check. It makes packages avaliable before upload, so we can test them locally if we like.

Best of all, we don't need to maintain it! We can benefit from@hynek and other contributors maintaining and improving it. We can also re-use it in other repos without duplicating all the extra checks across our repos.

(Here's the source:https://github.com/hynek/build-and-inspect-python-package)

@hugovk
Copy link
MemberAuthor

I removed the TestPyPI upload because we hardcode the version and that would have meant the second and subsequent uploads would fail because youcannot reuse filenames on PyPI.

I don't want to expand the scope to propose using something likehatch-vcs orsetuptools_scm in this PR, it's more important to get trusted publishing in place. 👍

AA-Turner reacted with thumbs up emoji

@hugovkhugovk marked this pull request as ready for reviewAugust 26, 2023 08:53
@AA-Turner
Copy link
Member

AA-Turner commentedAug 26, 2023
edited
Loading

Thanks for your patience with my questions--excited to see trusted publishing enabled forpython-docs-theme!

A

hugovk reacted with hooray emoji

@willingc
Copy link
Contributor

@hugovk I'm just re-engaging with core development a bit more now that I'm semi-retired. Let me know what you need me to do re: pypi. Thanks.

hynek, hugovk, and pradyunsg reacted with hooray emoji

@hugovk
Copy link
MemberAuthor

Congrats on the semi-retirement!

  1. Log in to pypi.org
  2. Go tohttps://pypi.org/manage/project/python-docs-theme/settings/publishing/
  3. Add a new publisher by filling in the form like this (leave the last env name box blank):
image

That's it!

pradyunsg reacted with heart emoji

@willingc
Copy link
Contributor

@hugovk Thanks for the great instructions. It's now completed. ✨

AA-Turner and pradyunsg reacted with hooray emoji

@hugovk
Copy link
MemberAuthor

Thank you!

Let's merge this now, and I can try out a release with#153 next week, after 3.12 is out.

willingc reacted with thumbs up emoji

@hugovkhugovk merged commit3f48c0c intopython:mainOct 1, 2023
@hugovk
Copy link
MemberAuthor

Success!

I merged#153, updated version and changelog in#157 and followed these steps (which I'll update inCONTRIBUTING.md):

The tag/release:

The CI build and deploy:

Screenshot

image

Screenshot

image

The release on PyPI:

hynek and ezio-melotti reacted with rocket emoji

@hugovkhugovk mentioned this pull requestOct 4, 2023
@hugovk
Copy link
MemberAuthor

(which I'll update inCONTRIBUTING.md):

Please see PR#158.

@Mariatta
Copy link
Member

Great work. Thanks!

hugovk reacted with thumbs up emoji

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

@ezio-melottiezio-melottiezio-melotti left review comments

@pradyunsgpradyunsgpradyunsg approved these changes

@AA-TurnerAA-TurnerAA-Turner approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@hugovk@AA-Turner@willingc@Mariatta@pradyunsg@ezio-melotti

[8]ページ先頭

©2009-2025 Movatter.jp