자신의 pip 소스 구축

3383 단어
보안 요인 으로 인해 기업 내 대부분의 서버 가 외부 네트워크 에 접근 할 수 없습니다. 이러한 서 비 스 는 일부 python package 를 설치 하 는 수요 가 있 을 수 있 기 때문에 기업 의 개인 적 인 pypi 소스 를 구축 할 필요 가 있 습 니 다.Bandersnatch 는 pypi 소스 를 동기 화 하 는 도구 로 홈 페이지 의 모든 패 키 지 를 다운로드 하고 동기 화 하 며 마지막 으로 nginx 에서 발표 합 니 다.
  • 300 G 이상 의 저장 공간 준비
  • bandersnatch: 원본 의 모든 패 키 지 를 로 컬 로 다운로드
  • nginx: 로 컬 pypi 발표
  • 1.Installation
    pip 로 설치:
    $ pip install bandersnatch
    

    원본 코드 로 설치:
    $ wget https://pypi.python.org/packages/source/b/bandersnatch/bandersnatch-1.5.tar.gz
    $ tar -zxvf bandersnatch-1.5.tar.gz
    $ cd bandersnatch-1.5
    $ python setup.py install
    

    2.Configure
    프로필 생 성 / etc / bandersnatch. conf.
    $ bandersnatch mirror
    2014-09-15 09:37:30,631 WARNING: Config file '/etc/bandersnatch.conf' missing, creating default config.
    2014-09-15 09:37:30,631 WARNING: Please review the config file, then run 'bandersnatch' again.
    

    / etc / bandersnatch. conf 는 실제 상황 에 따라 다음 두 가지 설정 을 중점적으로 수정 합 니 다. directory 는 package 가 로 컬 에 저 장 된 위 치 를 말 합 니 다. master 는 동기 화 된 원본 을 말 합 니 다.
    [mirror]
    ; The directory where the mirror data will be stored.
    directory = /srv/pypi
    
    ; The PyPI server which will be mirrored.
    ; master = https://testpypi.python.org
    ; scheme for PyPI server MUST be https
    master = https://pypi.python.org
    

    3.Download & Synchronize
    모든 package 를 로 컬 로 다운로드:
    $ bandersnatch -c /etc/bandersnatch.conf mirror
    2014-01-15 09:49:26,556 INFO: bandersnatch/1.5 (CPython 2.7.6-final0, Linux 3.19.0-37-generic x86_64)
    2014-01-15 09:49:26,558 INFO: Setting up mirror directory: /srv/pypi/
    2014-01-15 09:49:26,559 INFO: Setting up mirror directory: /srv/pypi/web/simple
    2014-01-15 09:49:26,560 INFO: Setting up mirror directory: /srv/pypi/web/packages
    2014-01-15 09:49:26,560 INFO: Setting up mirror directory: /srv/pypi/web/local-stats/days
    2014-01-15 09:49:26,561 INFO: Generation file missing. Reinitialising status files.
    ......
    

    로 컬 pacakge 업데이트:
    $ bandersnatch -c /etc/bandersnatch.conf mirror
    2014-09-15 09:54:35,813 INFO: bandersnatch/1.5 (CPython 2.7.6-final0, Linux 3.19.0-37-generic x86_64)
    2014-09-15 09:54:35,814 INFO: Status file missing. Starting over.
    2014-09-15 09:54:35,814 INFO: Syncing with https://pypi.python.org.
    2014-09-15 09:54:35,815 INFO: Current mirror serial: 0
    2014-09-15 09:54:35,815 INFO: Resuming interrupted sync from local todo list.
    

    4.Config nginx
    설치 nginx:
    $ apt-get install nginx
    

    / etc / nginx / sites - available / default 와 / etc / nginx / sites - available / default 설정 은 다음 과 같 습 니 다.
    server {
        listen *:80;
        server_name pypi_server;
        root /srv/pypi/web;
        autoindex on;
        charset utf-8;
    }
    

    시작 nginx:
    $ /etc/init.d/nginx start
    

    5.Test
    클 라 이언 트 pip 설정:
    $ cat ~/.pip/pip.conf
    [global]
    index-url = http:///simple
    

    테스트 는 다음 과 같 습 니 다:
    $ pip install apasvo
    Downloading/unpacking apasvo
      http:///simple/apasvo/ uses an insecure transport scheme (http). Consider using https if  has it available
      Downloading APASVO-0.0.5-py2-none-any.whl (226kB): 226kB downloaded
    ......
    

    좋은 웹페이지 즐겨찾기