s3rius / FastAPI-template

Feature rich robust FastAPI template.
MIT License
1.94k stars 171 forks source link

Question: How do you set the python version? #158

Closed BTruer closed 1 year ago

BTruer commented 1 year ago

I have been using pyenv to manage different python versions on my machine. When I pip installed poetry I did it with python11 but the project that was generated looks like its python9.something. Is there a way to set it on project generation? If not what is the recommended python version?

s3rius commented 1 year ago

Hi and thanks for raising your question. The generated project is not constraint to 3.9 it has a version "^3.9". This version specification with a caret can be translated to "this project can run on every python interpreter with version that higher or equal to 3.9 and less than 4.0". And because you were using python 3.11, I guess your interpreter in virtual environment has version 3.11.

You can check it by running

poetry run python -V
BTruer commented 1 year ago

That makes sense. Would the docker images also need to be updated with the version of python? Currently the generated one is:

FROM python:3.9.6-slim-buster
s3rius commented 1 year ago

If you want so, then yes. But by default everything should be working as expected. Every possible configuration of the project is tested with python 3.9. You can switch it and check if everything is correct. If it is, you're good to go with your python version.

If I add tests for every python version that higher than 3.9, tests would take up to 3 hours or more. I'm sorry, but it's too much. I hope, I made my point clear.