upgrade module on pypi

简介:
之前写了一篇如何将模块上传到pypi.python.org的文章
如果代码有更新, 如何更新到pypi呢?
例如 : 
首选更新代码
[root@localhost pydigoal]# vi digoal_nester.py 
"""this is comment
comment end"""

def print_lol(the_list, ident=False, level=0):
  """this is function comment
  comment end"""

  for each_item in the_list:
    if isinstance(each_item, list):
      print_lol(each_item, ident, level+1)
    else:
      if ident:
        for tab_stop in range(level):
          print("\t", end='')
      print(each_item)


然后要更新setup.py, 修改version.
[root@localhost pydigoal]# vi setup.py 
from distutils.core import setup
setup(
    name = 'digoal_nester',
    version = '1.2.0',
    py_modules = ['digoal_nester'],
    author = 'digoal',
    author_email = 'digoal@126.com',
    url = 'http://blog.163.com/digoal@126',
    description = 'a test module by digoal'
)


使用python setup.py sdist upload上传
[root@localhost pydigoal]# python setup.py sdist upload
running sdist
running check
warning: sdist: manifest template 'MANIFEST.in' does not exist (using default file list)

warning: sdist: standard file not found: should have one of README, README.txt

writing manifest file 'MANIFEST'
creating digoal_nester-1.2.0
making hard links in digoal_nester-1.2.0...
hard linking digoal_nester.py -> digoal_nester-1.2.0
hard linking setup.py -> digoal_nester-1.2.0
Creating tar archive
removing 'digoal_nester-1.2.0' (and everything under it)
running upload
Submitting dist/digoal_nester-1.2.0.tar.gz to https://pypi.python.org/pypi
Server response (200): OK


上传后可以通过URL搜索到上传的更新模块

本地测试
[root@localhost pydigoal]# python setup.py install
running install
running build
running build_py
copying digoal_nester.py -> build/lib
running install_lib
copying build/lib/nester.py -> /usr/local/lib/python3.4/site-packages
copying build/lib/digoal_nester.py -> /usr/local/lib/python3.4/site-packages
byte-compiling /usr/local/lib/python3.4/site-packages/nester.py to nester.cpython-34.pyc
byte-compiling /usr/local/lib/python3.4/site-packages/digoal_nester.py to digoal_nester.cpython-34.pyc
running install_egg_info
Writing /usr/local/lib/python3.4/site-packages/digoal_nester-1.2.0-py3.4.egg-info


本地测试
[root@localhost ~]# vi test.py
import digoal_nester

l_list = ['hello',['i',['am','digoal']]]
digoal_nester.print_lol(l_list,True)

[root@localhost ~]# python ./test.py
hello
        i
                am
                digoal

相关文章
使用pip时报错:No module named ‘chardet‘ 的解决办法
使用pip时报错:No module named ‘chardet‘ 的解决办法
1329 0
使用pip时报错:No module named ‘chardet‘ 的解决办法
|
3天前
|
Ubuntu Python
执行apt-get update时 报错ModuleNotFoundError: No module named ‘debian‘
执行apt-get update时 报错ModuleNotFoundError: No module named ‘debian‘
7 0
ou must install signalwire-client-c to build mod_signalwire
ou must install signalwire-client-c to build mod_signalwire
98 0
|
9月前
pip安装skbuild报错:ModuleNotFoundError: No module named ‘skbuild’解决方法
pip安装skbuild报错:ModuleNotFoundError: No module named ‘skbuild’解决方法,换源
533 0
|
11月前
|
Python
1. 成功解决 Bug:ModuleNotFoundError: No module named 'pip'
Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 87, in _ru
163 0
|
JavaScript
npm install报错error 404 Not Found - GET https://registry.npm.taobao.org/@xt
1.问题场景: 2.解决办法 2.1先查看有没有设置代理 2.2重新设置
1076 0
npm install报错error 404 Not Found - GET https://registry.npm.taobao.org/@xt
You must install libks to build mod_signalwire
You must install libks to build mod_signalwire
132 0
You must install signalwire-client-c to build mod_signalwire
You must install signalwire-client-c to build mod_signalwire
137 0
|
TensorFlow 算法框架/工具
pip安装后仍有ImportError No module named XX问题解决
pip安装后仍有ImportError No module named XX问题解决
229 2