Skip to content
Myr

Merge pull request #2541 from nsiregar/#2535_update_pycharm_instruction

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

update pycharm instructions

authored by David Lord · committed by GitHub · parents c2bac6d, c11fe5d · Browse files · 3 files+39 added−29 removed
This commit

State

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

Diff stats

3 files+39 added−29 removed

  • other:+39 added−29 removed

3 files+39 added−29 removed

modified:docs/_static/pycharm-runconfig.pngbinary

A binary file, modified.

modified:docs/cli.rst+37 added-27 removed
341 unmodified lines
342343PyCharm Integration344-------------------345346The new Flask CLI features aren't yet fully integrated into the PyCharm IDE,347so we have to do a few tweaks to get them working smoothly. These instructions348should be similar for any other IDE you might want to use.346The Flask CLI features aren't yet fully integrated into the PyCharm IDE,347so we have to do a few tweaks to get them working smoothly. These348instructions should be similar for any other IDE you might want to use.349350In PyCharm, with your project open, click on *Run* from the menu bar and go to351*Edit Configurations*. You'll be greeted by a screen similar to this:350In PyCharm, with your project open, click on *Run* from the menu bar and351go to *Edit Configurations*. You'll be greeted by a screen similar to352this:353354.. image:: _static/pycharm-runconfig.png354 :align: center355 :class: screenshot356 :alt: screenshot of pycharm's run configuration settings355 :align: center356 :class: screenshot357 :alt: screenshot of pycharm's run configuration settings358358There's quite a few options to change, but once we've done it for one command,359we can easily copy the entire configuration and make a single tweak to give us360access to other commands, including any custom ones you may implement yourself.359There's quite a few options to change, but once we've done it for one360command, we can easily copy the entire configuration and make a single361tweak to give us access to other commands, including any custom ones you362may implement yourself.363362For the *Script* input (**A**), navigate to your project's virtual environment.363Within that folder, pick the ``flask`` executable which will reside in the364``bin`` folder, or in the ``Scripts`` on Windows.364Click the + (*Add New Configuration*) button and select *Python*. Give365the configuration a good descriptive name such as "Run Flask Server".366For the ``flask run`` command, check "Single instance only" since you367can't run the server more than once at the same time.368366The *Script Parameter* field (**B**) is set to the CLI command you to execute.367In this example we use ``run``, which will run the development server.369Select *Module name* from the dropdown (**A**) then input ``flask``.370369You can skip this next step if you're using :ref:`dotenv`. We need to add an370environment variable (**C**) to identify our application. Click on the browse371button and add an entry with ``FLASK_APP`` on the left and the name of the372Python file or package on the right (``app.py`` for example).371The *Parameters* field (**B**) is set to the CLI command to execute372(with any arguments). In this example we use ``run``, which will run373the development server.374374Next we need to set the working directory (**D**) to be the same folder where375our application file or package resides. PyCharm changed it to the directory376with the ``flask`` executable when we selected it earlier, which is incorrect.375You can skip this next step if you're using :ref:`dotenv`. We need to376add an environment variable (**C**) to identify our application. Click377on the browse button and add an entry with ``FLASK_APP`` on the left and378the Python import or file on the right (``hello`` for example).379378Finally, untick the *PYTHONPATH* options (**E**) and give the configuration a379good descriptive name, such as "Run Flask Server", and click *Apply*.380Next we need to set the working directory (**D**) to be the folder where381our application resides.382383If you have installed your project as a package in your virtualenv, you384may untick the *PYTHONPATH* options (**E**). This will more accurately385match how you deploy the app later.386387Click *Apply* to save the configuration, or *OK* to save and close the388window. Select the configuration in the main PyCharm window and click389the play button next to it to run the server.390381Now that we have a configuration which runs ``flask run`` from within PyCharm,382we can simply copy that configuration and alter the *Script* argument391Now that we have a configuration which runs ``flask run`` from within392PyCharm, we can copy that configuration and alter the *Script* argument393to run a different CLI command, e.g. ``flask shell``.
modified:tox.ini+2 added-2 removed
38 unmodified lines
39 coverage run -p -m pytest tests examples4041[testenv:docs-html]42deps = sphinx43commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs docs/_build/html43commands = sphinx-build -W -b html -d {envtmpdir}/doctrees docs {envtmpdir}/html4445[testenv:docs-linkcheck]46deps = sphinx47commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees docs docs/_build/linkcheck47commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees docs {envtmpdir}/linkcheck4849[testenv:coverage-report]50deps = coverage51skip_install = true
13 unmodified lines