Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tutorial: step 3 (Installing as package) needs rationale #2421

Closed
uvtc opened this issue Jul 18, 2017 · 8 comments
Closed

Tutorial: step 3 (Installing as package) needs rationale #2421

uvtc opened this issue Jul 18, 2017 · 8 comments
Labels
Milestone

Comments

@uvtc
Copy link

uvtc commented Jul 18, 2017

Step 3 of the tutorial (installing flaskr as a package) needs rationale at the top. As it stands, that section of the tutorial tells the user out of the blue that they should install their webapp as a package, but doesn't say why. The user can already run their webapp via flask run, so it's not clear why they should at this point set up and install their package into their venv.

@davidism davidism added the docs label Jul 18, 2017
@davidism
Copy link
Member

davidism commented Jul 18, 2017

  • It's installed like all other packages, rather than relying on injecting the current directory into sys.path. This means that it's importable as long as you're in the virtualenv, rather than needing to be at the root project directory.
  • FLASK_APP can refer to it by name instead of path (or path to __init__.py). (This is true in some cases for non-installed packages in the next release, but installing is still recommended.)
  • You can install entry points, which is especially helpful if you need to customize the CLI.
  • You can deploy like any other Python library, by creating a wheel and installing it. The dev environment now mirrors the prod environment. This also helps you separate your app behavior from your repository structure.
  • In Python 2 especially, it avoids common "everything at the top level" relative import problems.
  • You can isolate your tests using tox.
  • It prepares you for better organization for larger projects.

Basically, you get all the benefits of installing packages in general.

@uvtc
Copy link
Author

uvtc commented Jul 20, 2017 via email

@davidism
Copy link
Member

I don't want the tutorial to not install the project. We want to encourage installation.

@uvtc
Copy link
Author

uvtc commented Jul 20, 2017

This is what I'm trying to understand (just posted to the ML). Isn't it customary to run from the project directory during development, without installing it? Trying to understand how development workflow goes, as opposed to deployment.

My guess is that there should be a paragraph at the top of this section saying something about how, in the end, you're going to want to be able to install as a package for a number of reasons, and so should set up your project that way from the start, but then describe how regular development works in the project dir.

Haven't gotten this working, nor finished reading the tut, so will get back to this! :)

@davidism
Copy link
Member

davidism commented Jul 20, 2017

"Regular development" is installing the package in develop mode. Yes, we should explain why, but no, we should not say that not installing the package is the way to do things.

@ThiefMaster
Copy link
Member

During develop you should install it, but with -e so the installed package just references your source directory.

@uvtc
Copy link
Author

uvtc commented Jul 20, 2017

BTW, my original comment on this issues was mistaken: I couldn't run my app with a simple flask run without first installing it. I was confused because the Quickstart doc did that with a simple standalone hello.py file, rather than as a package.

@davidism davidism modified the milestone: 1.0 Jul 31, 2017
@davidism
Copy link
Member

davidism commented Nov 8, 2017

continued in #2513

@davidism davidism closed this as completed Nov 8, 2017
@pallets pallets locked and limited conversation to collaborators Nov 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants