sample package for poetry-stabs
Project description
poetry-stabs-package-sample
パッケージ公開サンプル
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -r poetry-stabs-package-sample
型を付ける
addは型がついている、つまりちゃんとannotateしていればpyiとかpy.typedとかは必要ない
自分の理解は最初こうだったんですが mypy はこけてしまう!!
❯ mypy awesome-poetry-cache/
awesome-poetry-cache/awesome_poetry_cache/sample.py:1: error: Skipping analyzing "poetry_stabs_package_sample": module is installed, but missing library stubs or py.typed marker [import-untyped]
awesome-poetry-cache/awesome_poetry_cache/sample.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 3 source files)
https://blog.ymyzk.com/2018/09/creating-packages-using-pep-561/
テストを書く
awesome linters
documents
publish package
pypa/gh-action-pypi-publish@release/v1 を使うと公開できる、pypi とは odic で連携してるっぽいので事前に pypi の設定が必要 https://docs.github.com/ja/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-pypi
poetry publish をする
poetry に token の設定が必要
普通に公開しようとすると夏期のようなエラーが出た
❯ poetry publish --build -r testpypi
There are 2 files ready for publishing. Build anyway? (yes/no) [no] yes
Building poetry-stabs-package-sample (0.1.0)
- Building sdist
- Built poetry_stabs_package_sample-0.1.0.tar.gz
- Building wheel
- Built poetry_stabs_package_sample-0.1.0-py3-none-any.whl
Publishing poetry-stabs-package-sample (0.1.0) to testpypi
- Uploading poetry_stabs_package_sample-0.1.0-py3-none-any.whl FAILED
HTTP Error 403: Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information. | b'<html>\n <head>\n <title>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.\n \n <body>\n <h1>403 Invalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.\n Access was denied to this resource.<br/><br/>\nInvalid or non-existent authentication information. See https://test.pypi.org/help/#invalid-auth for more information.\n\n\n \n'
poetry config pypi-token.testpypi "pypi-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
通った
❯ poetry publish --build -r testpypi
There are 2 files ready for publishing. Build anyway? (yes/no) [no] yes
Building poetry-stabs-package-sample (0.1.0)
- Building sdist
- Built poetry_stabs_package_sample-0.1.0.tar.gz
- Building wheel
- Built poetry_stabs_package_sample-0.1.0-py3-none-any.whl
Publishing poetry-stabs-package-sample (0.1.0) to testpypi
- Uploading poetry_stabs_package_sample-0.1.0-py3-none-any.whl 100%
- Uploading poetry_stabs_package_sample-0.1.0.tar.gz 100%
バージョンを上げる
poetry version patch
上でバージョンを上げても github 上の ci release ではバージョンは上がらなかったので pypi 上のバージョンは git tags のバージョンに依存してそう。pyproject.toml や自動で再デプロイするとバージョンが上がるわけではなさそう
そんなことはなくて普通に pyproject.toml に依存してる。ただしpoetry buildを忘れないこと
pypi にいれる release env みたいなやつ
入れないほうが無難。
test.pypi は?
めっちゃ flakey。成功するまでリトライするとかするといいかもしれない。ghaction には現在再試行するオプションはなさそうだったので 3 回同じ文を書く脳筋実装をした
- name: publish testpypi
id: publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
continue-on-error: true
- name: retry publish testpypi
if: steps.publish.outcome == 'failure'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
continue-on-error: true
- name: retry publish testpypi (2nd attempt)
if: steps.publish.outcome == 'failure'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
continue-on-error: true
badge
https://zenn.dev/atu4403/articles/howto-poetry-dev#badge%E3%81%AE%E5%8F%96%E5%BE%97 fury.io で取得できる。今は test.pypi なのでできないけど
その他 tips
content: write を付けないと gh actions 上で該当のリポジトリへ push ができない
permissions:
contents: write
init.py で flake8 が import not used エラーを出すやつ
https://stackoverflow.com/questions/31079047/python-pep8-class-in-init-imported-but-not-used allを使える
ref
https://cylomw.hatenablog.com/entry/2021/01/19/174847 https://blog.ymyzk.com/2018/09/creating-packages-using-pep-561/
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file poetry_stabs_package_sample-0.1.8.tar.gz
.
File metadata
- Download URL: poetry_stabs_package_sample-0.1.8.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 579ef67ba24e88ad704c5990a8cb1201b50c27e064c97f31089d9f574932d972 |
|
MD5 | d4f239e93a5abe900d4be2336211c9ad |
|
BLAKE2b-256 | fe8c95d34b686c917573aaea517cee0d9b694915f8099cc88791010363e9f3c9 |
File details
Details for the file poetry_stabs_package_sample-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: poetry_stabs_package_sample-0.1.8-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/5.15.153.1-microsoft-standard-WSL2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9942f5a95380417c1c45c814b22fa083ecc8593037dfeeb809528476edd8c54 |
|
MD5 | d64cd52e8800b53a9caf58706d623a1a |
|
BLAKE2b-256 | 06fa0b393502292bce85cc49f1783f69d4dfdbb1aaaa850ad8c95abaa38fdffd |