Skip to content
Myr

Merge pull request #1795 from cgoldberg/update-docs-setuptools

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

update docs and refer to setuptools

authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents e45e17c, 28b36f6 · Browse files · 1 file+20 added−21 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+20 added−21 removed

  • other:+20 added−21 removed

1 file+20 added−21 removed

modified:docs/patterns/distribute.rst+20 added-21 removed
2 unmodified lines
3Deploying with Setuptools4=========================56`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:7distribute Python libraries and extensions. It extends distutils, a basic8module installation system shipped with Python to also support various more9complex constructs that make larger applications easier to distribute:1011- **support for dependencies**: a library or application can declare a12 list of other libraries it depends on which will be installed13 automatically for you.14- **package registry**: setuptools registers your package with your15 Python installation. This makes it possible to query information16 provided by one package from another package. The best known feature of17 this system is the entry point support which allows one package to19 declare an "entry point" another package can hook into to extend the18 declare an "entry point" that another package can hook into to extend the19 other package.21- **installation manager**: :command:`easy_install`, which comes with distribute22 can install other libraries for you. You can also use `pip`_ which23 sooner or later will replace :command:`easy_install` which does more than just24 installing packages for you.20- **installation manager**: :command:`pip` can install other libraries for you.2126Flask itself, and all the libraries you can find on the cheeseshop27are distributed with either distribute, the older setuptools or distutils.22If you have Python 2 (>=2.7.9) or Python 3 (>=3.4) installed from python.org,23you will already have pip and setuptools on your system. Otherwise, you24will need to install them yourself.2526Flask itself, and all the libraries you can find on PyPI are distributed with27either 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>`. 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 complex35A working deployment with setuptools 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 Script
25 unmodified lines
65 install_requires=['Flask']66 )6768Please keep in mind that you have to list subpackages explicitly. If you69want distribute to lookup the packages for you automatically, you can use69want setuptools to lookup the packages for you automatically, you can use70the `find_packages` function::7172 from setuptools import setup, find_packages73
3 unmodified lines
77 )7879Most parameters to the `setup` function should be self explanatory,80`include_package_data` and `zip_safe` might not be.81`include_package_data` tells distribute to look for a :file:`MANIFEST.in` file81`include_package_data` tells setuptools to look for a :file:`MANIFEST.in` file82and install all the entries that match as package data. We will use this83to distribute the static files and templates along with the Python module84(see :ref:`distributing-resources`). The `zip_safe` flag can be used to85force or prevent zip Archive creation. In general you probably don't want
7 unmodified lines
93----------------------9495If you try to install the package you just created, you will notice that96folders like :file:`static` or :file:`templates` are not installed for you. The97reason for this is that distribute does not know which files to add for97reason for this is that setuptools does not know which files to add for98you. What you should do, is to create a :file:`MANIFEST.in` file next to your99:file:`setup.py` file. This file lists all the files that should be added to100your tarball::101
7 unmodified lines
109110Declaring Dependencies111----------------------112113Dependencies are declared in the `install_requires` parameter as list.113Dependencies are declared in the `install_requires` parameter as a list.114Each item in that list is the name of a package that should be pulled from115PyPI on installation. By default it will always use the most recent116version, but you can also provide minimum and maximum version117requirements. Here some examples::
6 unmodified lines
124125As 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::128Just do it as if there was a PyPI entry and provide a list of129alternative locations where setuptools should look for tarballs::130131 dependency_links=['http://example.com/yourfiles']132133Make sure that page has a directory listing and the links on the page are134pointing to the actual tarballs with their correct filenames as this is135how distribute will find the files. If you have an internal company136server that contains the packages, provide the URL to that server there.135how setuptools will find the files. If you have an internal company136server that contains the packages, provide the URL to that server.137138139Installing / Developing140-----------------------
15 unmodified lines
156the code without having to run `install` again after each change.157158159.. _pip: https://pypi.python.org/pypi/pip160.. _ez_setup.py: https://bootstrap.pypa.io/ez_setup.py160.. _Setuptools: https://pythonhosted.org/setuptools