首页 > 其他分享 >4.打包子应用 投票

4.打包子应用 投票

时间:2023-02-18 11:45:07浏览次数:48  
标签:polls Python setup py django 投票 应用 include 包子

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

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 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 *



包含详细文档(可选)

  1. 创建一个空目录 django-polls/docs

  1. 补充一行代码 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
........

最终结果


image


image

标签:polls,Python,setup,py,django,投票,应用,include,包子
From: https://www.cnblogs.com/hugboy/p/17132239.html

相关文章

  • 使用Docker启动并运行Flask应用
    (一)拉取Python镜像dockerpullpython#查看当前主机中存在的镜像dockerimages(二)编写flask应用1.创建一个目录mkdirflask_demo#进入目录中cdflask_de......
  • Yar的RPC的应用-php
    RPC,即RemoteProcedureCall(远程过程调用),调用远程计算机上的服务,就像调用本地服务一样。RPC可以很好的解耦系统。RPC可基于HTTP或TCP协议,WebService就是基于HTTP......
  • Zookeeper典型应用场景汇总
    Zookeeper典型应用场景汇总数据发布与订阅(配置中心)发布与订阅模型,即所谓的配置中心,顾名思义就是发布者将数据发布到ZK节点上,供订阅者动态获取数据,实现配置信息的集中......
  • 《程序是怎样跑起来的》·第九章 操作系统和应用的关系
    阅读正文前,让我们先回答下面的问题来热热身吧:监控程序的主要功能是什么?在操作系统上运行的程序称为什么?调用操作系统功能称为什么?WindowsVista是多少位的操作系统?......
  • SnowFlake 雪花算法详解与实现 & MP中的应用
    BackGround现在的服务基本是分布式,微服务形式的,而且大数据量也导致分库分表的产生,对于水平分表就需要保证表中id的全局唯一性。对于MySQL而言,一个表中的主键id一般......
  • 蓝牙5.0对物联网应用的影响
    多年来,蓝牙一直在革新无线技术。其最新的5.0版本提供了显着改进的体验——明显更快的速度、更大的范围和广泛的数据广播功能,所有这些都大大扩大了其市场潜力。其使设备配对......
  • 5G如何加速无人快递?5G智能网关新应用
    网上购物已经是现代生活的主流消费方式之一,伴随网购的繁荣,物流快递行业也进入到一个最火热的时期。而在这之中,有限的快递配送能力和日益增长的配送需求的矛盾持续凸显,因此......
  • 测试公开课资料系列02--Postman之chai.js断言应用
    前言如果要挖井,就要挖到水出为止。明晚公开课给大家讲讲如何用chai.js断言,有用过postman只会右侧点来自动生成断言代码,或在公司应用postman的朋友们都来听听。一、c......
  • 如何将一个网站做成桌面应用
    1、答案是使用cefpython#coding=utf-8fromcefpython3importcefpythonascefimportplatformimportsys#pyinstaller-F-wtest3.py--hidden-importinspect......
  • 将 ASP.Net Core WebApi 应用打包至 Docker 镜像
    将ASP.NetCoreWebApi应用打包至Docker镜像运行环境为Windows10专业版21H1,DockerDesktop3.6.0(67351),DockerEngine20.10.81.ASP.NetCoreRuntime......