zoukankan      html  css  js  c++  java
  • Python 创建和发布安装函数模块

    1. create dir "nester" under C:UsersericAppDataLocalProgramsPythonPython35-32

    2. create a nester.py under C:UsersericAppDataLocalProgramsPythonPython35-32 ester

    """this is a new fuction, which work for a list"""
    def print_lol(the_list):
        """ one arguement is the_list"""
        for each_item in the_list:
            if isinstance(each_item,list):
                print_lol(each_item)
            else:
                print(each_item)
    

    3. Run F5, Python解析器重置,加载了新的函数

     RESTART: C:UsersericAppDataLocalProgramsPythonPython35-32
    ester
    ester.py 
    >>> movies = ["abc","ehll","asdfdsf"]
    >>> print_lol(movies)
    abc
    ehll
    asdfdsf
    >>> 
    

    4. create setup.py  under C:UsersericAppDataLocalProgramsPythonPython35-32 ester

    from distutils.core import setup
    
    setup(
            name        = 'nester',
            version     = '1.0.0',
            py_modules  = ['nester'],
            author      = 'eric',
            author_email= 'eric@126.com',
            url         = 'http://126.com',
            description = 'a simple nested lists',
    
        )
    

    5. create distribution under CMD or Shell

    C:UsersericAppDataLocalProgramsPythonPython35-32
    ester>c:UsersericAppDataLocalProgramsPythonPython35-32python.exe 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
    
    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 'dist
    ester-1.0.0.zip' and adding 'nester-1.0.0' to it
    adding 'nester-1.0.0
    ester.py'
    adding 'nester-1.0.0PKG-INFO'
    adding 'nester-1.0.0setup.py'
    removing 'nester-1.0.0' (and everything under it)
    

    6. install nester moudle to your local

    C:UsersericAppDataLocalProgramsPythonPython35-32
    ester>c:UsersericAppDataLocalProgramsPythonPython35-32python.exe setup.py install
    running install
    running build
    running build_py
    creating build
    creating buildlib
    copying nester.py -> buildlib
    running install_lib
    copying buildlib
    ester.py -> c:UsersericAppDataLocalProgramsPythonPython35-32Libsite-packages
    byte-compiling c:UsersericAppDataLocalProgramsPythonPython35-32Libsite-packages
    ester.py to nester.cpython-35.pyc
    running install_egg_info
    Writing c:UsersericAppDataLocalProgramsPythonPython35-32Libsite-packages
    ester-1.0.0-py3.5.egg-info
    

    7. import and test new moudle

    >>> import nester
    >>> cast = ['palin','cleese','book','jones']
    >>> print_lol(cast)
    Traceback (most recent call last):
      File "<pyshell#3>", line 1, in <module>
        print_lol(cast)
    NameError: name 'print_lol' is not defined
    >>> nester.print_lol(cast)
    palin
    cleese
    book
    jones
    >>>
    
  • 相关阅读:
    Docker+Jenkins持续集成环境(1)使用Docker搭建Jenkins+Docker持续集成环境
    DockOne技术分享(二十):Docker三剑客之Swarm介绍
    最佳实战Docker持续集成图文详解
    Spring Cloud Netflix Eureka源码导读与原理分析
    JVM内存区域的划分(内存结构或者内存模型)
    深入理解JVM(一)——JVM内存模型
    java多线程有哪些实际的应用场景?
    深入理解Java类加载器(1):Java类加载原理解析
    【深入Java虚拟机】之四:类加载机制
    OAuth 2和JWT
  • 原文地址:https://www.cnblogs.com/oskb/p/4816929.html
Copyright © 2011-2022 走看看