编写setup.py文件,获取帮助:python setup.py --help-commands

[python] 

Standard commands: 

  build             build everything needed to install 

  build_py          "build" pure Python modules (copy to build directory) 

  build_ext         build C/C++ extensions (compile/link to build directory) 

  build_clib        build C/C++ libraries used by Python extensions 

  build_scripts     "build" scripts (copy and fixup #! line) 

  clean             clean up temporary files from 'build' command 

  install           install everything from build directory 

  install_lib       install all Python modules (extensions and pure Python) 

  install_headers   install C/C++ header files 

  install_scripts   install scripts (Python or otherwise) 

  install_data      install data files 

  sdist             create a source distribution (tarball, zip file, etc.) 

  register          register the distribution with the Python package index 

  bdist             create a built (binary) distribution 

  bdist_dumb        create a "dumb" built distribution 

  bdist_rpm         create an RPM distribution 

  bdist_wininst     create an executable installer for MS Windows 

  upload            upload binary package to PyPI 

  check             perform some checks on the package 

 

Extra commands: 

  rotate            delete older distributions, keeping N newest files 

  develop           install package in 'development mode' 

  setopt            set an option in setup.cfg or another config file 

  saveopts          save supplied options to setup.cfg or other config file 

  egg_info          create a distribution's .egg-info directory 

  install_egg_info  Install an .egg-info directory for the package 

  alias             define a shortcut to invoke one or more commands 

  easy_install      Find/get/install Python packages 

  bdist_egg         create an "egg" distribution 

  test              run unit tests after in-place build

standard commands(标准命令)是distutils内建命令,而Extra commands(附加命令)是像

setuptools这样的第三方包创建的。

命令详解:

1.sdist:用来创建一个源码包,在windows下为zip格式,linux下为tag.gz格式 。

setup.py示例:

from setuptools import setup

setup(name='xxx',version='0.1.1')

打包命令:python setup.py sdist

distutils将浏览包的路径,查找包含在档案中的文件,包括:

   1)所有py_modules、packages和scripts选项隐含的python源文件

   2)所有在ext_modules选项中列出的C源文件

   3)符合test/test*.py模式的文件

   4)README、README.txt、setup.py和setup.cfg文件

如果需要包含更多文件,那么可以使用MANIFEST.in文件模版,示例如下:

include xx.txt

include yy/xx.txt

....

2.bdist_egg:用来创建一个二进制分发版本,经常用来替代基于bdist生成的模式

3.install:安装包到python中。另外,他还可能会安装在setup.py中的install_requires定义的

相关模块,例如:

install_requires=['...','...']

删除一个包:1)删除这个包所创建的文件,2)删除在site-packages文件夹easy-install.pth文

件中列举的所有引用。 www.2cto.com

4.develop:编译并且在适当的位置安装包,然后添加一个简单的链接到python site-packages文

件夹中,可以使用显式的-u选项删除包,例如:

 python setup.py develop

 python setup.py develop -u

    使用该方式比其他方式安装包更好一些

5.创建一个新命令:这是由setuptools引入的,是一种将包定义为插件的简单方法,示例:

