前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Python | 发包 2018 入坑

Python | 发包 2018 入坑

作者头像
py3study
发布2020-01-03 17:56:59
1.5K0
发布2020-01-03 17:56:59
举报
文章被收录于专栏:python3python3

最近业务需要抽离,抽离出来的应用需要做成 Django 第三方包的形式,可以在任何 Django(也没那么神奇,例如有些版本就没测试)版本项目中,直接安装使用,所以这里还是需要发包到 pypi。

第一次发包

我是先发到 test 环境 https://testpypi.python.org/,看下发包还是不是符合我的预期,毕竟很长时间没发过包。

代码语言:javascript
复制
twine upload  -r pypitest dist/django-xxxxx-0.0.1.tar.gz
Uploading distributions to https://test.pypi.org/legacy/
Uploading django-xxxxx-0.0.1.tar.gz
  0%|                                                                                                            | 0.00/18.5k [00:00<?, ?B/s]
SSLError: HTTPSConnectionPool(host='test.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661)'),))

结果打脸,查了下资料,http://pyfound.blogspot.hk/20...,摘出来一部分

There are two deadlines to upgrade your Python to a version with the latest TLS. The first comes soon, on April 30, 2017, when python.org sites without Extended Validation Certificates will stop supporting TLS 1.0 and 1.1. These sites include:testpypi.python.org test.pypi.org files.pythonhosted.org

大意是什么呢,意思就是提醒赶紧升级 python,那个后面只会只支持使用 TLS 1.2 版本的协议,低版本的不再支持了,很不幸,testpypi.python.org 这个测试站点停止支持 TLS 1.0 和 1.1

接着按照给出的例子,自己测了下

代码语言:javascript
复制
python -m pip install --upgrade requests
python -c "import requests; print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version'])"

TLS 1.0

If you see "TLS 1.2", your interpreter's TLS is up to date. If you see "TLS 1.0" or an error like "tlsv1 alert protocol version", then you must upgrade. ↩

第二次发包

按照文档上讲的,我的 python 过时了,那就直接升到 2.7.14;升完再跑一遍

代码语言:javascript
复制
python -c "import requests; print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version'])"
/Users/allen/Develop/py3env/lib/python3.6/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
TLS 1.2
代码语言:javascript
复制
这下是否可以省心了,继续我的发包

twine upload  -r pypitest dist/django-xxxxx-0.0.1.tar.gz
Uploading distributions to https://test.pypi.org/legacy/
Uploading django-xxxxx-0.0.1.tar.gz
  0%|                                                                                                            | 0.00/18.5k [00:00<?, ?B/s]
SSLError: HTTPSConnectionPool(host='test.pypi.org', port=443): Max retries exceeded with url: /legacy/ (Caused by SSLError(SSLError(1, u'[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:661)'),))

很不幸,继续躺着,谷歌了下 pip install pyOpenSSL 如果已经安装了,更新下,保险;

第三次发包
代码语言:javascript
复制
twine upload  -r pypitest dist/django-xxxxx-0.0.1.tar.gz
Uploading distributions to https://test.pypi.org/legacy/
Uploading django-xxxxx-0.0.1.tar.gz
100%|███████████████████████████████████████████████████████████████████████████████████████████████████| 18.5k/18.5k [00:08<00:00, 2.13kB/s]

终于跑起来了,小结下

  • 如果 Python 版本低,升级
  • 如果 pyOpenSSL 版本低,升级
  • 如果 requests 版本低,升级
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-10-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 第一次发包
  • 第二次发包
  • 第三次发包
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档