zoukankan      html  css  js  c++  java
  • Head Frist Python 读书笔记 构建发布

    构建发布 p41

    Windows系统需要使用“c:pythonXpython.exe”执行,

    或者,通过配置环境变量来简化输入

    1. 首先需要在系统中注册python环境变量:假设python的安装路径为c:python2.6,则修改我的电脑->属性->高级->环境变量->系统变量中的PATH为:

    (为了在命令行模式下运行Python命令,需要将python.exe所在的目录附加到PATH这个环境变量中。)

    PATH=PATH;c:python26

    上述环境变量设置成功之后,就可以在命令行直接使用python命令。或执行"python *.py"运行python脚本了。

    2. 此时,还是只能通过"python *.py"运行python脚本,若希望直接运行*.py,只需再修改另一个环境变量PATHEXT:

    PATHEXT=PATHEXT;.PY;.PYM

    setup.py文件,是用于打包发布的索引文件,调用了distutils.core.setup方法,其中py_modules标明了需要打包文件的名字

    from distutils.core import setup
    setup(
    name="nester",
    version="1.0.0",
    py_modules=['nester'],
    author="abc",
    author_email="abc@def.com",
    url="http://localhost/",
    description="A simple printer of nested lists",
    )

    构建一个发布文件:

    将发布安装到Python本地副本中:

    书中使用的是,这个是Linux的命令

    sudo python3 setup.py install

    Windows中使用

    python setup.py install

    命令说明:

    python setup.py sdist

    (assuming you haven’t specified any sdist options in the setup script or config file), sdist creates the archive of the default format for the current platform. The default format is a gzip’ed tar file (.tar.gz) on Unix, and ZIP file on Windows.

    You can specify as many formats as you like using the --formats option, for example:

    python setup.py sdist --formats=gztar,zip

    to create a gzipped tarball and a zip file. The available formats are:

    FormatDescriptionNotes
    zip zip file (.zip) (1),(3)
    gztar gzip’ed tar file (.tar.gz) (2)
    bztar bzip2’ed tar file (.tar.bz2)  
    ztar compressed tar file (.tar.Z) (4)
    tar tar file (.tar)  

    Notes:

    1. default on Windows
    2. default on Unix
    3. requires either external zip utility or zipfile module (part of the standard Python library since Python 1.6)
    4. requires the compress program. Notice that this format is now pending for deprecation and will be removed in the future versions of Python.

    When using any tar format (gztarbztarztar or tar), under Unix you can specify the owner and group names that will be set for each member of the archive.

    For example, if you want all files of the archive to be owned by root:

    python setup.py sdist --owner=root --group=root

    tips:“打开一个终端窗口”,可以通过命令行cd到代码所在目录,也可以在所在目录shift+鼠标右键,调出命令窗口

  • 相关阅读:
    阿里云盾证书服务助力博客装逼成功
    内容安全策略(CSP)_防御_XSS_攻击的好助手
    Spring-beans架构设计原理
    Httpclient核心架构设计
    第四章 数据类型—字典(dict)、集合(set)
    第三章 数据类型 — 列表(list)、元组(tuple)
    第三章 数据类型 — int、bool 和 str
    第二章 Python基础(二)
    pycharm快捷键
    第二章 Python基础(一)
  • 原文地址:https://www.cnblogs.com/lvjianwei/p/4964529.html
Copyright © 2011-2022 走看看