zoukankan      html  css  js  c++  java
  • python如何发布模块

    https://jingyan.baidu.com/article/59a015e375f55af794886591.html

    一、准备发布

    1、创建一个nester.py 模块,创建nester 文件夹将nester.py模块复制到这个文件夹

    "# Author:guangqing"
    ''' 这是 "nester" 模块,提供了一个名为print_lol()的函数,这个函数的作用是打印列表,其中有可能包含(也有可能不包含嵌套列表的类别)嵌套列表 '''
    def print_lol(the_list):
        '''这个函数取一个位置参数,名为 'the_list'这可以是任何python列表(也可以是包含嵌套列表的列表)。所指定的列表中的每个数据项会(递归的)输出到屏幕上,各个数据各占一行 '''
        for each_item in the_list:
            if isinstance(each_item,list):
                print_lol(each_item)
            else:
                print(each_item) 

    2、在新文件夹中创建一个名为setup.py的文件;

    from distutils.core import setup
    
    setup(
        name='nester',
        version='1.0.0',
        py_modules =['nester'],
        author='jiale',
        author_email='18521093275@163.com',
        url='http://www.headfirstlabs.com',
        
        description='这是我的第一个发布安装文件'
    )

    二、准备发布

    1、接下来我们打开cmd窗口,进入到上面建立的文件夹下面,然后执行python setup.py sdist命令,如下图所示(shift+右键,在此处打开powershell窗口)

    PS D:
    ester> python setup.py sdist
    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, README.rst
    
    writing manifest file 'MANIFEST'
    creating nester-1.0.0
    making hard links in nester-1.0.0...
    hard linking nester.py -> nester-1.0.0
    hard linking setup.py -> nester-1.0.0
    creating dist
    Creating tar archive
    removing 'nester-1.0.0' (and everything under it)
    PS D:
    ester>

    2、将发布安装到你的python本地副本中。

    PS D:
    ester> python setup.py install
    running install
    running build
    running build_py
    creating build
    creating buildlib
    copying nester.py -> buildlib
    running install_lib
    running install_egg_info
    Removing D:pythonLibsite-packages
    ester-1.0.0-py3.7.egg-info
    Writing D:pythonLibsite-packages
    ester-1.0.0-py3.7.egg-info
    PS D:
    ester>

    1、在python 或IDLE shell中,键入dir(__builtins__)可以看到Python提供的内置方法列表;那些小写的单词都是BIF。要查看某个BIF做什么,比如说input(),可以在shell中键入help(input),就会得到这个BIF的功能描述;

    Made by Guangqing Xu
  • 相关阅读:
    【转】JVM 堆内存设置原理
    【转】Java八种基本数据类型的比较及其相互转化
    8月12日
    并发与竞争
    高通gpio配置输出
    创建一个字符设备的基本流程
    4月2号 字符设备驱动实验
    3.30学习遇到卡死点
    断言函数的用法
    12.02 下午
  • 原文地址:https://www.cnblogs.com/jialexu/p/10385344.html
Copyright © 2011-2022 走看看