My first post

My first post

So my first blog post is due, since I just created this one. Since I'm eager to start blogging again after a long period of not having a blog I'm now thinking where should I start. If it was a python application it would be easy as touch __init__.py, but that's not the case.

So let's start with the stuff I use to start a new python project with first listing the tools I use mostly in my development process

Tools

  • pyenv - is the tool to manage python versions installed on my machine. It is better then just to rely on the default system version, and gives me the flexibility to test code on different python versions.
  • poetry - although not perfect, I mostly had a great experience with packaging my applications and libraries. I had mostly problems with private repository and authentication in CI/CD pipelines.
  • black - it is a great tool to format your code to a uniform style so the code is as consistent as possible in the company.
  • pytest - no code should be pushed to production without enough tests, but that should be how you do it anyways.
  • PyCharm/VSCode/Vim - some IDE or advanced code editor is needed - nice highlighting, integrated debugger, userful extensions or integrations are nice to have.

Setting up the project

First thing first - ensure we have a required python version installed (say 3.8)

pyenv install 3.8.10
pyenv global 3.8.10

Second we can then create our project

poetry new <path_name>
cd <path_name>
# Add development dependencies
poetry add --dev black
poetry add --dev pytest

That's mostly it

If you would like to support tools that are optional or interchangeable (say a database driver then you can add them in the pyproject.toml file) like this:

[tool.poetry.extras]
mysql = ["PyMySQL"]
pgsql = ["psycopg2"]

finally we can install evenrything and let poetry create our virtual environment to hold an isolated python version with all the depenencies for the project with

pyenv install --extras mysql # if mysql will be the driver you want to use

Done

What is left is to open the project in your editor/IDE and add your magic to it.


Photo by Torsten Kellermann: pexels.com/photo/body-of-water-surrounded-b..