简体   繁体   English

Python软件包中需要包含什么内容,以及它应该如何结构化?

[英]What needs to be in a Python package and how should it be structured?

I have a Python project that I'm ready to package up. 我有一个准备打包的Python项目。 I've never created a code package before and I have no idea what's involved. 我以前从未创建过代码包,也不知道涉及到什么。 Right now my project looks like this: 现在,我的项目如下所示:

Project/
    bin/
        script1.py
        script2.py
        script3.py
    project/
        __init__.py
        module1.py
        module2.py
        module3.py
    folder_where_files_created_by_the_scripts_go/
    BeautifulSoup/
        [stuff]

I know I have to create a setup.py file, a README, I remember reading somewhere that bin/ is where you're supposed to store scripts that carry out the modules... I'm sure there's a lot more I'm forgetting or don't know about to begin with. 我知道我必须创建一个setup.py文件,一个README文件,我记得在某个位置bin /那里应该存储执行模块的脚本...我敢肯定,我还有很多忘记或不知道开始。 Basically, I'm looking for a tutorial that assumes I know absolutely nothing about package code and will hold my hand through whole process from writing the README and setup to telling me what directories there should be and what should be in them. 基本上,我正在寻找一个教程,该教程假定我对软件包代码完全一无所知,并将在编写自述文件和设置到告诉我应该有哪些目录以及其中应该包含什么目录的整个过程中全神贯注。 Everything I've found by googling is essentially a "How to Make Better Packages" article that starts from a high level. 我通过谷歌搜索发现的所有内容本质上都是“如何制作更好的包装”的文章,从高层次开始。

Also, if it makes a difference, this project is for a business professor who needed a certain task to be completed; 同样,如果有所作为,则该项目适用于需要完成特定任务的商科教授。 for now I have no plans to upload it to PyPI, but I might want to in the future, and I'd like to do things properly now to save myself future hassle. 目前,我没有将其上传到PyPI的计划,但将来可能会希望这样做,并且我想现在做适当的事情以免自己将来遇到麻烦。

After more googling I found a good tutorial: http://www.scotttorborg.com/python-packaging/index.html 经过更多的谷歌搜索后,我发现了一个很好的教程: http : //www.scotttorborg.com/python-packaging/index.html

Hopefully this helps anybody else with the same utter lack of knowledge in this area. 希望这可以帮助在该领域完全缺乏知识的其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM