自定义一个python pip包

新建一个目录
mkdir example

基本说明文件

  • README.rst
  • LICENSE
  • setup.cfg
  • setup.py
  • MANIFEST.in
  • docs

example/README.rst

点击查看代码
=====
example
=====

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 = [
        ...
        'example',
    ]

2. Include the polls URLconf in your project urls.py like this::

    path('example/', 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/example/ to participate in the poll.

example/setup.cfg

点击查看代码
[metadata]
name = example
version = 0.1
description = A Django app to conduct Web-based example
long_description = file: README.rst
url = https://www.example.com/
author = Your Name
author_email = yourname@example.com
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.6
    Programming Language :: Python :: 3.7
    Programming Language :: Python :: 3.8
    Topic :: Internet :: WWW/HTTP
    Topic :: Internet :: WWW/HTTP :: Dynamic Content

[options]
include_package_data = true
packages = find:
python_requires = >=3.6
install_requires =
    Django >= X.Y  # Replace "X.Y" as appropriate
example/setup.py
from setuptools import setup

setup()
django-polls/MANIFEST.in
include LICENSE
include README.rst
recursive-include polls/static *
recursive-include polls/templates *
recursive-include docs *

文件定义后 将包文件 demo 放入

ptyhon setup.py sdist 
  • 在 dest 目录下 会有一个压缩包文件

参考来源 django 官网

https://docs.djangoproject.com/zh-hans/3.2/intro/reusable-apps/

源码地址

git@gitee.com:guanchaoguo/demo-pip-django-package.git

posted @ 2022-11-15 10:52  vx_guanchaoguo0  阅读(58)  评论(0编辑  收藏  举报