簡體   English   中英

setup.py文件中的包

[英]Packages in setup.py file

我遵循Python包的教程,並試圖了解這里的“包”行是什么..

install_requires將安裝列表中給出的所有軟件......那么,包的作用是什么?

from distutils.core import setup

setup(
    name='TowelStuff',
    version='0.1.0',
    author='J. Random Hacker',
    author_email='jrh@example.com',
    packages=['towelstuff', 'towelstuff.test'],
    scripts=['bin/stowe-towels.py','bin/wash-towels.py'],
    url='http://pypi.python.org/pypi/TowelStuff/',
    license='LICENSE.txt',
    description='Useful towel-related stuff.',
    long_description=open('README.txt').read(),
    install_requires=[
        "Django >= 1.1.1",
        "caldav == 0.1.4",
    ],
)

您可以查看disutils文檔的這一部分,其中提供了完整的解釋: http ://docs.python.org/2/distutils/setupscript.html#listing-whole-packages

但簡而言之,“包”指的是您的代碼,而不是外部依賴。 如果您的setup.py文件位於項目的頂級目錄中,並且您的'packages'參數列出了towelstuff和towelstuff.test,那么目錄結構的外觀如下:

setup.py
towelstuff
    __init__.py
    ...some other files in towelstuff...
towelstuff.test
    __init__.py
    ...some other files in towelstuff.test...
...some other scripts in the project directory...

基本上,Python包只是一個包含'__init__.py'文件的目錄。 當您編寫setup.py文件時,您承諾setup.py有兩個軟件包(towelstuff和towelstuff.test)與setup.py腳本位於同一目錄中。

將來,當您使用setup.py捆綁您的應用程序時,這兩個包將包含在發行版中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM