Create the Project¶
Project Naming¶
Obviously the very first step is to come up with a name for your new app/project.
As already mentioned, this tutorial uses Poser for the (placeholder) project name. But for the moment, let’s pretend the name is My Cool App and walk through the 4 “variations” involved.
When you generate code via cookiecutter (below) you will be asked for each of these “types” of names. Here are descriptions and examples which hopefully show the distinction:
project name - human-friendly display name for the project (
My Cool App)distribution name - PyPI-friendly name for the release (
My-Cool-Appormy-cool-apporMyCoolApp)package name - Python-friendly name which code can import (
my_cool_appormycoolapp)repo name - “slug” name used for source folder and URLs (
my-cool-appormycoolapp)
Virtual Environment¶
Now that the name is settled, let’s create a Python virtual environment:
python3 -m venv ~/poserenv
From now on all commands will generally be ran within the root folder of the virtual environment, which should be activated:
cd ~/poserenv
source bin/activate
Generate Code¶
Next we’ll invoke the wuttaweb template for cookiecutter.
You can specify the desired output path via the -o <dir> argument.
Note that a new folder underneath the output folder will be created,
named according to your project.
Using commands below, we’ll wind up with output in the ~/src/poser
folder.
mkdir -p ~/src
cookiecutter -o ~/src git+https://forgejo.wuttaproject.org/wutta/cookiecutter-wuttaweb
The cookiecutter command will ask you questions about project
naming etc. See above for more about the name variations.
When asked about “Continuum data versioning” you probably should say yes, unless you know you don’t want it. This provides a version history feature which can be used for any tables you create.
Commit Code¶
It’s a good idea to commit the fresh project code as-is. That way it’s clear what was generated vs. what you change going forward.
It may be helpful to add notes to the commit message indicating the procedure used to generate the code, along with answers given to the template questions etc.
cd ~/src/poser
git init .
git add .
git commit -m "initial code generated via cookiecutter"
Install Package¶
Final step here is to install the new Python package into our virtual environment:
pip install -e ~/src/poser