Skip to main content

A small example package

Project description

1.创建项目
目录结构:
/example_pkg
  /example_pkg
    __init__.py
2.编辑example_pkg/init.py
name = "example_pkg"

* 这只是为了可以在后面确认它是否正确安装
3.创建包文件
/example_pkg
  /example_pkg
    __init__.py
  setup.py
  LICENSE
  README.md
4.创建的setup.py
import setuptools

with open("README.md", "r") as fh:
    long_description = fh.read()

setuptools.setup(
    name="example_pkg",
    version="0.0.1",
    author="Example Author",
    author_email="author@example.com",
    description="A small example package",
    long_description=long_description,
    long_description_content_type="text/markdown",
    url="https://github.com/pypa/example-project",
    packages=setuptools.find_packages(),
    classifiers=(
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
    ),
)
5.创建许可证 LICENSE
Copyright (c) 2018 The Python Packaging Authority

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6.确认安装setuptools并wheel 安装了最新版本
pip install --upgrade pip
python3 -m pip install --upgrade setuptools wheel
7.编译dist文件
python3 setup.py sdist bdist_wheel

dist/
  example_pkg-0.0.1-py3-none-any.whl
  example_pkg-0.0.1.tar.gz
8.安装twine
python3 -m pip install --upgrade twine
9.运行Twine以上传dist
twine upload dist/*
备注
创建 .pypirc
[distutils]
index-servers =
  pypi
  pypitest

[pypi]
repository=https://pypi.python.org/pypi
username=zhangxin
password=Zx1234567890.

[pypitest]
repository=https://testpypi.python.org/pypi
username=zhangxin
password=Zx1234567890.


发布地址(*创建账号后需要邮件激活)
https://pypi.org/
https://test.pypi.org/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sp_utils-0.0.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

sp_utils-0.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file sp_utils-0.0.2.tar.gz.

File metadata

  • Download URL: sp_utils-0.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sp_utils-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2ef3da232dce22a97c28544225c9c4dd9e9cbd9001db5f86c5144a67998ef535
MD5 790de423aae478f73aeeb5269df3987d
BLAKE2b-256 d6d5fd59ac98faaff9b13e8d6aae7b0be1f7428ebb204ec2a13d37f7de559312

See more details on using hashes here.

File details

Details for the file sp_utils-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sp_utils-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bd6201de06a11817f1aefedb1b0767e2ce6c196648dae826e0a331fb079c1483
MD5 8e834ef684a7a683bde571fa460163a9
BLAKE2b-256 8ce8387b7a206de6dfa89bd8fdc34aec80be7c4e84ddd4f5bf2fc239f2f8a923

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page