Thinking:
Common code for each service made pip extracted package, upload to the warehouse and for download (do not enter the account password when downloading), docker deployment environment also need to be able to install this package pip
In addition pip package needs to be done alone version management, uploaded to the git repository.
twine module package python project upload pypi
https://blog.csdn.net/mouday/article/details/80736312
As a contribution to the world -pipy pack your wheels
https://blog.csdn.net/mouday/article/details/79611454
packaging.python
https://packaging.python.org/guides/using-testpypi/
Established manually pypi-server (pro-test)
https://liqiang.io/post/build-your-own-pip-source
Manually build the problem pypi-server:
1 htpasswd command error
[root@shen ~]# htpasswd
-bash: htpasswd: command not found
solve:
[root@shen pip]# yum -y install httpd
[root@shen pip]# htpasswd -c htpasswd.txt admin
https://www.cnblogs.com/zhaobin-diray/p/10936188.html
PS:
Set pypi-server and start
Open the firewall port 8080:
[root@shen pip]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
[root@shen pip]# firewall-cmd --reload
pypirc configuration file:
$HOME/.pypirc文件:
[distutils]
index-servers=
pypiserver
[pypiserver]
repository: http://10.1.252.30:8080
username: admin
password: admin
Upload:
(drf-venv-3.7) D:\shen\python\PythonWebDev\pip包\extradrf>twine upload dist\extradrf-0.0.1.tar.gz -r pypiserver
Uploading distributions to http://10.1.252.30:8080
Uploading extradrf-0.0.1.tar.gz
100%|█████████████████████████████████████████████████████████| 27.3k/27.3k [00:00<00:00, 905kB/s]
installation
pip install -i http://10.1.252.30:8080/simple/ --trusted-host 10.1.252.30 extradrf
Bale:
>python setup.py sdist
Note extra folder must have a __init__.py
Use nexus
Upload
nexus web upload
nexus open anonymous download
twine upload
(data_dict_venv3.7) D:\shen\python\PythonWebDev\pip包\extradrf>twine upload --repository-url http://10.1.252.30:8081/repository/pypi/ dist/*
Uploading distributions to http://10.1.252.30:8081/repository/pypi/
Enter your username: admin
Enter your password: admin123
Uploading extradrf-0.0.3.tar.gz
100%|█████████████████████████████████████████████| 27.4k/27.4k [00:00<00:00, 171kB/s]
Download and install
pip install
method one:
pip install -i http://10.1.252.30:8081/repository/pypi/simple extra
Second way:
copy Link
http://10.1.252.30:8081/repository/pypi/packages/extra/0.0.1/extra-0.0.1.tar.gz
pip install http://10.1.252.30:8081/repository/pypi/packages/extra/0.0.1/extra-0.0.1.tar.gz
web installation
http://10.1.252.30:8081/service/rest/repository/browse/pypi/extradrf/0.0.3/
(data_dict_venv3.7) D:\shen\python\PythonWebDev\web_develop\DRF\tianshu\data_dict>
pip install C:\Users\shen\Downloads\extradrf-0.0.3.tar.gz
use
from extradrf.response import DefaultResponse as TestDefaultResponse
...
@action(methods=['POST'], detail=False)
def device_conn(self, request):
""" """
....
return TestDefaultResponse({"name": res}, status=status.HTTP_200_OK)