日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python的setup.py文件及其常用命令

發布時間:2025/3/15 python 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python的setup.py文件及其常用命令 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

python的setup.py文件及其常用命令

上傳者:tingting1718 ?? ?
我也要“分享賺錢
2014/7/7
關注(286)
評論(0)

聲明:此內容僅代表網友個人經驗或觀點,不代表本網站立場和觀點。

? ? 編寫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文

? ? 件中列舉的所有引用。

? ? 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文件及其常用命令的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。