~jgillis/python-flask-cookiecutter

c006b5a4eb38090be683660661a61c0205a26f18 — Joris Gillis 3 years ago 17072c0 master
Documenting how to use the generated project

Plus fixing a small bug
2 files changed, 36 insertions(+), 2 deletions(-)

M README.md
M {{ cookiecutter.python_package_name }}/Makefile
M README.md => README.md +35 -1
@@ 10,7 10,41 @@ cookiecutter https://git.sr.ht/~jgillis/python-flask-cookiecutter

Answer the questions prompted by cookiecutter and your project will be generated. 

Start by initiating a git repository in your generated project:
```
git init
git add *
git commit -m "Initial commit"
git tag v0.0.1
```

Run the init goal of the Makefile. This installs all dependencies and creates a virtual environment:
```
make init
```

Enter the virtual environment
```
poetry shell
```

Build a docker image:
```
make clean docker
```

In the `dist` folder you should find three files. 
One tar file, containing the docker image.
One tar.gz file containing the source distribution of your Python package. 
One whl file containing the binary distribution of your Python package.
Now you can either use `poetry publish` to publish the Python artifacts to PyPI or your local repository. 
The docker artifact can be deployed to your docker registry. 
Or you use `docker load < <your-project>-<version>.tar` to load it into a Docker engine.   

Note on package names
---------------------
Do note the difference between `python_package_name` and `module_name`. 
The former is the name of you Python package (as used by pip and PyPi). 
The latter is the name of the Python module.  
For example, `py-project` is a valid `python_package_name` and `py_project` (note the dash became an underscore) is a module name.
\ No newline at end of file
For example, `py-project` is a valid `python_package_name` and `py_project` (note the dash became an underscore) is a module name.
Make sure that `python_package_name` and `module_name` are equivalent, except that dashes in the python package name are replaced by underscores in the module name.  

M {{ cookiecutter.python_package_name }}/Makefile => {{ cookiecutter.python_package_name }}/Makefile +1 -1
@@ 25,7 25,7 @@ build: test lint
	poetry build

docker: build
	cp dist/{{ cookiecutter.python_package_name }}*.whl docker/
	cp dist/{{ cookiecutter.module_name }}*.whl docker/
	cd docker && docker build -t {{ cookiecutter.python_package_name }} .
	docker save {{ cookiecutter.python_package_name }} >dist/{{ cookiecutter.python_package_name }}-`ls docker/*.whl | grep -o -E "[0-9\.]+(post[0-9]+\.dev[0-9]+\+[a-f0-9]+)?" | head -n 1`.tar
	rm docker/*.whl