跳转至

PyPi发布

注册

前往 https://pypi.org/ 注册账号。

setup模板

该文件用于对库进行说明、设置

import os
from setuptools import find_packages, setup

import popup_field

version = popup_field.__version__

with open(os.path.join(os.path.dirname(__file__), 'README.md')) as readme:
    README = readme.read()

with open(os.path.join(os.path.dirname(__file__), 'HISTORY.md')) as history:
    HISTORY = history.read()

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

setup(
    name='django-popup-field',
    version=version,
    description='A popup field for django which can create\\update\\delete ForeignKey and ManyToManyField instance by popup windows.',
    long_description=README + '\n\n' + HISTORY,
    license='BSD 3-Clause License',
    packages=[
        'popup_field'
    ],
    include_package_data=True,
    install_requires=[
    ],
    url='https://github.com/yinkh/django-popup-field.git',
    author='Yin KangHong',
    author_email='614457662@qq.com',
    keywords='django-popup-field',
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: MIT License',
        'Operating System :: OS Independent',
        'Programming Language :: Python :: 3',
        'Topic :: Software Development :: Libraries',
        'Environment :: Web Environment',
        'Framework :: Django',
    ],
)

LICENSE模板

该文件用于声明授权

BSD 3-Clause License

Copyright (c) 2018 Yin KangHong(殷康红)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
  list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
  contributors may be used to endorse or promote products derived from
  this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in模板

该文件用于指定会打包涵盖的文件

include LICENSE
include README.md
include HISTORY.md
recursive-include popup_field *
global-exclude *.pyc

编译

  • tar.gz
 python setup.py sdist build
  • wheel
pip install wheel
python setup.py bdist_wheel --universal

上传

sudo pip install twine
twine upload dist/*

Demo Site

使用Django实现一个测试站点时,需要在settings里声明:

PACKAGE_DIR = os.path.dirname(BASE_DIR)
if PACKAGE_DIR not in sys.path:
    sys.path.insert(0, PACKAGE_DIR)

以保证该库能在INSTALLED_APPS中被正确引用。