Skip to content
Myr

install.rst

This file

Path

docs/tutorial/install.rst

114 lines · 3.5 KiB

Last changed by

Merge branch '1.0.x'David Lordbefore adoption1351d0a

History of this file

Take it

The walk stopped after 200 commits: lines older than 35afec3 point at it.

Merge branch '1.0-maintenance'David Lordbefore adoption35afec3

lines 1–72why, one step back
1Make the Project Installable
2============================34Making your project installable means that you can build a5*distribution* file and install that in another environment, just like6you installed Flask in your project's environment. This makes deploying7your project the same as installing any other library, so you're using8all the standard Python tools to manage everything.910Installing also comes with other benefits that might not be obvious from11the tutorial or as a new Python user, including:1213* Currently, Python and Flask understand how to use the ``flaskr``14 package only because you're running from your project's directory.15 Installing means you can import it no matter where you run from.1617* You can manage your project's dependencies just like other packages18 do, so ``pip install yourproject.whl`` installs them.1920* Test tools can isolate your test environment from your development21 environment.2223.. note::24 This is being introduced late in the tutorial, but in your future25 projects you should always start with this.262728Describe the Project29--------------------3031The ``setup.py`` file describes your project and the files that belong32to it.3334.. code-block:: python35 :caption: ``setup.py``3637 from setuptools import find_packages, setup3839 setup(40 name='flaskr',41 version='1.0.0',42 packages=find_packages(),43 include_package_data=True,44 zip_safe=False,45 install_requires=[46 'flask',47 ],48 )495051``packages`` tells Python what package directories (and the Python files52they contain) to include. ``find_packages()`` finds these directories53automatically so you don't have to type them out. To include other54files, such as the static and templates directories,55``include_package_data`` is set. Python needs another file named56``MANIFEST.in`` to tell what this other data is.5758.. code-block:: none59 :caption: ``MANIFEST.in``6061 include flaskr/schema.sql62 graft flaskr/static63 graft flaskr/templates64 global-exclude *.pyc6566This tells Python to copy everything in the ``static`` and ``templates``67directories, and the ``schema.sql`` file, but to exclude all bytecode68files.6970See the `official packaging guide`_ for another explanation of the files71and options used.72

Merge branch '1.0.x'David Lordbefore adoption1351d0a

line 73why, one step back
73.. _official packaging guide: https://packaging.python.org/tutorials/packaging-projects/

Merge branch '1.0-maintenance'David Lordbefore adoption35afec3

lines 74–82why, one step back
74
7576Install the Project77-------------------7879Use ``pip`` to install your project in the virtual environment.8081.. code-block:: none82

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 83why, one step back
83 $ pip install -e .

Merge branch '1.0-maintenance'David Lordbefore adoption35afec3

lines 84–93why, one step back
84
85This tells pip to find ``setup.py`` in the current directory and install86it in *editable* or *development* mode. Editable mode means that as you87make changes to your local code, you'll only need to re-install if you88change the metadata about the project, such as its dependencies.8990You can observe that the project is now installed with ``pip list``.9192.. code-block:: none93

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 94why, one step back
94 $ pip list

Merge branch '1.0-maintenance'David Lordbefore adoption35afec3

lines 95–110why, one step back
95
96 Package Version Location97 -------------- --------- ----------------------------------98 click 6.799 Flask 1.0100 flaskr 1.0.0 /home/user/Projects/flask-tutorial101 itsdangerous 0.24102 Jinja2 2.10103 MarkupSafe 1.0104 pip 9.0.3105 setuptools 39.0.1106 Werkzeug 0.14.1107 wheel 0.30.0108109Nothing changes from how you've been running your project so far.110``FLASK_APP`` is still set to ``flaskr`` and ``flask run`` still runs

Merge branch '1.0-maintenance'David Lordbefore adoptionac6746d

lines 111–112why, one step back
111the application, but you can call it from anywhere, not just the
112``flask-tutorial`` directory.

Merge branch '1.0-maintenance'David Lordbefore adoption35afec3

lines 113–114why, one step back
113
114Continue to :doc:`tests`.