install.rst
This file
Path
docs/tutorial/install.rst
88 lines · 2.7 KiB
Last changed by
Merge branch '2.3.x'David Lordbefore adoption15a0d4a
History of this fileTake it
The walk stopped after 200 commits: lines older than 0ae0f59 point at it.
Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 1–3why, one step back1Make the Project Installable2============================3Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
lines 4–7why, one step back4Making your project installable means that you can build a *wheel* file and install that5in another environment, just like you installed Flask in your project's environment.6This makes deploying your project the same as installing any other library, so you're7using all the standard Python tools to manage everything.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 8–29why, one step back89Installing also comes with other benefits that might not be obvious from10the tutorial or as a new Python user, including:1112* Currently, Python and Flask understand how to use the ``flaskr``13 package only because you're running from your project's directory.14 Installing means you can import it no matter where you run from.1516* You can manage your project's dependencies just like other packages17 do, so ``pip install yourproject.whl`` installs them.1819* Test tools can isolate your test environment from your development20 environment.2122.. note::23 This is being introduced late in the tutorial, but in your future24 projects you should always start with this.252627Describe the Project28--------------------29Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
line 30why, one step back30The ``pyproject.toml`` file describes your project and how to build it.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 31why, one step back31Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
lines 32–33why, one step back32.. code-block:: toml33 :caption: ``pyproject.toml``Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 34why, one step back34Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
lines 35–40why, one step back35 [project]36 name = "flaskr"37 version = "1.0.0"38 dependencies = [39 "flask",40 ]Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 41why, one step back41Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
line 42why, one step back42 [build-system]Merge branch '2.3.x'David Lordbefore adoption15a0d4a
lines 43–44why, one step back43 requires = ["flit_core<4"]44 build-backend = "flit_core.buildapi"Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 45why, one step back45Merge branch '2.3.x'David Lordbefore adoption15a0d4a
lines 46–47why, one step back46See the official `Packaging tutorial <packaging tutorial_>`_ for more47explanation of the files and options used.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
line 48why, one step back48Merge branch '2.1.x'David Lordbefore adoption9e2e1de
line 49why, one step back49.. _packaging tutorial: https://packaging.python.org/tutorials/packaging-projects/Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 50–60why, one step back505152Install the Project53-------------------5455Use ``pip`` to install your project in the virtual environment.5657.. code-block:: none5859 $ pip install -e .60Merge pull request #4947 from pallets/pyprojectDavid Lordbefore adoption78b42b9
lines 61–64why, one step back61This tells pip to find ``pyproject.toml`` in the current directory and install the62project in *editable* or *development* mode. Editable mode means that as you make63changes to your local code, you'll only need to re-install if you change the metadata64about the project, such as its dependencies.Merge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 65–83why, one step back6566You can observe that the project is now installed with ``pip list``.6768.. code-block:: none6970 $ pip list7172 Package Version Location73 -------------- --------- ----------------------------------74 click 6.775 Flask 1.076 flaskr 1.0.0 /home/user/Projects/flask-tutorial77 itsdangerous 0.2478 Jinja2 2.1079 MarkupSafe 1.080 pip 9.0.381 Werkzeug 0.14.18283Nothing changes from how you've been running your project so far.Merge pull request #4646 from pallets/cli-app-envDavid Lordbefore adoptionae54727
line 84why, one step back84``--app`` is still set to ``flaskr`` and ``flask run`` still runsMerge branch '2.0.x'David Lordbefore adoption0ae0f59
lines 85–88why, one step back85the application, but you can call it from anywhere, not just the86``flask-tutorial`` directory.8788Continue to :doc:`tests`.