最新要闻

广告

手机

iphone11大小尺寸是多少?苹果iPhone11和iPhone13的区别是什么?

iphone11大小尺寸是多少?苹果iPhone11和iPhone13的区别是什么?

警方通报辅警执法直播中被撞飞:犯罪嫌疑人已投案

警方通报辅警执法直播中被撞飞:犯罪嫌疑人已投案

家电

4.打包子应用 投票

来源:博客园


(相关资料图)

接上回 最终得到这样的目录

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

组织子应用 并写点介绍文件

  1. 任意外面的目录 起个名字并建文件夹 django-polls

  2. 复制 polls 到django-polls

  3. 写 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.
  4. 写 LICENSE 文件

  5. 写 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 setupsetup()

    setup.cfg

    [metadata]name = django-pollsversion = 0.1description = A Django app to conduct web-based polls.long_description = file: README.rsturl = https://www.example.com/author = Your Nameauthor_email = yourname@example.comlicense = BSD-3-Clause  # Example licenseclassifiers =    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 = truepackages = find:python_requires = >=3.8install_requires =    Django >= X.Y  # Replace "X.Y" as appropriate

包含其他文件

默认情况下,包中仅包含 Python 模块和包。 要包含其他文件,我们需要创建一个 MANIFEST.in 文件。 上一步中提到的 setuptools 文档更详细地讨论了这个文件。 要包含模板、README.rst 和我们的 LICENSE 文件,创建一个文件 django-polls/MANIFEST.in ,其内容如下:

include LICENSEinclude README.rstrecursive-include polls/static *recursive-include polls/templates *

包含详细文档(可选)

  1. 创建一个空目录 django-polls/docs
  1. 补充一行代码 django-polls/MANIFEST.in
    recursive-include docs *

构建

D:\此电脑下分类\桌面\django-polls>D:\此电脑下分类\桌面\django-polls>python setup.py sdistrunning sdistrunning egg_infocreating django_polls.egg-infowriting django_polls.egg-info\PKG-INFOwriting dependency_links to django_polls.egg-info\dependency_links.txt........

最终结果

关键词: 其他文件 这个文件 我们需要