Environment MacOS Catalina 10.15.7 Python 3.9.7 Directory structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 concurrent-api-client ├── .python-version ├── README.md ├── MANIFEST.in ├── requirements.in ├── requirements.testing.in ├── requirements.txt ├── setup.py ├── tox.ini ├── src │ └── api_client │ ├── __init__.py │ ├── api_client.py │ └── ... └── tests ├── __init__.py ├── test_api_formatter.py └── ... Register PyPI account PyPI https://pypi.
Environment MacOS Catalina 10.15.7 Python 3.7.8, 3.8.6, 3.9.7 Directory structure:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 concurrent-api-client ├── .python-version ├── README.md ├── MANIFEST.in ├── requirements.in ├── requirements.testing.in ├── requirements.txt ├── setup.py ├── setup.cfg ├── tox.ini ├── src │ └── api_client │ ├── __init__.py │ ├── api_client.py │ └── ... └── tests ├── __init__.py ├── test_api_formatter.
For surviving hell of dependency management in python project, it’d good to use python toolkit libraries for dependency management like pip, pip-tools, setuptools (pytest, and tox). At this post, I write about pip, pip-tools and setuptools(setup.py).
Environment MacOS Catalina 10.15.7 Python 3.9.7 Guides Python packaging user guide | tool recommendation is fine document. Tool pyenv can install multiple python versions and switch python interpreter venv can create and switch to a python virtual environment for the package package project pip : pip is the package installer for Python.
Problem On running pytest with configuring strongly recommended directory structure in good practices in docs.pytest.org,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 setup.py src/ mypkg/ __init__.py app.py view.py tests/ __init__.py foo/ __init__.py test_view.py bar/ __init__.py test_view.py In my sample case, the directory is like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 concurrent-api-client ├── README.
Environment MacOS Catalina 10.15.7 Python 3.9.7 Flask 2.0.1 SQLte3 3.28.0 Problem On connecting to SQLite from Flask application , sqlite3.ProgrammingError is raised. This does not happen every time but rarely raise error after bunch of requesting calls are succeeded.
The error says SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 123145517748224 and this is thread id 123145534537728.
Former article (Consideration about python logging and file configuration(1)) has concerns to be updated.
There is more space to improve the usage for logging library with module naming space with __name__. setting configuration by config.fileConfig is older and limited in features (e.g. filter setting is not supported) (ref. document). Instead, it’s better to use config.dictConfig and load configuration file in .json or .yml format, a format that can be loaded as python' dictionary format.