==================================================
Building and Distributing Packages with Setuptools
==================================================
``Setuptools`` is a collection of enhancements to the Python ``distutils``
(for Python 2.6 and up) that allow developers to more easily build and
distribute Python packages, especially ones that have dependencies on other
packages.
Packages built and distributed using ``setuptools`` look to the user like
ordinary Python packages based on the ``distutils``. Your users don't need to
install or even know about setuptools in order to use them, and you don't
have to include the entire setuptools package in your distributions. By
including just a single `bootstrap module`_ (a 12K .py file), your package will
automatically download and install ``setuptools`` if the user is building your
package from source and doesn't have a suitable version already installed.
.. _bootstrap module: https://bootstrap.pypa.io/ez_setup.py
Feature Highlights:
* Automatically find/download/install/upgrade dependencies at build time using
the `EasyInstall tool <easy_install.html>`_,
which supports downloading via HTTP, FTP, Subversion, and SourceForge, and
automatically scans web pages linked from PyPI to find download links. (It's
the closest thing to CPAN currently available for Python.)
* Create `Python Eggs <http://peak.telecommunity.com/DevCenter/PythonEggs>`_ -
a single-file importable distribution format
* Enhanced support for accessing data files hosted in zipped packages.
* Automatically include all packages in your source tree, without listing them
individually in setup.py
* Automatically include all relevant files in your source distributions,
without needing to create a ``MANIFEST.in`` file, and without having to force
regeneration of the ``MANIFEST`` file when your source tree changes.
* Automatically generate wrapper scripts or Windows (console and GUI) .exe
files for any number of "main" functions in your project. (Note: this is not
a py2exe replacement; the .exe files rely on the local Python installation.)
* Transparent Pyrex support, so that your setup.py can list ``.pyx`` files and
still work even when the end-user doesn't have Pyrex installed (as long as
you include the Pyrex-generated C in your source distribution)
* Command aliases - create project-specific, per-user, or site-wide shortcut
names for commonly used commands and options
* PyPI upload support - upload your source distributions and eggs to PyPI
* Deploy your project in "development mode", such that it's available on
``sys.path``, yet can still be edited directly from its source checkout.
* Easily extend the distutils with new commands or ``setup()`` arguments, and
distribute/reuse your extensions for multiple projects, without copying code.
* Create extensible applications and frameworks that automatically discover
extensions, using simple "entry points" declared in a project's setup script.
.. contents:: **Table of Contents**
.. _ez_setup.py: `bootstrap module`_
-----------------
Developer's Guide
-----------------
Installing ``setuptools``
=========================
Please follow the `EasyInstall Installation Instructions`_ to install the
current stable version of setuptools. In particular, be sure to read the
section on `Custom Installation Locations`_ if you are installing anywhere
other than Python's ``site-packages`` directory.
.. _EasyInstall Installation Instructions: easy_install.html#installation-instructions
.. _Custom Installation Locations: easy_install.html#custom-installation-locations
If you want the current in-development version of setuptools, you should first
install a stable version, and then run::
ez_setup.py setuptools==dev
This will download and install the latest development (i.e. unstable) version
of setuptools from the Python Subversion sandbox.
Basic Use
=========
For basic use of setuptools, just import things from setuptools instead of
the distutils. Here's a minimal setup script using setuptools::
from setuptools import setup, find_packages
setup(
name="HelloWorld",
version="0.1",
packages=find_packages(),
)
As you can see, it doesn't take much to use setuptools in a project.
Run that script in your project folder, alongside the Python packages
you have developed.
Invoke that script to produce eggs, upload to
PyPI, and automatically include all packages in the directory where the
setup.py lives. See the `Command Reference`_ section below to see what
commands you can give to this setup script. For example,
to produce a source distribution, simply invoke::
python setup.py sdist
Of course, before you release your project to PyPI, you'll want to add a bit
more information to your setup script to help people find or learn about your
project. And maybe your project will have grown by then to include a few
dependencies, and perhaps some data files and scripts::
from setuptools import setup, find_packages
setup(
name="HelloWorld",
version="0.1",
packages=find_packages(),
scripts=['say_hello.py'],
# Project uses reStructuredText, so ensure that the docutils get
# installed or upgraded on the target machine
install_requires=['docutils>=0.3'],
package_data={
# If any package contains *.txt or *.rst files, include them:
'': ['*.txt', '*.rst'],
# And include any *.msg files found in the 'hello' package, too:
'hello': ['*.msg'],
},
# metadata for upload to PyPI
author="Me",
author_email="me@example.com",
description="This is an Example Package",
license="PSF",
keywords="hello world example examples",
url="http://example.com/HelloWorld/", # project home page, if any
# could also include long_description, download_url, classifiers, etc.
)
In the sections that follow, we'll explain what most of these ``setup()``
arguments do (except for the metadata ones), and the various ways you might use
them in your own project(s).
Specifying Your Project's Version
---------------------------------
Setuptools can work well with most versioning schemes; there are, however, a
few special things to watch out for, in order to ensure that setuptools and
EasyInstall can always tell what version of your package is newer than another
version. Knowing these things will also help you correctly specify what
versions of other projects your project depends on.
A version consists of an alternating series of release numbers and pre-release
or post-release tags. A release number is a series of digits punctuated by
dots, such as ``2.4`` or ``0.5``. Each series of digits is treated
numerically, so releases ``2.1`` and ``2.1.0`` are different ways to spell the
same release number, denoting the first subrelease of release 2. But ``2.10``
is the *tenth* subrelease of release 2, and so is a different and newer release
from ``2.1`` or ``2.1.0``. Leading zeros within a series of digits are also
ignored, so ``2.01`` is the same as ``2.1``, and different from ``2.0.1``.
Following a release number, you can have either a pre-release or post-release
tag. Pre-release tags make a version be considered *older* than the version
they are appended to. So, revision ``2.4`` is *newer* than revision ``2.4c1``,
which in turn is newer than ``2.4b1`` or ``2.4a1``. Postrelease tags make
a version be considered *newer* than the version they are appended to. So,
revisions like ``2.4-1`` and ``2.4pl3`` are newer than ``2.4``, but are *older*
than ``2.4.1`` (which has a higher release number).
A pre-release tag is a series of letters that are alphabetically before
"final". Some examples of prerelease tags would include ``alpha``, ``beta``,
``a``, ``c``, ``dev``, and so on. You do not have to place a dot or dash
before the prerelease tag if it's immediately
没有合适的资源?快使用搜索试试~ 我知道了~
setuptools-33.1.1.zip
共157个文件
py:110个
txt:19个
exe:6个
5星 · 超过95%的资源 需积分: 50 159 下载量 105 浏览量
2017-11-10
00:25:11
上传
评论 1
收藏 686KB ZIP 举报
温馨提示
windows下python安装第三方模块是报错“ImportError: No module named setuptools”,发现时未安装setuptools,按网上方法下载了ez_setup.py进行安装时又报错:“使用“2”个参数调用“DownloadFile”时发生异常:“基础连接已经关闭: 发送时发生错误。”发现时网络问题,下载不了setuptools-33.1.1.zip,后经科学上网法,拿到了setuptools-33.1.1.zip特分享出来以供需要的同学。
资源推荐
资源详情
资源评论
收起资源包目录
setuptools-33.1.1.zip (157个子文件)
launcher.c 10KB
setup.cfg 393B
msvc-build-launcher.cmd 2KB
theme.conf 71B
pygments.css 3KB
nature.css_t 4KB
gui-64.exe 74KB
cli-64.exe 73KB
cli-32.exe 64KB
gui-32.exe 64KB
gui.exe 64KB
cli.exe 64KB
indexsidebar.html 308B
index.html 174B
external.html 92B
MANIFEST.in 430B
pytest.ini 487B
tox.ini 151B
LICENSE 1KB
Makefile 2KB
PKG-INFO 2KB
PKG-INFO 2KB
pyparsing.py 224KB
__init__.py 101KB
easy_install.py 84KB
package_index.py 39KB
dist.py 37KB
msvc.py 36KB
test_resources.py 30KB
six.py 29KB
specifiers.py 27KB
egg_info.py 24KB
test_easy_install.py 23KB
appdirs.py 22KB
bdist_egg.py 17KB
test_config.py 17KB
test_manifest.py 16KB
config.py 16KB
sandbox.py 14KB
test_sdist.py 13KB
build_ext.py 13KB
version.py 11KB
__init__.py 11KB
build_py.py 9KB
test_egg_info.py 9KB
test.py 9KB
test_packageindex.py 8KB
markers.py 8KB
ssl_support.py 8KB
develop.py 7KB
upload_docs.py 7KB
setup.py 7KB
sdist.py 7KB
archive_util.py 6KB
test_find_packages.py 6KB
test_windows_wrappers.py 6KB
conf.py 6KB
test_msvc.py 6KB
depends.py 6KB
monkey.py 5KB
test_pkg_resources.py 5KB
glob.py 5KB
test_develop.py 5KB
setopt.py 5KB
__init__.py 5KB
py36compat.py 5KB
install.py 5KB
requirements.py 4KB
test_sandbox.py 4KB
install_lib.py 4KB
test_namespaces.py 4KB
test_install_scripts.py 3KB
namespaces.py 3KB
test_integration.py 3KB
test_pypi.py 3KB
py36compat.py 3KB
__init__.py 2KB
install_scripts.py 2KB
alias.py 2KB
manual_test.py 2KB
test_test.py 2KB
test_dist_info.py 2KB
site-patch.py 2KB
install_egg_info.py 2KB
rotate.py 2KB
contexts.py 2KB
server.py 2KB
lib2to3_ex.py 2KB
extension.py 2KB
test_upload_docs.py 2KB
py31compat.py 2KB
environment.py 2KB
bootstrap.py 2KB
bdist_rpm.py 1KB
test_build_ext.py 1KB
_structures.py 1KB
namespaces.py 1KB
test_setuptools.py 1KB
upload.py 1KB
test_bdist_egg.py 1010B
共 157 条
- 1
- 2
资源评论
- wolfyayaya2019-08-01公网没下载到,感谢帮到我,感谢上传。
- beyondsyq2018-11-22可以正常安装。
良非凉
- 粉丝: 1479
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
- 以下是一个简化的示例,它使用pygame库来模拟烟花动画的框架.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功