搭建+部署
mkdir -p /Server/pypi/packages
pip install htpasswd
htpasswd -sc /Server/pypi/htpasswd.txt sunie
docker run --name pypi \
--restart=always \
-v /Server/pypi/packages:/data/packages \
-v /Server/pypi/htpasswd.txt:/data/htpasswd.txt \
-p 9007:8080 -d \
pypiserver/pypiserver \
-P htpasswd.txt packages
上传
upload.sh
# pip install wheel twine
cd /Server/Desktop/wencai
rm -rf build
rm -rf dist
rm -rf wencai.egg-info
python setup.py bdist_wheel
twine upload dist/* -r private --verbose
# 注意这里的private是repo的名字
# pip install http://sunie.top:9007/packages/wencai-0.0.1.sunie.2021_08_25t10_26-py3-none-any.whl
conda activate
wc.update
更新
def get_newest_version(branch):
# http://spring.sensetime.com/pypi/dev/packages/
# spring_aux-???-py3-none-any.whl
url = 'http://sunie.top:9007/packages/'
rep = requests.get(url).text
ans = ''
for line in rep.split('\n'):
if line.count('wencai') and line.count('.whl'):
if line.count(branch):
ans = line
return ans.split('"')[1].split('-')[1]
def upload():
os.system(f'sh {filepath}/upload.sh')
def update():
branch = 'sunie'
"""update wencai to the newest version"""
ech('on branch: %s' % click.style(branch, 'blue'))
version = get_newest_version(branch)
ech('the newest version is: %s' % click.style(version, 'blue'))
cmd = "pip install http://sunie.top:9007/packages/" + \
f"wencai-{version}-py3-none-any.whl --user"
if get_system() != 'Windows':
cmd += ' --upgrade'
os.system(cmd)
ech(f'successfully update wencai({version})', 'green')
配置用户名密码
https://www.cnblogs.com/mithrilon/p/8954677.html
上传机器上配置~/.pypirc
[distutils]
index-servers =
private
[private]
repository: http://sunie.top:9007/
username: sunie
password: Sunye123!!
问题
Q: twine upload的时候出现:
InvalidConfiguration: Missing 'private' section from ~/.pypirc.
https://packaging.python.org/specifications/pypirc/
原因是twine upload没有对应~/.pypirc
Q: HTTPError: 403 Forbidden from http://sunie.top:9007/
username: sunie
password: <hidden>
Uploading wencai-0.0.4.sunie.2021_10_22t10_53-py3-none-any.whl
100%|█████████████████████████████████████████████████████████████████████████████████████████████████| 51.2k/51.2k [00:00<00:00, 1.14MB/s]
Content received from server:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>Error: 403 Forbidden</title>
<style type="text/css">
html {background-color: #eee; font-family: sans;}
body {background-color: #fff; border: 1px solid #ddd;
padding: 15px; margin: 15px;}
pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
</style>
</head>
<body>
<h1>Error: 403 Forbidden</h1>
<p>Sorry, the requested URL <tt>'http://sunie.top:9007/'</tt>
caused an error:</p>
<pre>None</pre>
</body>
</html>
多次卸载重装均无效,可能是密码不正确。删掉了特殊字符
评论区