24년 02월의 공부 - pypi 패키지 업로드
포스트
취소

24년 02월의 공부 - pypi 패키지 업로드

2024년 2월 동안 검색하고 공부한 것들을 정리한 내용입니다.

pypi 패키지 업로드

패키지 빌드

1
2
# pip install setuptools wheel
python3 setup.py sdist bdist_wheel

패키지 업로드

1
2
# pip install twine
python3 -m twine upload dist/*

에러 1. keyring.errors.NoKeyringError

twine 패키지 버전을 5.0.0에서 2.0.0 버전으로 다운그레이드하여 해결했습니다.

1
2
3
4
5
6
7
> Uploading distributions to https://upload.pypi.org/legacy/
WARNING  Error getting password from keyring                                                                                                                                   
         Traceback (most recent call last):                                                                                                                                    
           ...                                                                                                                                         
         keyring.errors.NoKeyringError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want
         to use the non-recommended backends. See https://pypi.org/project/keyring for details.                                                                                
Enter your API token:

에러 2. HTTPError: 403 Client Error

pypi의 Account settings의 하단 ‘api-token’ 발급을 통해 해결했습니다. api-token 발급을 위해서는 2차 인증 설정이 필요합니다.

1
> HTTPError: 403 Client Error: Username/Password authentication is no longer supported. Migrate to API Tokens or Trusted Publishers instead. See https://pypi.org/help/#apitoken and https://pypi.org/help/#trusted-publishers for url: https://upload.pypi.org/legacy/

토큰 발급 이후 아래와 같이 id는 __token__으로, 암호는 발급받은 토큰값을 입력하면 됩니다.

1
2
3
python3 -m twine upload dist/*
> Enter your username: __token__
> Enter your password: {api-token}
이 기사는 저작권자의 CC BY 4.0 라이센스를 따릅니다.