2025-04-10 15:52:02 -06:00
<!DOCTYPE html>
< html lang = "en" data-content_root = "../" >
< head >
< meta charset = "utf-8" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" / >
< meta name = "viewport" content = "width=device-width, initial-scale=1" >
2025-04-11 03:04:22 +00:00
< title > Make the Project Installable — Flask Documentation (3.2.x)< / title >
2025-04-10 15:52:02 -06:00
< link rel = "stylesheet" type = "text/css" href = "../_static/pygments.css?v=6625fa76" / >
< link rel = "stylesheet" type = "text/css" href = "../_static/flask.css?v=b87c8d14" / >
< script src = "../_static/documentation_options.js?v=56528222" > < / script >
< script src = "../_static/doctools.js?v=9bcbadda" > < / script >
< script src = "../_static/sphinx_highlight.js?v=dc90522c" > < / script >
< script data-project = "flask" data-version = "3.2.x" src = "../_static/describe_version.js?v=fa7f30d0" > < / script >
< link rel = "icon" href = "../_static/shortcut-icon.png" / >
< link rel = "index" title = "Index" href = "../genindex.html" / >
< link rel = "search" title = "Search" href = "../search.html" / >
2025-04-11 03:04:22 +00:00
< link rel = "next" title = "Test Coverage" href = "tests.html" / >
< link rel = "prev" title = "Blog Blueprint" href = "blog.html" / >
2025-04-10 15:52:02 -06:00
< / head > < body >
< div class = "related" role = "navigation" aria-label = "Related" >
< h3 > Navigation< / h3 >
< ul >
< li class = "right" style = "margin-right: 10px" >
< a href = "../genindex.html" title = "General Index"
accesskey="I">index< / a > < / li >
< li class = "right" >
< a href = "../py-modindex.html" title = "Python Module Index"
>modules< / a > |< / li >
< li class = "right" >
2025-04-11 03:04:22 +00:00
< a href = "tests.html" title = "Test Coverage"
2025-04-10 15:52:02 -06:00
accesskey="N">next< / a > |< / li >
< li class = "right" >
2025-04-11 03:04:22 +00:00
< a href = "blog.html" title = "Blog Blueprint"
2025-04-10 15:52:02 -06:00
accesskey="P">previous< / a > |< / li >
< li class = "nav-item nav-item-0" > < a href = "../index.html" > Flask Documentation (3.2.x)< / a > » < / li >
< li class = "nav-item nav-item-1" > < a href = "index.html" accesskey = "U" > Tutorial< / a > » < / li >
2025-04-11 03:04:22 +00:00
< li class = "nav-item nav-item-this" > < a href = "" > Make the Project Installable< / a > < / li >
2025-04-10 15:52:02 -06:00
< / ul >
2025-04-11 03:04:22 +00:00
< / div >
2025-04-10 15:52:02 -06:00
< div class = "document" >
< div class = "documentwrapper" >
< div class = "bodywrapper" >
< div class = "body" role = "main" >
2025-04-11 03:04:22 +00:00
< section id = "make-the-project-installable" >
< h1 > Make the Project Installable< a class = "headerlink" href = "#make-the-project-installable" title = "Link to this heading" > ¶< / a > < / h1 >
< p > Making your project installable means that you can build a < em > wheel< / em > file and install that
in another environment, just like you installed Flask in your project’ s environment.
This makes deploying your project the same as installing any other library, so you’ re
using all the standard Python tools to manage everything.< / p >
< p > Installing also comes with other benefits that might not be obvious from
the tutorial or as a new Python user, including:< / p >
< ul class = "simple" >
< li > < p > Currently, Python and Flask understand how to use the < code class = "docutils literal notranslate" > < span class = "pre" > flaskr< / span > < / code >
package only because you’ re running from your project’ s directory.
Installing means you can import it no matter where you run from.< / p > < / li >
< li > < p > You can manage your project’ s dependencies just like other packages
do, so < code class = "docutils literal notranslate" > < span class = "pre" > pip< / span > < span class = "pre" > install< / span > < span class = "pre" > yourproject.whl< / span > < / code > installs them.< / p > < / li >
< li > < p > Test tools can isolate your test environment from your development
environment.< / p > < / li >
< / ul >
< div class = "admonition note" >
< p class = "admonition-title" > Note< / p >
< p > This is being introduced late in the tutorial, but in your future
projects you should always start with this.< / p >
2025-04-10 15:52:02 -06:00
< / div >
2025-04-11 03:04:22 +00:00
< section id = "describe-the-project" >
< h2 > Describe the Project< a class = "headerlink" href = "#describe-the-project" title = "Link to this heading" > ¶< / a > < / h2 >
< p > The < code class = "docutils literal notranslate" > < span class = "pre" > pyproject.toml< / span > < / code > file describes your project and how to build it.< / p >
2025-04-10 15:52:02 -06:00
< div class = "literal-block-wrapper docutils container" id = "id1" >
2025-04-11 03:04:22 +00:00
< div class = "code-block-caption" > < span class = "caption-text" > < code class = "docutils literal notranslate" > < span class = "pre" > pyproject.toml< / span > < / code > < / span > < a class = "headerlink" href = "#id1" title = "Link to this code" > ¶< / a > < / div >
< div class = "highlight-toml notranslate" > < div class = "highlight" > < pre > < span > < / span > < span class = "k" > [project]< / span >
< span class = "n" > name< / span > < span class = "w" > < / span > < span class = "o" > =< / span > < span class = "w" > < / span > < span class = "s2" > " flaskr" < / span >
< span class = "n" > version< / span > < span class = "w" > < / span > < span class = "o" > =< / span > < span class = "w" > < / span > < span class = "s2" > " 1.0.0" < / span >
< span class = "n" > description< / span > < span class = "w" > < / span > < span class = "o" > =< / span > < span class = "w" > < / span > < span class = "s2" > " The basic blog app built in the Flask tutorial." < / span >
< span class = "n" > dependencies< / span > < span class = "w" > < / span > < span class = "o" > =< / span > < span class = "w" > < / span > < span class = "p" > [< / span >
< span class = "w" > < / span > < span class = "s2" > " flask" < / span > < span class = "p" > ,< / span >
< span class = "p" > ]< / span >
< span class = "k" > [build-system]< / span >
< span class = "n" > requires< / span > < span class = "w" > < / span > < span class = "o" > =< / span > < span class = "w" > < / span > < span class = "p" > [< / span > < span class = "s2" > " flit_core< 4" < / span > < span class = "p" > ]< / span >
< span class = "n" > build-backend< / span > < span class = "w" > < / span > < span class = "o" > =< / span > < span class = "w" > < / span > < span class = "s2" > " flit_core.buildapi" < / span >
2025-04-10 15:52:02 -06:00
< / pre > < / div >
< / div >
< / div >
2025-04-11 03:04:22 +00:00
< p > See the official < a class = "reference external" href = "https://packaging.python.org/tutorials/packaging-projects/" > Packaging tutorial< / a > for more
explanation of the files and options used.< / p >
2025-04-10 15:52:02 -06:00
< / section >
2025-04-11 03:04:22 +00:00
< section id = "install-the-project" >
< h2 > Install the Project< a class = "headerlink" href = "#install-the-project" title = "Link to this heading" > ¶< / a > < / h2 >
< p > Use < code class = "docutils literal notranslate" > < span class = "pre" > pip< / span > < / code > to install your project in the virtual environment.< / p >
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > $ pip install -e .
2025-04-10 15:52:02 -06:00
< / pre > < / div >
< / div >
2025-04-11 03:04:22 +00:00
< p > This tells pip to find < code class = "docutils literal notranslate" > < span class = "pre" > pyproject.toml< / span > < / code > in the current directory and install the
project in < em > editable< / em > or < em > development< / em > mode. Editable mode means that as you make
changes to your local code, you’ ll only need to re-install if you change the metadata
about the project, such as its dependencies.< / p >
< p > You can observe that the project is now installed with < code class = "docutils literal notranslate" > < span class = "pre" > pip< / span > < span class = "pre" > list< / span > < / code > .< / p >
< div class = "highlight-none notranslate" > < div class = "highlight" > < pre > < span > < / span > $ pip list
2025-04-10 15:52:02 -06:00
2025-04-11 03:04:22 +00:00
Package Version Location
-------------- --------- ----------------------------------
click 6.7
Flask 1.0
flaskr 1.0.0 /home/user/Projects/flask-tutorial
itsdangerous 0.24
Jinja2 2.10
MarkupSafe 1.0
pip 9.0.3
Werkzeug 0.14.1
2025-04-10 15:52:02 -06:00
< / pre > < / div >
< / div >
2025-04-11 03:04:22 +00:00
< p > Nothing changes from how you’ ve been running your project so far.
< code class = "docutils literal notranslate" > < span class = "pre" > --app< / span > < / code > is still set to < code class = "docutils literal notranslate" > < span class = "pre" > flaskr< / span > < / code > and < code class = "docutils literal notranslate" > < span class = "pre" > flask< / span > < span class = "pre" > run< / span > < / code > still runs
the application, but you can call it from anywhere, not just the
< code class = "docutils literal notranslate" > < span class = "pre" > flask-tutorial< / span > < / code > directory.< / p >
< p > Continue to < a class = "reference internal" href = "tests.html" > < span class = "doc" > Test Coverage< / span > < / a > .< / p >
2025-04-10 15:52:02 -06:00
< / section >
< / section >
< div class = "clearer" > < / div >
< / div >
< / div >
< / div >
< span id = "sidebar-top" > < / span >
< div class = "sphinxsidebar" role = "navigation" aria-label = "Main" >
< div class = "sphinxsidebarwrapper" >
2025-04-11 03:04:22 +00:00
2025-04-10 15:52:02 -06:00
< p class = "logo" > < a href = "../index.html" >
< img class = "logo" src = "../_static/flask-vertical.png" alt = "Logo of Flask" / >
< / a > < / p >
2025-04-11 03:04:22 +00:00
2025-04-10 15:52:02 -06:00
< h3 > Contents< / h3 >
< ul >
2025-04-11 03:04:22 +00:00
< li > < a class = "reference internal" href = "#" > Make the Project Installable< / a > < ul >
< li > < a class = "reference internal" href = "#describe-the-project" > Describe the Project< / a > < / li >
< li > < a class = "reference internal" href = "#install-the-project" > Install the Project< / a > < / li >
2025-04-10 15:52:02 -06:00
< / ul >
< / li >
< / ul >
< h3 > Navigation< / h3 >
< ul >
< li > < a href = "../index.html" > Overview< / a >
< ul >
< li > < a href = "index.html" > Tutorial< / a >
< ul >
2025-04-11 03:04:22 +00:00
< li > Previous: < a href = "blog.html" title = "previous chapter" > Blog Blueprint< / a >
< li > Next: < a href = "tests.html" title = "next chapter" > Test Coverage< / a > < / ul >
2025-04-10 15:52:02 -06:00
< / li >
< / ul >
< / li >
< / ul >
< search id = "searchbox" style = "display: none" role = "search" >
< h3 id = "searchlabel" > Quick search< / h3 >
< div class = "searchformwrapper" >
< form class = "search" action = "../search.html" method = "get" >
< input type = "text" name = "q" aria-labelledby = "searchlabel" autocomplete = "off" autocorrect = "off" autocapitalize = "off" spellcheck = "false" / >
< input type = "submit" value = "Go" / >
< / form >
< / div >
< / search >
< script > document . getElementById ( 'searchbox' ) . style . display = "block" < / script > < div id = "ethical-ad-placement" > < / div >
< / div >
< / div >
< div class = "clearer" > < / div >
< / div >
< div class = "footer" role = "contentinfo" >
© Copyright 2010 Pallets.
Created using < a href = "https://www.sphinx-doc.org/" > Sphinx< / a > 8.1.3.
< / div >
< / body >
2025-04-11 03:04:22 +00:00
< / html >