From 836c3406757c9bd7f44c424279f47aad15e48fd9 Mon Sep 17 00:00:00 2001 From: Danieldu Date: Wed, 30 Aug 2023 21:27:10 +0800 Subject: [PATCH 1/5] form daniel --- config/dir.py | 2 +- main.spec | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/config/dir.py b/config/dir.py index 4d99537..a75421c 100644 --- a/config/dir.py +++ b/config/dir.py @@ -3,4 +3,4 @@ base_directory = os.getcwd() static_dir = os.path.join(base_directory, "static") audio_dir = os.path.join(static_dir, "audio") -font_dir = os.path.join(static_dir, "font/Noto_Sans_TC/static/NotoSansTC-Black.ttf") +font_dir = os.path.join(static_dir, "font","Noto_Sans_TC","static","NotoSansTC-Black.ttf") diff --git a/main.spec b/main.spec index 9497724..f7678f8 100644 --- a/main.spec +++ b/main.spec @@ -8,7 +8,7 @@ a = Analysis( ['main.py'], pathex=[], binaries=[], - datas=[], + datas=[('/home/danieldu/QuizzApp/static', './static')], hiddenimports=[], hookspath=[], hooksconfig={}, @@ -24,17 +24,13 @@ pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE( pyz, a.scripts, - a.binaries, - a.zipfiles, - a.datas, [], + exclude_binaries=True, name='main', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, - upx_exclude=[], - runtime_tmpdir=None, console=True, disable_windowed_traceback=False, argv_emulation=False, @@ -42,3 +38,13 @@ exe = EXE( codesign_identity=None, entitlements_file=None, ) +coll = COLLECT( + exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + upx_exclude=[], + name='main', +) From 1eff24850a38404de564dda3d38276651a37503a Mon Sep 17 00:00:00 2001 From: Danieldu Date: Wed, 30 Aug 2023 21:39:19 +0800 Subject: [PATCH 2/5] add readme --- README.md | 37 ++++++++++++++++++++++++++++++++++++- environment.yml | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fab3b71..ec59dfd 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,38 @@ # QuizzApp -pyinstaller --add-data "C:\Users\SF305\Desktop\QuizzApp\static;./static" main.py +QuizzApp is a Python application for conducting quizzes or tests with audio questions. + +## Installation + +### Prerequisites + +- Python 3.8 or higher +- Conda (for creating and managing virtual environments) + +### Setup + +1. Clone the repository: + + ```bash + git clone https://github.com/yourusername/QuizzApp.git + cd QuizzApp +2. Create a Conda environment from the env.yml file: + ```bash + conda env create -f environment.yml +3. Activate the Conda environment: + ```bash + conda activate quizzapp +## Usage +To run the QuizzApp, use the following command: + + ```bash + python main.py +## Build Executable +You can build an executable for QuizzApp using cx_Freeze. Run the following command: + + ```bash + python setup.py build +This will create an executable in the build directory. + + + diff --git a/environment.yml b/environment.yml index da758aa..737b143 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: psychopy +name: quizzapp channels: - conda-forge - anaconda From c828c56b4e20a8058528804f7db9ea7010164d41 Mon Sep 17 00:00:00 2001 From: Danieldu Date: Wed, 30 Aug 2023 21:40:31 +0800 Subject: [PATCH 3/5] add setup --- .gitignore | 1 - setup.py | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index ace7dd0..f848c3c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ __pycache__/ build/ dist/ *.icns -setup.py *.mp3 venv prompt.txt diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..f1b3199 --- /dev/null +++ b/setup.py @@ -0,0 +1,39 @@ +import cx_Freeze +import logging + +# Configure error logging settings +logging.basicConfig(filename='error.log', level=logging.ERROR) + +# Create a file handler for error logging +error_log_handler = logging.FileHandler('error.log') +error_log_handler.setLevel(logging.ERROR) + +# Create a formatter for the log messages (customize as needed) +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') +error_log_handler.setFormatter(formatter) + +# Add the error log handler to the root logger +root_logger = logging.getLogger() +root_logger.addHandler(error_log_handler) + +# Define the list of files to include +include_files = [('static', 'static')] # ('source_path', 'destination_path') + +# Continue with your cx_Freeze setup script +executables = [cx_Freeze.Executable("main.py", base=None)] + +options = { + 'build_exe': { + 'packages': [], # Add your packages here + 'includes': [], # Add your includes here + 'include_files': include_files, # Include the static folder + } +} + +cx_Freeze.setup( + name="QuizzApp", + version="1.0", + description="Your Application Description", + executables=executables, + options=options +) From fb651aec9f1a31d8dd2fae8bb5d61c57e4a1a0f2 Mon Sep 17 00:00:00 2001 From: Danieldu Date: Wed, 30 Aug 2023 21:47:50 +0800 Subject: [PATCH 4/5] fix readme --- README.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ec59dfd..610df5c 100644 --- a/README.md +++ b/README.md @@ -17,21 +17,29 @@ QuizzApp is a Python application for conducting quizzes or tests with audio ques git clone https://github.com/yourusername/QuizzApp.git cd QuizzApp 2. Create a Conda environment from the env.yml file: + ```bash conda env create -f environment.yml 3. Activate the Conda environment: + ```bash conda activate quizzapp + ## Usage + To run the QuizzApp, use the following command: - ```bash - python main.py + ```bash + python main.py + ``` + ## Build Executable + You can build an executable for QuizzApp using cx_Freeze. Run the following command: - ```bash - python setup.py build + ```bash + python setup.py build + ``` This will create an executable in the build directory. From bfdaa32e8e8566d16841136e50a7f4afec614ed2 Mon Sep 17 00:00:00 2001 From: Daniel Du <57485952+danghoangnhan@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:51:28 +0800 Subject: [PATCH 5/5] Create python-app.yml --- .github/workflows/python-app.yml | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python-app.yml diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml new file mode 100644 index 0000000..f3d4fca --- /dev/null +++ b/.github/workflows/python-app.yml @@ -0,0 +1,39 @@ +# This workflow will install Python dependencies, run tests and lint with a single version of Python +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python application + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest