Skip to content
Myr

update docs and refer to setuptools

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

authored by Corey Goldberg · committed by Corey Goldberg · parent 317d603 · Browse files · 1 file+17 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+17 added−18 removed

  • other:+17 added−18 removed

1 file+17 added−18 removed

modified:docs/patterns/distribute.rst+17 added-18 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`_ which20- **installation manager**: :command:`easy_install`, which comes with setuptools21 can install other libraries for you. You can also use :command:`pip`_ which22 sooner or later will replace :command:`easy_install` which does more than just23 installing packages for you.2426Flask itself, and all the libraries you can find on the cheeseshop27are distributed with either distribute, the older setuptools or distutils.25Flask itself, and all the libraries you can find on PyPI are distributed with26either setuptools or distutils.2728In this case we assume your application is called29:file:`yourapplication.py` and you are not using a module, but a :ref:`package30<larger-applications>`. If you have not yet converted your application into31a package, head over to the :ref:`larger-applications` pattern to see32how this can be done.3335A working deployment with distribute is the first step into more complex34A working deployment with setuptools is the first step into more complex35and more automated deployment scenarios. If you want to fully automate36the process, also read the :ref:`fabric-deployment` chapter.3738Basic Setup Script
25 unmodified lines
64 install_requires=['Flask']65 )6667Please keep in mind that you have to list subpackages explicitly. If you69want distribute to lookup the packages for you automatically, you can use68want setuptools to lookup the packages for you automatically, you can use69the `find_packages` function::7071 from setuptools import setup, find_packages72
3 unmodified lines
76 )7778Most parameters to the `setup` function should be self explanatory,79`include_package_data` and `zip_safe` might not be.81`include_package_data` tells distribute to look for a :file:`MANIFEST.in` file80`include_package_data` tells setuptools to look for a :file:`MANIFEST.in` file81and install all the entries that match as package data. We will use this82to distribute the static files and templates along with the Python module83(see :ref:`distributing-resources`). The `zip_safe` flag can be used to84force or prevent zip Archive creation. In general you probably don't want
7 unmodified lines
92----------------------9394If you try to install the package you just created, you will notice that95folders like :file:`static` or :file:`templates` are not installed for you. The97reason for this is that distribute does not know which files to add for96reason for this is that setuptools does not know which files to add for97you. What you should do, is to create a :file:`MANIFEST.in` file next to your98:file:`setup.py` file. This file lists all the files that should be added to99your tarball::100
7 unmodified lines
108109Declaring Dependencies110----------------------111113Dependencies are declared in the `install_requires` parameter as list.112Dependencies are declared in the `install_requires` parameter as a list.113Each item in that list is the name of a package that should be pulled from114PyPI on installation. By default it will always use the most recent115version, but you can also provide minimum and maximum version116requirements. Here some examples::
6 unmodified lines
123124As mentioned earlier, dependencies are pulled from PyPI. What if you125want to depend on a package that cannot be found on PyPI and won't be126because 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::127Just do it as if there was a PyPI entry and provide a list of128alternative locations where setuptools should look for tarballs::129130 dependency_links=['http://example.com/yourfiles']131132Make sure that page has a directory listing and the links on the page are133pointing 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.134how setuptools will find the files. If you have an internal company135server that contains the packages, provide the URL to that server.136137138Installing / Developing139-----------------------
21 unmodified lines