Python
[pypi] 로컬 pypi 서버 구성 (private pypi)
kyeongjun-dev
2021. 12. 20. 18:43
pypi
PYthon Package Index의 줄임말로 pip install 명령어를 이용해 다운로드 할 때 사용되는 패키지 저장소이다.
docker 컨테이너 생성 및 구성 작업
docker 가 설치된 상태라고 가정한 뒤 실시
1. 파이썬 이미지 pull
docker pull python:3.8-slim
2. 컨테이너 실행
[root@localhost ~]# docker run -it -p 8080:8080 \
--name pypi \
python:3.8-slim \
bash
3. apt 패키지 업데이트 및 htpasswd 사용을 위한 apache2 설치
root@8ada1e11ca6c:/# apt update -y
root@8ada1e11ca6c:/# apt install -y apache2
4. htpasswd 생성
root@8ada1e11ca6c:/# cd ~
root@8ada1e11ca6c:~# htpasswd -sc htpasswd.txt kkj
New password:
Re-type new password:
Adding password for user kkj
root@8ada1e11ca6c:~# ls
htpasswd.txt
root@8ada1e11ca6c:~# cat htpasswd.txt
kkj:{SHA}WnNX3eEWa8sZP1V+bDifg0Me3kc=
pypiserver 설치 및 실행
1. pypiserver 설치
root@8ada1e11ca6c:~# pip install pypiserver
2. passlib 설치 (암호화된 password 인식에 사용)
root@8ada1e11ca6c:~# pip install passlib
3. pypiserver 실행
root@8ada1e11ca6c:~# pypi-server -p 8080 -P htpasswd.txt /packages &
4. 실행확인
pypi upload
wheel 파일을 업로드 하는 방법
1. twine 설치
pip install twine
2. twine을 이용한 파일 업로드 (링크)
twine upload zipp-3.6.0-py3-none-any.whl --repository-ur=http://192.168.122.194:8080
Uploading distributions to http://192.168.122.194:8080
Enter your username: kkj
Enter your password:
Uploading zipp-3.6.0-py3-none-any.whl
100%|███████████████████████████████████████| 11.2k/11.2k [00:00<00:00, 961kB/s]
3. 업로드된 whl 파일 확인