Skip to content

Explore the FAB Quick Start Utility

Val Huber edited this page Oct 3, 2020 · 10 revisions

Use this page to explore fab-quick-start, the command line utility to generate fab views.py files.

The fab_quick-start project contains 2 main folders - see the screen shot below:

  1. nw: is a fab project for a sqlite version northwind (nw), for illustration and testing. It was built using the QuickStart procedure.
  2. fab_quick_start_util/fab_quick_start.py code

Pre Reqs

To get started, you will need:

  • Python3: run the windows installer; on mac/Unix, consider using brew
  • virtualenv - see here (e.g., pip install virtualenv)
  • An IDE - any will do (I've used PyCharm and VSCode, install notes here) - ide will do, though different install / generate / run instructions apply for running programs

Issues? Try here

Project Installation

Get the project. First fork it on GitHub, then clone:

git clone https://github.com/valhuber/fab-quick-start.git

In VSCode Python Debug Console:

cd fab-quick-start
virtualenv venv
# windows: .\venv\Scripts\activate
source venv/bin/activate
pip install -r requirements.txt

In VSCode, you must also choose your Python Interpreter (e.g., .\venv\bin\python).

Note: Windows Powershell requires privileges as described here

IDE

Generate views.py

Then, in VSCode, select and run Launch Config: fab-quick-start run.

Or, in a terminal window:

cd nw-app
python ../fab_quick_start_util/fab_quick_start.py run

Copy the console output over the nw-app/app/views.py file.

Run generated fab app

In a terminal window:

cd nw
export FLASK_APP=app
flask run

Login as admin, p

Local PyPi Install

It's advisable to test the PyPi install process locally before using the test systems. We have seen many issues in Python Path not getting set.

Prepare the distribution:

cd fab-quick-start
deactivate
python3 setup.py sdist bdist_wheel

Then, from a test project, install from the local dist (e.g., /Users/val/python/pycharm/fab-quick-start)

source venv/bin/activate
pip install -e /Users/val/python/pycharm/fab-quick-start

Deploy to Test Pypi

Since fab-quick-start is normally run via the command line, we must deploy to the PyPi site.

Using this reference...

Acquire the setup software (initial, 1-time setup):

cd fab-quick-start
deactivate
python setup.py install
python3 -m pip install --user --upgrade twine
python3 -m pip install --user --upgrade setuptools wheel

Creating the dist, first time Get a Saved API Key

cd fab-quick-start
deactivate
python3 setup.py sdist bdist_wheel
# verify this produced the dist folder; next command uploads to test Pypi
python3 -m twine upload --repository testpypi dist/*

User is __token__, pwd is Saved API Key (from above).

This should upload to the test Pypi site

To re-upload:

  1. Delete the dist folder (and build, and .egg)
  2. Alter the version number in setup.py
deactivate
python3 setup.py sdist bdist_wheel
python3 -m twine upload  --skip-existing --repository testpypi dist/*

To install (beware - may require 15 mins until new version is active.

source venv/bin/activate
pip uninstall fab-quick-start
pip install -i https://test.pypi.org/simple/ fab-quick-start
cd nw-app
val@valMbp nw-app % fab-quick-start --help

Once you've verified it on testpypi, production deploy is:

 python3 -m twine upload --u vhuber --p ??? dist/*