接上回 最终得到这样的目录
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
asgi.py
wsgi.py
polls/
__init__.py
admin.py
apps.py
migrations/
__init__.py
0001_initial.py
models.py
static/
polls/
images/
background.gif
style.css
templates/
polls/
detail.html
index.html
results.html
tests.py
urls.py
views.py
templates/
admin/
base_site.html
安装打包工具
# pip install setuptools
组织子应用 并写点介绍文件
-
任意外面的目录 起个名字并建文件夹 django-polls
-
复制 polls 到django-polls
-
写 README.rst 文件
===== Polls ===== Polls is a Django app to conduct web-based polls. For each question, visitors can choose between a fixed number of answers. Detailed documentation is in the "docs" directory. Quick start ----------- 1. Add "polls" to your INSTALLED_APPS setting like this:: INSTALLED_APPS = [ ... 'polls', ] 2. Include the polls URLconf in your project urls.py like this:: path('polls/', include('polls.urls')), 3. Run ``python manage.py migrate`` to create the polls models. 4. Start the development server and visit http://127.0.0.1:8000/admin/ to create a poll (you'll need the Admin app enabled). 5. Visit http://127.0.0.1:8000/polls/ to participate in the poll.
-
写 LICENSE 文件
-
写 pyproject.toml setup.cfg setup.py 文件 介绍如何构建安装 app
pyproject.toml
[build-system] requires = ['setuptools>=40.8.0', 'wheel'] build-backend = 'setuptools.build_meta:__legacy__'
setup.py
from setuptools import setup setup()
setup.cfg
[metadata] name = django-polls version = 0.1 description = A Django app to conduct web-based polls. long_description = file: README.rst url = https://www.example.com/ author = Your Name author_email = [email protected] license = BSD-3-Clause # Example license classifiers = Environment :: Web Environment Framework :: Django Framework :: Django :: X.Y # Replace "X.Y" as appropriate Intended Audience :: Developers License :: OSI Approved :: BSD License Operating System :: OS Independent Programming Language :: Python Programming Language :: Python :: 3 Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Topic :: Internet :: WWW/HTTP Topic :: Internet :: WWW/HTTP :: Dynamic Content [options] include_package_data = true packages = find: python_requires = >=3.8 install_requires = Django >= X.Y # Replace "X.Y" as appropriate
包含其他文件
默认情况下,包中仅包含 Python 模块和包。 要包含其他文件,我们需要创建一个 MANIFEST.in 文件。 上一步中提到的 setuptools 文档更详细地讨论了这个文件。 要包含模板、README.rst 和我们的 LICENSE 文件,创建一个文件 django-polls/MANIFEST.in ,其内容如下:
include LICENSE
include README.rst
recursive-include polls/static *
recursive-include polls/templates *
包含详细文档(可选)
- 创建一个空目录 django-polls/docs
- 补充一行代码 django-polls/MANIFEST.in
recursive-include docs *
构建
D:\此电脑下分类\桌面\django-polls>
D:\此电脑下分类\桌面\django-polls>python setup.py sdist
running sdist
running egg_info
creating django_polls.egg-info
writing django_polls.egg-info\PKG-INFO
writing dependency_links to django_polls.egg-info\dependency_links.txt
........
最终结果
标签:polls,Python,setup,py,django,投票,应用,include,包子 From: https://www.cnblogs.com/hugboy/p/17132239.html