jeudi 26 novembre 2020

Use setup.py or not use setup.py for an python application

I have some issues related to the packaging/installation of python apps. I now have a new fastapi app where I want to include all the best practices like running linting and tests (pytest) and stuff with tox to reliably test also with different python versions. Previous to that I just ran pytest with what i now would call a hack because I added the root app folder manually to the sys.path.

Now that I can start with a fresh new app I want to get rid of this hack. I did some research and found different opposing answers to the question on how to structure the app so I can easily test it manually with pytest or running tox. The problem always comes down to how to access the modules and packages from the test directory. The first import inside the test file is simply done with a relative import but then all other imports inside the first imported module will not work. I think I'm missing something crucial here but since I cannot name it I cannot find a solution.

I know that for libraries I should create a setup.py to install it so other apps can import it and use it, but how should I proceed in the context of my app? Should I create a setup.py to install it or not?

Aucun commentaire:

Enregistrer un commentaire