이름 | 설명 |
---|---|
버전 | 2.2.0 |
날짜: | 2024-09-15 |
원천 | https://github.com/pypiserver/pypiserver |
pypi | https://pypi.org/project/pypiserver/ |
테스트 | https://github.com/pypiserver/pypiserver/actions |
관리자 | @ankostis , @mplanchard , @dee-me-tree-or-love , @pawamoy , 새로운 사람? 우리는 새로운 관리자에게 열려 있습니다! #397 |
특허 | zlib/libpng + mit |
지역 사회 | https://pypiserver.zulipchat.com |
팁
토론 에 연락하거나 Zulip 에서 우리와 채팅
Pypiserver는 PIP 또는 Easy_Install을 위한 최소 PYPI 호환 서버입니다. 병을 기반으로하며 일반 디렉토리의 패키지를 제공합니다. 휠, BDIST, 계란 및 수반되는 PGP-SIGNATURE는 PIP , Setupools , Twine , PYPI-Uploader 또는 SCP를 간단히 복사하여 업로드 할 수 있습니다.
메모
공식 소프트웨어 전원 PYPI는 창고입니다. 그러나 창고는 pypi.org 의 자체 소프트웨어로 상당히 전문적이며 다른 상황에서는 사용해서는 안됩니다. 특히, 자체 패키지를 제공하려는 사용자가 사용자 정의 패키지 색인으로 공식적으로 사용하는 것은 공식적으로 지원하지 않습니다.
PypiserVer는 PYPI와 동일한 인터페이스를 구현하여 PIP 및 Twine 과 같은 표준 Python 패키징 툴링이 PYPI와 마찬가지로 패키지 인덱스로 상호 작용할 수 있도록하는 동시에 실행중인 인덱스 서버를 쉽게 얻을 수 있도록합니다.
목차
Pypiserver는 Python 3.6+ 및 Pypy3에서 작동합니다.
구형 파이썬 버전은 여전히 작동 할 수 있지만 테스트되지 않았습니다.
레거시 파이썬 버전의 경우 pypiserver-1.x 시리즈를 사용하십시오. 이들은 공식적으로 지원되지 않으며 버그 수정 또는 새로운 기능을받지 못합니다.
팁
아래 명령은 POSIX 쉘이있는 UNIX와 같은 운영 체제에서 작동합니다. '~' 문자는 사용자의 홈 디렉토리로 확장됩니다.
Windows를 사용하는 경우 "Windows 상대방"을 사용해야합니다. 이 문서의 나머지 부분에 대해서도 마찬가지입니다.
이 명령으로 pypiserver를 설치하십시오
pip install pypiserver # Or: pypiserver[passlib,cache]
mkdir ~ /packages # Copy packages into this directory.
[! 팁] 대체 설치 방법도 참조하십시오
~/패키지 폴더에 일부 패키지를 복사 한 다음 PypiserVer를 업데 링하십시오.
pypi-server run -p 8080 ~ /packages & # Will listen to all IPs.
클라이언트 컴퓨터에서 이것을 입력하십시오
# Download and install hosted packages.
pip install --extra-index-url http://localhost:8080/simple/ ...
# or
pip install --extra-index-url http://localhost:8080 ...
# Search hosted packages.
pip search --index http://localhost:8080 ...
# Note that pip search does not currently work with the /simple/ endpoint.
[! 팁] 지루한 타이핑을 피하기위한 클라이언트 측정도 참조하십시오.
CMD 라인에 pypi-server -h를 입력하여 자세한 사용 메시지를 인쇄하십시오.
usage: pypi-server [-h] [-v] [--log-file FILE] [--log-stream STREAM]
[--log-frmt FORMAT] [--hash-algo HASH_ALGO]
[--backend {auto,simple-dir,cached-dir}] [--version]
{run,update} ...
start PyPI compatible package server serving packages from PACKAGES_DIRECTORY. If PACKAGES_DIRECTORY is not given on the command line, it uses the default ~/packages. pypiserver scans this directory recursively for packages. It skips packages and directories starting with a dot. Multiple package directories may be specified.
positional arguments:
{run,update}
run Run pypiserver, serving packages from
PACKAGES_DIRECTORY
update Handle updates of packages managed by pypiserver. By
default, a pip command to update the packages is
printed to stdout for introspection or pipelining. See
the `-x` option for updating packages directly.
optional arguments:
-h, --help show this help message and exit
-v, --verbose Enable verbose logging; repeat for more verbosity.
--log-file FILE Write logging info into this FILE, as well as to
stdout or stderr, if configured.
--log-stream STREAM Log messages to the specified STREAM. Valid values are
stdout, stderr, and none
--log-frmt FORMAT The logging format-string. (see `logging.LogRecord`
class from standard python library)
--hash-algo HASH_ALGO
Any `hashlib` available algorithm to use for
generating fragments on package links. Can be disabled
with one of (0, no, off, false).
--backend {auto,simple-dir,cached-dir}
A backend implementation. Keep the default 'auto' to
automatically determine whether to activate caching or
not
--version show program's version number and exit
Visit https://github.com/pypiserver/pypiserver for more information
CMD 라인에 pypi-server run -h를 입력하여 자세한 사용법을 인쇄하십시오.
usage: pypi-server run [-h] [-v] [--log-file FILE] [--log-stream STREAM]
[--log-frmt FORMAT] [--hash-algo HASH_ALGO]
[--backend {auto,simple-dir,cached-dir}] [--version]
[-p PORT] [-i HOST] [-a AUTHENTICATE]
[-P PASSWORD_FILE] [--disable-fallback]
[--fallback-url FALLBACK_URL]
[--health-endpoint HEALTH_ENDPOINT] [--server METHOD]
[-o] [--welcome HTML_FILE] [--cache-control AGE]
[--log-req-frmt FORMAT] [--log-res-frmt FORMAT]
[--log-err-frmt FORMAT]
[package_directory [package_directory ...]]
positional arguments:
package_directory The directory from which to serve packages.
optional arguments:
-h, --help show this help message and exit
-v, --verbose Enable verbose logging; repeat for more verbosity.
--log-file FILE Write logging info into this FILE, as well as to
stdout or stderr, if configured.
--log-stream STREAM Log messages to the specified STREAM. Valid values are
stdout, stderr, and none
--log-frmt FORMAT The logging format-string. (see `logging.LogRecord`
class from standard python library)
--hash-algo HASH_ALGO
Any `hashlib` available algorithm to use for
generating fragments on package links. Can be disabled
with one of (0, no, off, false).
--backend {auto,simple-dir,cached-dir}
A backend implementation. Keep the default 'auto' to
automatically determine whether to activate caching or
not
--version show program's version number and exit
-p PORT, --port PORT Listen on port PORT (default: 8080)
-i HOST, -H HOST, --interface HOST, --host HOST
Listen on interface INTERFACE (default: 0.0.0.0)
-a AUTHENTICATE, --authenticate AUTHENTICATE
Comma-separated list of (case-insensitive) actions to
authenticate (options: download, list, update;
default: update).
Any actions not specified are not authenticated, so
to authenticate downloads and updates, but allow
unauthenticated viewing of the package list, you would
use:
pypi-server -a 'download, update' -P
./my_passwords.htaccess
To disable authentication, use:
pypi-server -a . -P .
See the `-P` option for configuring users and
passwords.
Note that when uploads are not protected, the
`register` command is not necessary, but `~/.pypirc`
still needs username and password fields, even if
bogus.
-P PASSWORD_FILE, --passwords PASSWORD_FILE
Use an apache htpasswd file PASSWORD_FILE to set
usernames and passwords for authentication.
To allow unauthorized access, use:
pypi-server -a . -P .
--disable-fallback Disable the default redirect to PyPI for packages not
found in the local index.
--fallback-url FALLBACK_URL
Redirect to FALLBACK_URL for packages not found in the
local index.
--health-endpoint HEALTH_ENDPOINT
Configure a custom liveness endpoint. It always
returns 200 Ok if the service is up. Otherwise, it
means that the service is not responsive.
--server METHOD Use METHOD to run the server. Valid values include
paste, cherrypy, twisted, gunicorn, gevent, wsgiref,
and auto. The default is to use "auto", which chooses
one of paste, cherrypy, twisted, or wsgiref.
-o, --overwrite Allow overwriting existing package files during
upload.
--welcome HTML_FILE Use the contents of HTML_FILE as a custom welcome
message on the home page.
--cache-control AGE Add "Cache-Control: max-age=AGE" header to package
downloads. Pip 6+ requires this for caching.AGE is
specified in seconds.
--log-req-frmt FORMAT
A format-string selecting Http-Request properties to
log; set to '%s' to see them all.
--log-res-frmt FORMAT
A format-string selecting Http-Response properties to
log; set to '%s' to see them all.
--log-err-frmt FORMAT
A format-string selecting Http-Error properties to
log; set to '%s' to see them all.
PYPI-Server 업데이트 에 대한 자세한 내용
usage: pypi-server update [-h] [-v] [--log-file FILE] [--log-stream STREAM]
[--log-frmt FORMAT] [--hash-algo HASH_ALGO]
[--backend {auto,simple-dir,cached-dir}] [--version]
[-x] [-d DOWNLOAD_DIRECTORY] [-u]
[--blacklist-file IGNORELIST_FILE]
[package_directory [package_directory ...]]
positional arguments:
package_directory The directory from which to serve packages.
optional arguments:
-h, --help show this help message and exit
-v, --verbose Enable verbose logging; repeat for more verbosity.
--log-file FILE Write logging info into this FILE, as well as to
stdout or stderr, if configured.
--log-stream STREAM Log messages to the specified STREAM. Valid values are
stdout, stderr, and none
--log-frmt FORMAT The logging format-string. (see `logging.LogRecord`
class from standard python library)
--hash-algo HASH_ALGO
Any `hashlib` available algorithm to use for
generating fragments on package links. Can be disabled
with one of (0, no, off, false).
--backend {auto,simple-dir,cached-dir}
A backend implementation. Keep the default 'auto' to
automatically determine whether to activate caching or
not
--version show program's version number and exit
-x, --execute Execute the pip commands rather than printing to
stdout
-d DOWNLOAD_DIRECTORY, --download-directory DOWNLOAD_DIRECTORY
Specify a directory where packages updates will be
downloaded. The default behavior is to use the
directory which contains the package being updated.
-u, --allow-unstable Allow updating to unstable versions (alpha, beta, rc,
dev, etc.)
--blacklist-file IGNORELIST_FILE, --ignorelist-file IGNORELIST_FILE
Don't update packages listed in this file (one package
name per line, without versions, '#' comments
honored). This can be useful if you upload private
packages into pypiserver, but also keep a mirror of
public packages that you regularly update. Attempting
to pull an update of a private package from `pypi.org`
might pose a security risk - e.g. a malicious user
might publish a higher version of the private package,
containing arbitrary code.
명령 줄에 항상 PYPI URL을 지정하는 것은 약간 번거 롭습니다. PypiserVer는 요청 된 패키지가없는 경우 pip/easy_install을 pypi.org 인덱스로 리디렉션하므로 항상 로컬 PYPI 인덱스를 사용하도록 구성하는 것이 좋습니다.
PIP 명령의 경우 .bashr/.profile/.zshrc 에서 환경 변수 PIP_EXTRA_INDEX_URL을 설정하여 수행 할 수 있습니다.
export PIP_EXTRA_INDEX_URL=http://localhost:8080/simple/
또는 다음 줄을 ~/.pip/pip.conf 에 추가합니다
[global]
extra-index-url = http://localhost:8080/simple/
메모
HTTPS 없이 원격 URL에 pypiserver를 설치 한 경우 PIP 로부터 "신뢰할 수없는"경고를 받게되므로 -신뢰할 수있는 호스트 옵션을 추가 할 것을 촉구합니다. 구성 파일 또는 환경 변수 에이 옵션을 영구적으로 포함시킬 수도 있습니다.
Easy_Install 명령의 경우 ~/.pydistutils.cfg 에서 다음 구성을 설정할 수 있습니다.
[easy_install]
index_url = http://localhost:8080/simple/
패키지를 서버 폴더 (즉, SCP 와 함께)에 직접 복사하는 대신 작업에 Python 도구를 사용하여 Python Setup.py 업로드를 사용할 수 있습니다. 이 경우 Pypiserver는 업로드 요청을 인증 할 책임이 있습니다.
메모
업로드를 암호로 보호하는 것이 좋습니다!
업로드에 대한 인증을 비활성화 할 수 있습니다 (예 : 인트라 넷). 게으른 보안 결정을 피하려면 -p 및 -a 옵션에 대한 도움말을 읽으십시오.
먼저 PassLib 모듈이 설치되어 있는지 확인하십시오 ( PassLib> = 1.6 이 필요함). -P , -Passwords 옵션 (다음 단계 참조)으로 지정된 Apache Htpasswd 파일을 구문 분석하는 데 필요합니다.
pip install passlib
이 명령과 함께 하나 이상의 사용자/비밀번호 쌍으로 Apache Htpasswd 파일을 만듭니다 (암호가 메시지가 표시됩니다).
htpasswd -sc htpasswd.txt < some_username >
팁
Windows 에서 htpasswd
CMD를 실행하기위한이 질문을 읽거나 내부 서비스 (보안 관점에서 여전히 "나쁘다"고 생각하기 때문에 신경 쓰지 않는 가짜 비밀번호가있는 경우이 공개를 사용할 수 있습니다. 서비스
팁
API를 통해 PypiserVer에 액세스 할 때 Auther Config 플래그를 통해 대체 인증 방법을 사용할 수 있습니다. 부울을 반환 할 수있는 모든 호출 가능한 부울은 사용자 정의 인증을 제공하기 위해 PypiserVer 구성으로 전달할 수 있습니다. 예를 들어, Python-Pam을 사용하여 PypiserVer를 인증하도록 구성하려면
import pam
pypiserver.default_config(auther=pam.authenticate)
자세한 내용은 Using Ad-hoc authentication providers
참조하십시오.
-P 옵션으로 서버를 다시 시작해야합니다 (그러나 사용자/비밀번호 쌍이 나중에 추가하거나 즉시 업데이트 할 수 있습니다).
./pypi-server run -p 8080 -P htpasswd.txt ~ /packages &
클라이언트 측에서 비슷한 내용이있는 ~/.pypirc 파일을 편집하거나 만듭니다.
[distutils]
index-servers =
pypi
local
[pypi]
username: < your_pypi_username >
password: < your_pypi_passwd >
[local]
repository: http://localhost:8080
username: < some_username >
password: < some_passwd >
그런 다음 Python-Project의 디렉토리 내에서 업로드하려는 경우이 명령을 발행하십시오.
python setup.py sdist upload -r local
디스크에 비밀번호를 저장하지 않으려면 명확한 텍스트로 다음 중 하나 일 수 있습니다.
-R 옵션과 함께 Register SetupTools 의 명령을 사용하십시오.
python setup.py sdist register -r local upload -r local
두 단계로 절차를 중단하는 꼬기 라이브러리를 사용하십시오. 또한 PGP-Signatures로 파일에 서명하고 생성 된 .ASC 파일을 pypiserver ::에 업로드하는 것이 지원됩니다.
twine upload -r local --sign -identity user_name ./foo-1.zip
버전 1.2.5부터 시작하여 공식 Docker 이미지는 각각의 main
, 각 Dev, Alpha 또는 베타 릴리스 및 각 최종 릴리스마다 구축됩니다. 가장 최근의 풀 릴리스는 TAG 최신 으로 항상 사용할 수 있으며 현재 main
브랜치는 항상 태그에서 사용할 수 없습니다 .
Docker Repo 에서 현재 사용할 수있는 태그를 확인할 수 있습니다.
Docker와 함께 Pypiserver 의 가장 최근 릴리스를 실행하려면 간단히
docker run pypiserver/pypiserver:latest run
이것은 컨테이너 포트 8080에서 청취하여 컨테이너 내부의 /data /packages 디렉토리에서 Pypiserver 서빙 패키지를 시작합니다.
컨테이너는 항상 8080이되는 내부 컨테이너 포트 ( -p )를 제외하고는 일반 PYPI -Server 실행 파일과 동일한 인수를 취합니다.
물론 컨테이너를 실행하는 것은 그다지 흥미롭지 않습니다. 호스트의 포트 80을 컨테이너의 포트 8080에 매핑하려면 ::
docker run -p 80:8080 pypiserver/pypiserver:latest run
이제 LocalHost : 80 에서 웹 브라우저에서 pypiserver 에 액세스 할 수 있습니다.
호스트의 디렉토리에서 패키지를 제공하려면 ~/패키지
docker run -p 80:8080 -v ~ /packages:/data/packages pypiserver/pypiserver:latest run
로컬 .htpasswd 파일에 대해 인증하려면 ::
docker run -p 80:8080 -v ~ /.htpasswd:/data/.htpasswd pypiserver/pypiserver:latest run -P .htpasswd packages
ComposeFile을 사용하여 Docker 서비스로 실행하도록 pypiserver를 지정할 수도 있습니다. 예제 ComposeFile은 docker-compose.yaml
로 제공됩니다
아래 방법을 시도 할 때 먼저 다음 명령을 사용하여 이전 버전의 PypiserVer가 이미 존재하는지 확인하고 (선택적으로) 제거하십시오.
# VERSION-CHECK: Fails if not installed.
pypi-server --version
# UNINSTALL: Invoke again until it fails.
pip uninstall pypiserver
PYPI 의 최신 버전이 사전 릴리스 인 경우 PIP 의 -PRE 옵션을 사용해야합니다. 기존 설치를 업데이트하려면이를 결합하여 --ignore-installed
pip install pypiserver --pre -I
길 에 GIT가 설치되어 있다고 가정하면 다음 명령으로 GitHub 에서 직접 최신 PypiserVer를 설치할 수도 있습니다.
pip install git+git://github.com/pypiserver/pypiserver.git
PYPI-Server 명령에는 사용 가능한 패키지의 업데이트를 검색하는 업데이트 명령이 있습니다. PIPI.org에서 사용 가능한 패키지 및 검색을 위해 패키지 디렉토리를 스캔하여 업데이트를 위해 스캔합니다. 추가 옵션이 없으면 PYPI-Server 업데이트는 각 패키지의 최신 버전을 얻기 위해 실행 해야하는 명령 목록 만 인쇄합니다. 출력은 다음과 같습니다.
$ ./pypi-server update
checking 106 packages for newer version
.........u.e...........e..u.............
.....e..............................e...
..........................
no releases found on pypi for PyXML, Pymacs, mercurial, setuptools
# update raven from 1.4.3 to 1.4.4
pip -q install --no-deps --extra-index-url https://pypi.org/simple/ -d /home/ralf/packages/mirror raven==1.4.4
# update greenlet from 0.3.3 to 0.3.4
pip -q install --no-deps --extra-index-url https://pypi.org/simple/ -d /home/ralf/packages/mirror greenlet==0.3.4
PYPI에서 사용 가능한 버전을 확인한 후 각 패키지에 대해 먼저 각 패키지에 대해 인쇄합니다. 도트 (.)는 패키지가 최신임을 의미하고 'U'는 패키지를 업데이트 할 수 있고 'e' 는 PYPI의 릴리스 목록이 비어 있음을 의미합니다. 그 후 하나의 패키지를 업데이트하는 데 사용할 수있는 PIP 명령 줄이 표시됩니다. 해당 명령을 실제로 실행하려면 PYPI -SERVER UPDATE -X를 복사하여 붙여 넣기 또는 실행하십시오. 그러나 작동하려면 PIP를 설치해야합니다.
추가 -U 옵션을 지정하면 알파, 베타 및 릴리스 후보도 다운로드 할 수 있습니다. 이 옵션이 없으면이 릴리스는 고려되지 않습니다.
중요한
기본적으로 Pypiserver는 들어오는 HTTP 요청이 발생할 때마다 전체 패키지 디렉토리를 스캔합니다. 소수의 패키지에는 문제가되지 않지만 수천 패키지를 제공 할 때 눈에 띄는 속도가 저하됩니다.
이 문제가 발생하면 PypiserVer의 디렉토리 캐싱 기능을 활성화하여 상당한 속도를 높일 수 있습니다. 유일한 요구 사항은 Watchdog 패키지를 설치하는 것입니다. 또는 Cache Extras 옵션을 지정하여 PypiserVer 설치 중에 설치할 수 있습니다.
pip install pypiserver[cache]
Webserver의 내장 캐싱 기능을 사용하여 추가 스피드 업을 얻을 수 있습니다. 예를 들어, Behind a reverse proxy
아래에 설명 된대로 nginx
역 프로파일로 사용하는 경우 캐싱을 쉽게 활성화 할 수 있습니다. 예를 들어, Nginx가 최대 1 시간 동안 최대 10 기가 바이트의 데이터를 캐시하도록 허용합니다.
proxy_cache_path /data/nginx/cache
levels=1:2
keys_zone=pypiserver_cache:10m
max_size=10g
inactive=60m
use_temp_path=off ;
server {
# ...
location / {
proxy_cache pypiserver_cache ;
proxy_pass http://localhost:8080 ;
}
}
팁
Webserver 캐싱 사용은 요청 볼륨이 높은 경우 특히 유용합니다. Nginx 캐싱을 사용하여 실제 Pypiserver 설치는 피크 하중에서 1000 개가 넘는 패키지 다운로드/분을 쉽게 지원할 수있었습니다.
시스템 시작시 PypiserVer의 자동 시작을 처리하기위한 다양한 옵션이 있습니다. 가장 일반적인 두 가지는 Linux 시스템의 SystemD 및 Supervisor 입니다. Windows의 경우 스크립트가있는 서비스를 작성하는 것은 NSSM 과 같은 타사 도구가 없으면 쉬운 작업이 아닙니다.
SystemD는 대부분의 최신 Linux 시스템에 기본적으로 설치되므로 PypiserVer 프로세스를 관리하기위한 훌륭한 옵션입니다. SystemD 의 예제 구성 파일은 아래를 참조하십시오.
[Unit]
Description=A minimal PyPI server for use with pip/easy_install.
After=network.target
[Service]
Type=simple
# systemd requires absolute path here too.
PIDFile=/var/run/pypiserver.pid
User=www-data
Group=www-data
ExecStart=/usr/local/bin/pypi-server run -p 8080 -a update,download --log-file /var/log/pypiserver.log -P /etc/nginx/.htpasswd /var/www/pypi
ExecStop=/bin/kill -TERM $MAINPID
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
WorkingDirectory=/var/www/pypi
TimeoutStartSec=3
RestartSec=5
[Install]
WantedBy=multi-user.target
경로를 조정하고 PypiserVer.Service 로이 파일을 SystemD/System 디렉토리에 추가하면 SystemCTL , 예를 들어 PypiserVer 프로세스를 관리 할 수 있습니다.
SystemD 에 대한보다 유용한 정보는 https://www.digitalocean.com/community/tutorials/how-to-us-systemctl-to-manage-systemd-services-and-units를 참조하십시오.
감독자는 순수한 파이썬 패키지라는 이점을 가지고 있으며, 따라서 프로세스 관리에 대한 탁월한 크로스 플랫폼 지원을 제공합니다. 감독자 의 예제 구성 파일은 다음과 같습니다
[program:pypi]
command=/home/pypi/pypi-venv/bin/pypi-server run -p 7001 -P /home/pypi/.htpasswd /home/pypi/packages
directory=/home/pypi
user=pypi
autostart=true
autorestart=true
stderr_logfile=/var/log/pypiserver.err.log
stdout_logfile=/var/log/pypiserver.out.log
거기에서 프로세스는 SupervisorCTL을 사용하여 Supervisord를 통해 관리 할 수 있습니다.
Windows의 경우 https://nsssm.cc에서 nssm을 프로그램 파일과 같은 원하는 위치로 다운로드하십시오. win32
또는 win64
사용할 것인지 결정하고 해당 exe
환경 PATH
에 추가하십시오.
start_pypiserver.bat을 만듭니다
pypi-server run -p 8080 C: P ath T o P ackages &
팁
서비스를 작성하기 전에 배치 파일을 먼저 실행하여 테스트하십시오. 서버에 원격으로 액세스하고 패키지를 설치할 수 있는지 확인하십시오. 가능하다면, 가능할 때까지 문제를 해결하지 않으면 진행하십시오. 이렇게하면 NSSM을 믹스에 추가하기 전에 서버가 작동하는 것을 알 수 있습니다.
명령 프롬프트에서
nssm install pypiserver
이 명령은 NSSM GUI 응용 프로그램을 시작합니다
Path: C: P ath T o s tart_pypiserver.bat
Startup directory: Auto generates when selecting path
Service name: pypiserver
더 많은 탭이 있지만 이것이 기본 설정입니다. 특정 로그인 자격 증명으로 서비스를 실행 해야하는 경우 로그온 탭에 해당 자격 증명을 입력해야합니다.
서비스를 시작하십시오
nssm start pypiserver
팁
다른 유용한 명령
nssm --help
nssm stop < servicename >
nssm restart < servicename >
nssm status < servicename >
자세한 정보는 https://nssm.cc를 방문하십시오
많은 WSGI 서버를 지원하는 병 웹 서버, 특히 페이스트 , 체리 , 트위스트 및 WSGiref (파이썬의 일부); -서버 플래그를 사용하여 선택합니다.
다음 대화 형 코드를 사용하여 지원되는 모든 WSGI 서버를 볼 수 있습니다.
>> > from pypiserver import bottle
>> > list ( bottle . server_names . keys ())
[ 'cgi' , 'gunicorn' , 'cherrypy' , 'eventlet' , 'tornado' , 'geventSocketIO' ,
'rocket' , 'diesel' , 'twisted' , 'wsgiref' , 'fapws3' , 'bjoern' , 'gevent' ,
'meinheld' , 'auto' , 'aiohttp' , 'flup' , 'gae' , 'paste' , 'waitress' ]
위의 서버 중 어느 것도 귀하의 요구와 일치하지 않는 경우, 서버를 시작하지 않고 내부 WSGI-APP을 반환하는 pypiserver : app () 메소드 만 호출하십시오. 그러면 원하는 WSGI 서버로 보낼 수 있습니다. API 섹션을 사용하여 읽으십시오.
몇 가지 예는 다음과 같습니다. 병 사이트에서 자세한 내용을 찾을 수 있습니다.
pypiserver 와 함께 apache2를 사용하려면 병의 문서에 설명 된대로 mod_wsgi를 사용하는 것이 좋습니다.
메모
대신 mod_proxy 와 함께 가기로 선택한 경우 접두사 경로로 문제가 발생할 수 있습니다 ( #155 참조).
다음 APACHE 구성을 최상위 범위 또는 일부 <VirtualHost>
(Thomas Waldmann에 의해 기여)에 적응하고 배치하십시오.
WSGIScriptAlias / /yoursite/wsgi/pypiserver-wsgi.py
WSGIDaemonProcess pypisrv user=pypisrv group=pypisrv umask=0007
processes=1 threads=5 maximum-requests=500
display-name=wsgi-pypisrv inactivity-timeout=300
WSGIProcessGroup pypisrv
WSGIPassAuthorization On # Required for authentication (https://github.com/pypiserver/pypiserver/issues/288)
< Directory /yoursite/wsgi >
Require all granted
< /Directory >
또는 오래된 아파치 <2.4를 사용하는 경우 마지막 부분을 다음과 같이 대체하십시오.
< Directory /yoursite/wsgi >
Order deny,allow
Allow from all
< /Directory >
그런 다음 /yoursite/cfg/pypiserver.wsgi 파일을 작성하고 WSGIDAEMOMEMONPROCESS 지침의 사용자 와 그룹 에 읽은 권한 이 있는지 확인하십시오.
import pypiserver
conf = pypiserver . default_config (
root = "/yoursite/packages" ,
password_file = "/yoursite/htpasswd" , )
application = pypiserver . app ( ** conf )
[! tip] VirtualEnV에 pypiserver를 설치 한 경우 mod_wsgi 의 지침을 따르고 위의 Python 코드를 다음과 함께 준비하십시오.
import site site . addsitedir ( '/yoursite/venv/lib/pythonX.X/site-packages' )
메모
보안상의 이유로, 디렉토리 지시문은 WSGI 시작 스크립트를 보유한 디렉토리에 대한 액세스를 만듭니다. 다른 것은 없습니다.
메모
Apache에서 HTTPS 지원을 활성화하려면 SSL을 사용하기위한 WSGI 구성이 포함 된 지침을 구성하십시오.
다음 명령은 Gunicorn을 사용하여 PypiserVer를 시작합니다
gunicorn -w4 ' pypiserver:app(root="/home/ralf/packages") '
또는 여러 뿌리를 사용할 때
gunicorn -w4 ' pypiserver:app(root=["/home/ralf/packages", "/home/ralf/experimental"]) '
페이스트는 다른 URL 경로에서 여러 WSGI 응용 프로그램을 실행할 수 있습니다. 따라서 다른 경로에서 다른 패키지 세트를 제공 할 수 있습니다.
다음 예제 Paste.ini는 다른 경로에서 안정적이고 불안정한 패키지를 제공하는 데 사용될 수 있습니다.
[composite:main]
use = egg:Paste#urlmap
/unstable/ = unstable
/ = stable
[app:stable]
use = egg:pypiserver#main
root = ~ /stable-packages
[app:unstable]
use = egg:pypiserver#main
root = ~ /stable-packages
~ /unstable-packages
[server:main]
use = egg:gunicorn#main
host = 0.0.0.0
port = 9000
workers = 5
accesslog = -
메모
다음과 같이 작동하려면 더 많은 종속성을 설치해야합니다.
pip install paste pastedeploy gunicorn pypiserver
서버는 시작할 수 있습니다
gunicorn_paster paste.ini
리버스 프록시 뒤에 PypiserVer를 실행할 수도 있습니다.
nginx 구성을 확장하십시오
upstream pypi {
server pypiserver.example.com:12345 fail_timeout=0 ;
}
server {
server_name myproxy.example.com ;
location / {
proxy_set_header Host $host : $server_port ;
proxy_set_header X-Forwarded-Proto $scheme ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_pass http://pypi ;
}
}
Pypiserver 1.3에서 리버스 프록시 구성에서 X-Forwarded-Host
헤더를 사용하여 기본 URL을 변경할 수 있습니다. 예를 들어 서버의 특정 경로에서 pypiserver를 호스팅하려는 경우
upstream pypi {
server localhost:8000 ;
}
server {
location /pypi/ {
proxy_set_header X-Forwarded-Host $host : $server_port /pypi ;
proxy_set_header X-Forwarded-Proto $scheme ;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_pass http://pypi ;
}
}
리버스 프록시를 사용하는 것이 HTTPS 뒤에 pypiserver를 얻는 선호하는 방법입니다. 예를 들어, nginx
사용하여 자동 HTTP 리디렉션을 사용하여 포트 443의 HTTPS 뒤에 pypiserver를 넣으려면
upstream pypi {
server localhost:8000 ;
}
server {
listen 80 default_server ;
server_name _ ;
return 301 https:// $host$request_uri ;
}
server {
listen 443 ssl ;
server_name pypiserver.example.com ;
ssl_certificate /etc/star.example.com.crt ;
ssl_certificate_key /etc/star.example.com.key ;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 ;
ssl_ciphers HIGH: ! aNULL: ! MD5 ;
location / {
proxy_set_header Host $host : $server_port ;
proxy_set_header X-Forwarded-Proto $scheme ;
proxy_set_header X-Real-IP $remote_addr ;
proxy_pass http://pypi ;
}
}
팁
자세한 내용은 Nginx의 HTTPS 문서를 참조하십시오.
CertBot 및 LetSencrypt를 사용하여 인증서를 얻고 최신 상태로 유지하면 단순화 할 수 있습니다.
Docker Compose를 사용하여 자동 HTTP 리디렉션을 통해 Pypiserver를 포트 443의 HTTPS 뒤에 배치하기 위해 Traefik을 사용하는 것도 가능합니다. 자세한 내용은 제공된 Docker-Compose.yml 예제를 참조하십시오.
Ad-Hoc 인증 제공자를 활성화하거나 Bottle Out-of-the-Box에서 지원하지 않는 WSGI 서버를 사용하려면 API를 통해 PypiserVer를 시작해야합니다.
pypiserver를 구성하기위한 메인 엔트리 포인트는 pypiserver : app () 함수입니다. 이 함수는 내 내부 WSGI-App을 반환합니다.
모든 pypiserver : app () 키워드 및 설명을 얻으려면 pypiserver : default_config ()를 읽으십시오.
마지막으로, 구성된 앱으로 WSGI-Server를 발사하려면 병을 호출하십시오 : run (앱, 호스트, 포트, 서버) 기능. Pypiserver는 자체 병 사본을 배송합니다. 그것을 사용하려면 그것을 가져 오기 : pypiserver import 병에서 가져옵니다.
pypiserver : app () 함수의 자동 키워드는 API를 사용 하여만 설정할 수 있습니다. 주어진 요청에 대한 사용자 이름 과 비밀번호를 전달할 때 부울을 반환하는 호출 가능.
예를 들어, UNIX의 /etc /passwd 파일을 기반으로 사용자를 인증하려면 다음 단계에 따라 이러한 결정을 Python-Pam 라이브러리에 위임 할 수 있습니다.
Python-Pam 모듈이 설치되었는지 확인하십시오
pip install python-pam
이 라인을 따라 파이썬 스크립트를 만듭니다
$ cat > pypiserver-start.py
import pypiserver
from pypiserver import bottle
import pam
app = pypiserver.app(root= ' ./packages ' , auther=pam.authenticate)
bottle.run(app=app, host= ' 0.0.0.0 ' , port=80, server= ' auto ' )
[Ctrl+ D]
Python-Script를 시작하여 Pypiserver를 시작하십시오
python pypiserver-start.py
메모
Python-Pam 모듈은 /etc /섀도우 파일에 대한 읽기 액세스가 필요합니다. Pypiserver가 Shadow Group에 실행되는 사용자를 다음 과 같은 명령으로 추가 할 수 있습니다.
임베디드 장치 용 Micropython 통역사는 모듈 upip.py 와 함께 패키지를 설치할 수 있습니다. 이 모듈은 특수 JSON-ENDPOINT를 사용하여 패키지 정보를 검색합니다. 이 엔드 포인트는 Pypiserver 에 의해 지원됩니다.
Unix 포트의 Micropython 으로 테스트 할 수 있습니다.
cd micropython
ports/unix/micropython -m tools.upip install -i http://my-server:8080 -p /tmp/mymodules micropython-foobar
임베디드 장치의 REPL에서 패키지를 설치하면 다음과 같은 방식으로 작동합니다.
import network
import upip
sta_if = network . WLAN ( network . STA_IF )
sta_if . active ( True )
sta_if . connect ( '<your ESSID>' , '<your password>' )
upip . index_urls = [ "http://my-server:8080" ]
upip . install ( "micropython-foobar" )
Micropython-packaging에 대한 자세한 내용은 https://docs.micropython.org/en/latest/reference/packages.html을 참조하십시오
Pypiserver는 /Health 에서 기본 건강 종점을 제공합니다. 서비스가 UP이면 항상 200 명을 반환합니다. 그렇지 않으면 서비스가 반응하지 않음을 의미합니다.
또한 PypiserVer를 사용하면 사용자가 건강 종점을 사용자 정의 할 수 있습니다. 영숫자, 하이픈, 전방 슬래시 및 밑줄이 허용되며 엔드 포인트는 기존 경로와 겹치지 않아야합니다. 유효한 사례 : /healthz , /health /live-1 , /api_health , /action /health
-health-endpoint argument와 함께 pypiserver를 실행하십시오.
pypi-server run --health-endpoint /action/health
import pypiserver
from pypiserver import bottle
app = pypiserver . app ( root = "./packages" , health_endpoint = "/action/health" )
bottle . run ( app = app , host = "0.0.0.0" , port = 8080 , server = "auto" )
CURL http : // localhost : 8080/Action/Health를 사용해보십시오
저장소 사본을 만들려면 사용하십시오
git clone https://github.com/pypiserver/pypiserver.git
cd pypiserver
나중에 변경 사항을 받으려면 위의 폴더에서 사용하십시오.
git pull
중요한
Pypiserver는 PYPI에서 볼 수 있듯이 전체 API를 구현하지 않습니다. Easy_Install , PIP 설치 및 검색 작업을 만들기에 충분히 구현됩니다.
다음과 같은 한계가 알려져 있습니다.
찾은 다른 버그는 Github의 BugTracker를 사용하십시오.
다른 많은 프로젝트가있어 자신의 PYPI 서버를 실행할 수 있습니다. PypiserVer가 작동하지 않으면 다음은 가장 인기있는 대안 중 하나입니다.
DevPi-Server : 신뢰할 수있는 빠른 pypi.org 캐싱 서버, 포괄적 인 Github 스타일 PYPI 인덱스 서버 및 포장 메타 도구의 일부. (버전 : 2.1.4, 액세스 날짜 : 2015 년 8 월 3 일)
이것을 확인하십시오. 질문 : 내 자신의 pypi를 굴리는 방법
이 프로젝트는 한때 Pypiserver에 대한 대안 이었지만 이제는 유지되지 않거나 보관되었습니다.
PIP2PI PIP 요구 사항에서 PYPI 호환 로컬 폴더를 구축하는 간단한 CMD 라인 도구
Flask-Pypi-Proxy 사용자 정의 패키지를 업로드 할 수있는 PYPI의 프록시.
Pypiserver 의 인덱스 서버로 사용하기위한 직접적인 대안은 아니지만 다음은 친숙해지기를 원하는 관련 소프트웨어 프로젝트 목록입니다.
pypi-uploader : 먼저 로컬로 저장하지 않고도 PYPI에서 PyPiserVer 에 패키지를 업로드하는 명령 줄 유틸리티.
꼬기 : PYPI 또는 PYPISERVER 와 상호 작용하기위한 명령 줄 유틸리티.
창고 : PYPI 자체에 전원을 공급하는 소프트웨어. 일반적으로 최종 사용자가 운영하기위한 것이 아닙니다.
Pypiserver 에는 MIT 라이센스에 따라 제공되는 병 사본이 포함되어 있으며 나머지 부분은 Zlib/Libpng 라이센스에 따라 배포됩니다. License.txt 파일을 참조하십시오.