Skip to content
Myr

Merge pull request #1588 from Akasurde/i_1465

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Updated documentation for Setuptools

authored by Kenneth Reitz · committed by Kenneth Reitz · parents b4240e6, 2fe8e81 · Browse files · 1 file+13 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+13 added−18 removed

  • other:+13 added−18 removed

1 file+13 added−18 removed

modified:docs/patterns/distribute.rst+13 added-18 removed
1.. _distribute-deployment:23Deploying with Distribute3Deploying with Setuptools4=========================56`distribute`_, formerly setuptools, is an extension library that is7commonly used to (like the name says) distribute Python libraries and8extensions. It extends distutils, a basic module installation system6`Setuptools`_, is an extension library that is commonly used to7(like the name says) distribute Python libraries and8extensions. It extends distutils, a basic module installation system9shipped with Python to also support various more complex constructs that10make larger applications easier to distribute:1112- **support for dependencies**: a library or application can declare a
14 unmodified lines
27are distributed with either distribute, the older setuptools or distutils.2829In this case we assume your application is called30:file:`yourapplication.py` and you are not using a module, but a :ref:`package31<larger-applications>`. Distributing resources with standard modules is32not supported by `distribute`_ so we will not bother with it. If you have33not yet converted your application into a package, head over to the34:ref:`larger-applications` pattern to see how this can be done.31<larger-applications>`. If you have not yet converted your application into32a package, head over to the :ref:`larger-applications` pattern to see33how this can be done.3435A working deployment with distribute is the first step into more complex36and more automated deployment scenarios. If you want to fully automate37the process, also read the :ref:`fabric-deployment` chapter.3839Basic Setup Script40------------------4143Because you have Flask running, you either have setuptools or distribute44available on your system anyways. If you do not, fear not, there is a45script to install it for you: `distribute_setup.py`_. Just download and42Because you have Flask running, you have setuptools available on your system anyways.43Flask already depends upon setuptools. If you do not, fear not, there is a44script to install it for you: `ez_setup.py`_. Just download and45run with your Python interpreter.4647Standard disclaimer applies: :ref:`you better use a virtualenv48<virtualenv>`.
1 unmodified line
50Your setup code always goes into a file named :file:`setup.py` next to your51application. The name of the file is only convention, but because52everybody will look for a file with that name, you better not change it.5355Yes, even if you are using `distribute`, you are importing from a package56called `setuptools`. `distribute` is fully backwards compatible with57`setuptools`, so it also uses the same import name.5854A basic :file:`setup.py` file for a Flask application looks like this::5556 from setuptools import setup57
63 unmodified lines
121 'SQLAlchemy>=0.6',122 'BrokenPackage>=0.7,<=1.0'123 ]124130I mentioned earlier that dependencies are pulled from PyPI. What if you125As mentioned earlier, dependencies are pulled from PyPI. What if you126want to depend on a package that cannot be found on PyPI and won't be127because it is an internal package you don't want to share with anyone?128Just still do as if there was a PyPI entry for it and provide a list of129alternative locations where distribute should look for tarballs::
25 unmodified lines
155folder instead of copying the data over. You can then continue to work on156the code without having to run `install` again after each change.157158164.. _distribute: https://pypi.python.org/pypi/distribute159.. _pip: https://pypi.python.org/pypi/pip166.. _distribute_setup.py: http://python-distribute.org/distribute_setup.py160.. _ez_setup.py: https://bootstrap.pypa.io/ez_setup.py161.. _Setuptools: https://pythonhosted.org/setuptools