...entry_points='''

                [distutils.commands]

  my_command=my.command.module.Class

python的setup.py文件及其常用命令的更多相关文章

  1. python的setup.py文件

    最近工作需要,用Cython写了*.pyx扩展,并将其编译成C文件,最后转换为so扩展,供python引用使用 distutils 编译,建立一个setup.py 的脚本from distutils. ...

  2. python 利用 setup.py 手动安装django_chartit

    手动安装django_chartit库 1 下载压缩包 2 解压到python安装目录下,文件夹名为django_chartit,并检查文件夹下是否有setup.py文件 3 在cmd中进入djang ...

  3. 『Python』setup.py简介

    setup.py应用场合 网上见到其他人这样介绍: 假如我在本机开发一个程序,需要用到python的redis.mysql模块以及自己编写的redis_run.py模块.我怎么实现在服务器上去发布该系 ...

  4. python如何编译py文件生成pyc、pyo、pyd以及如何和C语言结合使用

    python执行py文件的流程 当我们执行一个py文件的时候,直接python xx.py即可,那么这个流程是怎么样的呢.先说明一下,python执行代码实际上是先打开文件然后执行里面的代码,所以文件 ...

  5. 如何使用setup.py文件

    setup.py文件的使用:% python setup.py build #编译% python setup.py install    #安装% python setup.py sdist     ...

  6. python进阶之py文件内置属性

    前言 对于任何一个python文件来说,当python解释器运行一个py文件,会自动将一些内容加载到内置的属性中:一个模块我们可以看做是一个比类更大的对象. 查看模块的内置属性 我们先创建一个典型的p ...

  7. python中__init__.py文件的作用

    问题 在执行models.py时,报ImportError:No module named transwarp.db的错误,但明明transwarp下就有db.py文件,路径也没有错误.真是想不通.后 ...

  8. MySQL进口.sql文件和常用命令

    MySQL进口.sql文件和常用命令 在MySQL Qurey   Brower中直接导入*.sql脚本,是不能一次运行多条sql命令的.在mysql中运行sql文件的命令: mysql> so ...

  9. Python中__init__.py文件的作用详解

    转自http://www.jb51.net/article/92863.htm Python中__init__.py文件的作用详解 http://www.jb51.net/article/86580. ...

随机推荐

  1. 人工智能AI智能加速卡技术

    人工智能AI智能加速卡技术 一. 可编程AI加速卡 1. 概述: 这款可编程AI加速器卡具备 FPGA 加速的强大性能和多功能性,可部署AI加速器IP(WNN/GNN,直接加速卷积神经网络,直接运行常 ...

  2. 视频处理器为电池供电的设计提供4K视频编码

    视频处理器为电池供电的设计提供4K视频编码 Video processor enables 4K video coding for battery-powered designs OmniVision ...

  3. Docker系列——Grafana+Prometheus+Node-exporter微信推送(三)

    在之前博文中,已经成功的实现了邮件推送.目前主流的办公终端,就是企业微信.钉钉.飞书.今天来分享下微信推送,我们具体来看. 企业微信 在配置企业微信推送时,需要有微信企业,具体如何注册.使用,另外百度 ...

  4. java并发编程工具类JUC第八篇:ConcurrentHashMap

    在之前的文章中已经为大家介绍了java并发编程的工具:BlockingQueue接口.ArrayBlockingQueue.DelayQueue.LinkedBlockingQueue.Priorit ...

  5. nacos 实战(史上最全)

    文章很长,而且持续更新,建议收藏起来,慢慢读! 高并发 发烧友社群:疯狂创客圈(总入口) 奉上以下珍贵的学习资源: 疯狂创客圈 经典图书 : 极致经典 + 社群大片好评 < Java 高并发 三 ...

  6. org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element

    org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element(识别不到想要的元素) 想获取 ...

  7. ORA-09817:Write to audit file failed

    ERROR: ORA-09817: Write to audit file failed. --这种错误基本是磁盘空间满了 问题描述:sqlplus / as sysdba登不上,报上述ora-098 ...

  8. windows 上 OpenSSH 服务 启用秘钥登录(微软真心逆天)

    windows 上 OpenSSH 服务 启用秘钥登录(微软真心逆天) windows 安装 OpenSSH 服务 最近需要在windows 服务器上部署自动发布程序,那么就需要用到 scp 和 ss ...

  9. Unity接入ShareSDK实现QQ登录和QQ分享、微信分享

    原文链接:Unity接入ShareSDK实现QQ登录和QQ分享.微信分享 由于微信登录需要企业审核,我这里就不说明了,有需要的可以去官网看一下文档,和QQ登录比多了一个打包的步骤. 第一步:到官网申请 ...

  10. nginx负载均衡与反向代理

    1.集群的特点 (1)高性能 (2)价格有效性 (3)可伸缩性 (4)高可用性 (5)透明性 2.负载均衡概述 负载均衡,英文名称为Load Balance,其含义就是指将负载(工作任务)进行平衡.分 ...