Package: brewblox-automation
Boilerplate code for BrewBlox Service implementationsThere is some boilerplate code involved when creating a Brewblox service. This repository can be forked to avoid having to do the boring configuration.Everything listed underRequired Changesmust be done before the package works as intended.How to useFork this repository to your own Github account or project.Follow all steps outlined under the variousRequired Changes.Start coding your service =)To test, runpipenv run pytestFilessetup.pyUsed to create a distributable and installable Python package. Seehttps://docs.python.org/3.6/distutils/setupscript.htmlfor more information.Required Changes:Change thenamevariable to your project name. This is generally the same as the repository name. This name is used when installing the package through Pip.It is common for this name to equal the package name, but using "-" as separator instead of "_".Change theurlparameter to the url of your repository.Change theauthorparameter to your name.Change theauthor_emailparameter to your email.tox.iniDeveloper tools such asTox,Pytest,Flake8, andAutopep8use this file to find configuration options.Required Changes:Change--cov=YOUR_PACKAGEto refer to your module name.The--cov-fail-under=100makes the build fail if code coverage is less than 100%. It is optional, but recommended. Remove the#comment character to enable it..envProject-specific environment variables can be stored here.Pipenvwill automatically load it when executing a command inpipenv run.For a basic service (not deployed to PyPi or Docker Hub), you do not need to add or edit anything here.PipfilePipenvis used to streamline development. It manages dependencies and virtual environments. It also automatically loads environment variables declared in.env.Pipfilelists all dependencies. Everything under [packages] is needed for the package to run, while everything under [dev-packages] is needed to run the tests.You can usepipenv install <package name>orpipenv install --dev <package name>to add dependencies.Note:There is overlap between the [packages] section inPipfile, and theinstall_requires=[]list insetup.py. The rule of thumb is that if you need an external package to run, you should add it to both.Required Changes:Install pipenv (runsudo pip3 install pipenv)Update thePipfile.lockfile (runpipenv lock)Install all packages (runpipenv sync -d)MANIFEST.inThis file lists all non-code files that should be part of the package.
Seehttps://docs.python.org/3.6/distutils/sourcedist.html#specifying-the-files-to-distributefor more info.For a basic service, you do not need to change anything in this file..editorconfigThis file containsEditorConfigconfiguration for this project.Among other things, it describes per file type whether it uses tabs or spaces.For a basic service, you do not need to change anything in this file.
However, it is recommended to use an editor that recognizes and uses.editorconfigfiles.README.mdYour module readme (this file). It will be the package description on Pypi.org, and automatically be displayed in Github.Required Changes:Add all important info about your package here. What does your package do? How do you use it? What is your favorite color?YOUR_PACKAGE/Your module. This name is used when importing your code in Python.Required Changes:Rename to the desired module name. This name can't include "-" characters.It is common for single-module projects to use "-" as a separator for the project name, and "_" for the module.For example:your-packageandyour_package.test/conftest.pyProject-level pytest fixtures. Some useful fixtures for testing any brewblox_service implementation are defined here. See tests inhttps://github.com/BrewBlox/brewblox-service/tree/develop/testfor examples on how to use.For a basic implementation, you do not need to change anything in this file.test/test_hello.pyAn example on how to test aiohttp endpoints you added. Feel free to remove this once you no longer need it.docker/amd/DockerfileA docker file for running your package. To build, you need to copy the local version of your python package todocker/dist/first.The Dockerfiles are set up so both the AMD (desktop) and ARM variants can use the same input files.Example:python3setup.pysdist

rmdocker/dist/*
cpdist/*docker/dist/
pipenvlock--requirements>docker/requirements.txt

dockerbuild\--tagyour-package:your-version\--filedocker/amd/Dockerfile\docker/# run itdockerrunyour-package:your-versionTo cover the most common use cases, thebrewblox-toolsdependency defines thebbt-localbuildscript.It will read your .env file, run sdist, copy configuration to the docker directory, and build an image. Example:bbt-localbuild
dockerrunyour-package:localExplore its other arguments withbbt-localbuild --helpRequired Changes:Rename instances ofYOUR-PACKAGEandYOUR_PACKAGEin the docker file to desired project and package names.docker/arm/DockerfileThe same as fordocker/amd/Dockerfile, but for Raspberry Pi targets.In order to build for Raspberry, you must also first enable the ARM compiler.Example:python3setup.pysdist

rmdocker/dist/*
cpdist/*docker/dist/
pipenvlock--requirements>docker/requirements.txt# Enable ARM compilerdockerrun--rm--privilegedmultiarch/qemu-user-static:register--reset# Build the Raspberry Pi versiondockerbuild\--tagyour-package:rpi-your-version\--filedocker/arm/Dockerfile\docker/# Try to run Raspberry version# On the desktop, this will fail with "standard_init_linux.go:190: exec user process caused "exec format error""dockerrun--detachyour-package:rpi-your-versionbbt-localbuildcan also generate ARM images. It will automatically enable the QEMU compiler, and prefix the tag withrpi-. To use:bbt-localbuild --arch arm
docker run your-package:rpi-localRequired Changes:Rename instances ofYOUR-PACKAGEandYOUR_PACKAGEin the docker file to desired project and package names.azure-pipelines.ymlAzurecan automatically test and deploy all commits you push to GitHub. If you haven't enabled travis for your repository: don't worry, it won't do anything.To deploy your software, you will also needPyPiandDocker Hubaccounts.