diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1130cda..4baad75 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,3 +47,15 @@ jobs: - name: Smoke Test Docker Image run: | docker run --rm python_boilerplate:smoke-test-tag param_3_from_command_line + - name: Build Application Executable Package with PyInstaller + run: | + pipenv run pyinstaller --windowed --noconsole \ + --add-data "setup.cfg:." \ + --add-data "python_boilerplate/resources/*:python_boilerplate/resources" \ + --name multithread_and_thread_pool_usage \ + --clean --noconfirm python_boilerplate/demo/multithread_and_thread_pool_usage.py + - name: Display Built Artifacts + run: | + du -s -h * + - name: Smoke Test PyInstaller Application + run: ./dist/multithread_and_thread_pool_usage/multithread_and_thread_pool_usage diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7d5de02..6949bd8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -7,7 +7,7 @@ repos: - id: trailing-whitespace - id: end-of-file-fixer - id: mixed-line-ending - args: [ --fix, lf ] + args: [ --fix, auto ] - id: check-yaml - id: debug-statements - id: name-tests-test diff --git a/CHANGELOG.md b/CHANGELOG.md index 2182be0..d6c7ed9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [5.0.0](https://github.com/johnnymillergh/muscle-and-fitness-server/compare/4.0.1...5.0.0) (2023-03-04) + + +### Features + +* **$PyInstaller:** integrate PyInstaller ([29251e7](https://github.com/johnnymillergh/python_boilerplate/commit/29251e7249322ce706287ab39b9d6e9060d72408)) + + + # [4.0.0](https://github.com/johnnymillergh/muscle-and-fitness-server/compare/3.0.0...4.0.0) (2022-09-18) diff --git a/Pipfile b/Pipfile index 4f1fb58..07a9c16 100644 --- a/Pipfile +++ b/Pipfile @@ -73,3 +73,5 @@ pytest-html = "==3.2.0" pytest-xdist = "==3.2.0" # Call stack profiler for Python. Shows you why your code is slow! https://github.com/joerick/pyinstrument pyinstrument = "==4.4.0" +# PyInstaller bundles a Python application and all its dependencies into a single package. https://github.com/pyinstaller/pyinstaller +pyinstaller = "==5.8.0" diff --git a/Pipfile.lock b/Pipfile.lock index b62280c..efcda7f 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "81d65aa84c4f23a4847367c38e7fcd8b40a3761f70dabadd2f0fb5e6755eb7d5" + "sha256": "cd19601e1f9618087eac30b53ed94d9bf8aeb14d3ff2d135a1f885ff13865e87" }, "pipfile-spec": 6, "requires": { @@ -539,6 +539,13 @@ } }, "develop": { + "altgraph": { + "hashes": [ + "sha256:ad33358114df7c9416cdb8fa1eaa5852166c505118717021c6a8c7c7abbd03dd", + "sha256:c8ac1ca6772207179ed8003ce7687757c04b0b71536f81e2ac5755c6226458fe" + ], + "version": "==0.17.3" + }, "attrs": { "hashes": [ "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836", @@ -819,6 +826,14 @@ "markers": "python_version >= '3.7'", "version": "==0.11.0" }, + "pefile": { + "hashes": [ + "sha256:82e6114004b3d6911c77c3953e3838654b04511b8b66e8583db70c65998017dc", + "sha256:da185cd2af68c08a6cd4481f7325ed600a88f6a813bad9dea07ab3ef73d8d8d6" + ], + "markers": "sys_platform == 'win32'", + "version": "==2023.2.7" + }, "pep8-naming": { "hashes": [ "sha256:1705f046dfcd851378aac3be1cd1551c7c1e5ff363bacad707d43007877fa971", @@ -875,6 +890,32 @@ "markers": "python_version >= '3.6'", "version": "==3.0.1" }, + "pyinstaller": { + "hashes": [ + "sha256:314fb883caf3cbf06adbea2b77671bb73c3481568e994af0467ea7e47eb64755", + "sha256:3b74f50a57b1413047042e47033480b7324b091f23dff790a4494af32b377d94", + "sha256:4f4d818588e2d8de4bf24ed018056c3de0c95898ad25719e12d68626161b4933", + "sha256:502a2166165a8e8c3d99c19272e923d2548bac2132424d78910ef9dd8bb11705", + "sha256:5c9632a20faecd6d79f0124afb31e6557414d19be271e572765b474f860f8d76", + "sha256:8d004699c5d71c704c14a5f81eec233faa4f87a3bf0ae68e222b87d63f5dd17e", + "sha256:a62ee598b137202ef2e99d8dbaee6bc7379a6565c3ddf0331decb41b98eff1a2", + "sha256:bacf236b5c2f8f674723a39daca399646dceb470881f842f52e393b9a67ff2f8", + "sha256:bf1f7b7e88b467d7aefcdb2bc9cbd2e856ca88c5ab232c0efe0848f146d3bd5f", + "sha256:ded780f0d3642d7bfc21d97b98d4ec4b41d2fe70c3f5c5d243868612f536e011", + "sha256:e68bcadf32edc1171ccb06117699a6a4f8e924b7c2c8812cfa00fd0186ade4ee", + "sha256:f9361eff44c7108c2312f39d85ed768c4ada7e0aa729046bbcef3ef3c1577d18" + ], + "index": "pypi", + "version": "==5.8.0" + }, + "pyinstaller-hooks-contrib": { + "hashes": [ + "sha256:29d052eb73e0ab8f137f11df8e73d464c1c6d4c3044d9dc8df2af44639d8bfbf", + "sha256:bd578781cd6a33ef713584bf3726f7cd60a3e656ec08a6cc7971e39990808cc0" + ], + "markers": "python_version >= '3.7'", + "version": "==2023.0" + }, "pyinstrument": { "hashes": [ "sha256:09167ece8802bc03a63e97536dcefd9c1a340dae686f40914cf995099bc0d0af", @@ -979,6 +1020,14 @@ "index": "pypi", "version": "==3.2.0" }, + "pywin32-ctypes": { + "hashes": [ + "sha256:24ffc3b341d457d48e8922352130cf2644024a4ff09762a2261fd34c36ee5942", + "sha256:9dc2d991b3479cc2df15930958b674a48a227d5361d413827a4cfd0b5876fc98" + ], + "markers": "sys_platform == 'win32'", + "version": "==0.2.0" + }, "pyyaml": { "hashes": [ "sha256:01b45c0191e6d66c470b6cf1b9531a771a83c1c4208272ead47a3ae4f2f603bf", diff --git a/README.md b/README.md index 61c598c..7f71f51 100644 --- a/README.md +++ b/README.md @@ -120,18 +120,42 @@ $ python3 -m python_boilerplate $ PYTHONPATH="${PYTHONPATH}:/Users/johnny/Projects/PyCharmProjects/python_boilerplate/python_boilerplate" python3 python_boilerplate/__main__.py ``` -### ~~Package with [PyInstaller](https://pyinstaller.org/en/latest/usage.html?highlight=pythonpath#using-pyinstaller)~~ - +### Package with [PyInstaller](https://pyinstaller.org/en/latest/usage.html?highlight=pythonpath#using-pyinstaller) + +> **⚠️ WANRING** +> +> Need to call `freeze_support()` immediately when startup in `python_boilerplate/__init__.py` +> +> ``` +> from multiprocessing import freeze_support +> +> freeze_support() +> ``` +> +> - [Pyinstaller multiprocessing name of process is always "MainProcess" #3957](https://github.com/pyinstaller/pyinstaller/issues/3957#issuecomment-674579877) +> - [pyinstaller linux binary is getting restarted again and again #4190](https://github.com/pyinstaller/pyinstaller/issues/4190) + +Build artifact with macOS or Linux, ```shell $ pipenv run pyinstaller --console \ +--add-data "setup.cfg:." \ --add-data "python_boilerplate/resources/*:python_boilerplate/resources" \ ---name main \ +--name pandas_usage \ --clean --noconfirm python_boilerplate/demo/pandas_usage.py ``` +On Windows, +```powershell +$ pipenv run pyinstaller --console ` +--add-data "setup.cfg;." ` +--add-data "python_boilerplate/resources/*;python_boilerplate/resources" ` +--name multithread_and_thread_pool_usage ` +--clean --noconfirm python_boilerplate/demo/multithread_and_thread_pool_usage.py +``` + ### Run Unit Tests -Run with pytest, analyze code coverage, generate HTML code coverage reports, fail the test if coverage percentage is unser 85% +Run with pytest, analyze code coverage, generate HTML code coverage reports, fail the test if coverage percentage is under 90%, ```shell $ pipenv run pytest --cov --cov-report html --cov-fail-under=85 --capture=no --log-cli-level=INFO diff --git a/setup.cfg b/setup.cfg index 3b52bc5..a2f0471 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = python_boilerplate -version = 4.0.1 +version = 5.0.0 description = A boilerplate project for Python. long_description = file: README.md long_description_content_type = text/markdown