Poetry로 개발에서publish까지
pypi와 관련된 계정 설정 등이 없습니다.끝부분의 참고 사이트를 참조하세요.
새로 만들다
poetry new --src project_name
cd project_name
poetry install
pycharm .
# vscodeの場合
# code .
이렇게 하면 새로운 항목은pycharm에서 열리고 다음은pycharm 내 단말기에서 실행됩니다.기본 설정
단말기
poetry add -D pytest-watch pytest-mock pytest-cov
poetry shell
mv README.rst README.md
# git init -> デフォルトのブランチ名をdevにする場合
git init -b dev
# LICENSEファイルの作成
license -n atu4403 -o LICENSE mit
# .gitignoreの作成
gibo dump python >> .gitignore
LICENSE와gitignore의 제작은 CLI 도구를 사용하면 매우 편리하다License: Command line license generator
simonwhitaker/gibo: Easy access to gitignore boilerplates
local의 자체 제작 모듈을 사용하려면 상대 경로로 지정하십시오.절대 패스는 실패할 것이다.
poetry add ../moncoll/dist/moncoll-0.1.0.tar.gz
pycharm 설정
이렇게 되면 환경이 정돈되고 그 다음은 가시가시가시 개발이다.
개발 중
함수 이름이
test_
에서 시작되면 코드 블록의 왼쪽에 테스트에 사용할 재현 단추가 자동으로 표시되기 때문에 간단한 TDD/BDDpoetry run ptw --ignore tests/test_download.py
pytest-covpoetry run pytest --cov-report term-missing --cov=src/adash tests/
완성
TODO 확인
나머지 파일이 없는지 확인하려면 모든 파일을 검색
TODO:
하십시오.ci(github actions)
github actions로 ptest를 조작하는 예
.github/workflows/test.yml
.name: Test
on:
push:
pull_request:
jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- macos-11.0
- macos-latest
- windows-latest
- ubuntu-20.04
- ubuntu-latest
python-version: [ 3.8, 3.9 ]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: atu4403/poetry-setup-multi-platform@v1
- run: |
poetry install
poetry run pytest
shell: bash
name의 부분은 그대로 배지의 타이틀이 되기 때문에 해당하는 부분을 설정해야 한다.만들다
프로젝트 원본 바로 아래
__init__.py
의 시작에 주석을 추가합니다."""
.. include:: ../../README.md
"""
# 以下普通に実装
from foo import bar
적절한 디렉터리에 생성하고 확인합니다.pdoc --html --output-dir tmp --force src/{project-name}
여기 tmp
디렉터리를 만들지만git 관리가 필요하지 않기 때문에 .gitignore
에 미리 추가해야 합니다.github에서push시 자동 디버깅을 위해 제작
.github/workflows/deploy.yml
.{project-name}의 부분은 매번 설정해야 합니다.name: GitHub Pages
on:
push:
branches:
- main
pull_request:
jobs:
deploy:
runs-on: ubuntu-20.04
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Build
run: |
pip install pdoc3
pdoc --html --output-dir tmp --force src/{project-name}
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./tmp
git 연결
dev 분기 상태에서 push를 진행하여 CI(GiitHubAction)의 동작을 확인합니다.
hub create
git push -u origin dev
CI 통과 후 지금까지의 역사 기록을 삭제하고main 지점으로 정리한다.git checkout --orphan main # 履歴のない状態でmainブランチを切る
git commit -m "Initial Commit" # ステージングされた状態になるのでaddせずにcommitする
git push -u origin main
git branch --delete --force dev
git push --delete origin dev
# deleteできない場合は GitHubのsettings → branches からDefault branchをmainに変更し、再度`push —delete`する。
github actions 동작 실패 후 여러 번commiit &push 리셋 이력서 를 위해 위 의 일 을 하고 신경 쓰지 않으면 main 으로 바로 들어가도 OK공개적인 준비
pyproject.수정toml.
[tool.poetry]
name = "{project-name}"
version = "0.1.0"
description = "{project description}"
authors = ["atu4403 <[email protected]>"]
homepage = "https://github.com/atu4403"
repository = "https://github.com/atu4403/{project-name}"
readme = "README.md"
project.toml 제출 후 탭 만들기git tag v0.1.0 # 最新のコミットに対してtagを作成
git push origin --tags
testpypi에서 임시 공개
testPyPI에 대해 publish를 수행합니다.계정 생성 및 poetry config에 대해서는 참조 링크 참조
> poetry publish --build -r testpypi
https://test.pypi.org/manage/projects/에 가서 제작된 프로젝트의 페이지를 엽니다.설치용 URL이 있기 때문에 복사 후 실제 설치 & 동작 확인
> pip3 install -i https://test.pypi.org/simple/ remind-task
# 一部のpackageがインストールできない時は--extra-index-urlを設定する
> pip3 install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.python.org/pypi remind-task
Poetry install을 사용하려는 경우poetry add {url}
에도 오류가 발생할 수 있습니다.poetry run
머리에 쓰고 하면 OK.poetry run pip3 install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.python.org/pypi {project-name}
테스트PyPI로 향상된 제품에 문제가 있으면 수정 버전은 버전을 높여야 한다.pyproject.toml의version을 수정합니다.[tool.poetry]
name = "project_name"
version = "0.2.0"
GiitHub에서 CI 통과를 최종 확인한 뒤 이를 공식적으로 사용하는 PyPI로 공공연하게 종료한다.신중을 기하기 위한 동작 확인용이기 때문에 CI 통과에 문제가 없다고 판단되면 건너뛸 수 있다.
공개한다
poetry publish --build
개봉 후 pypihttps://pypi.org/project/{project-name}/
가 검색되지 않을 수 있으니 확인하세요.페이지 가져오기
github actions
actions 탭에서 최신 탭을 열고 오른쪽
...
에서 "create status badge"를 선택하면 mardown의 링크를 복사할 수 있습니다![alt](https://s1.md5.ltd/image/d41d8cd98f00b204e9800998ecf8427e.png)
pypi version
사이트 축소판 그림
명령 - Poetry documentation(일본어 번역)
Poetry를 사용한 파이썬 패키지 개발부터 PyPI 공개까지 - PYTHONIC BOOM BOOM HEAD
Reference
이 문제에 관하여(Poetry로 개발에서publish까지), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://zenn.dev/atu4403/articles/howto-poetry-dev텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)