-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Final code refinements, package EXE, write readme
A few final changes to code have been applied. A basic icon has been created. The pip requirements file has been created outlining dependencies. A script to seamlessly convert the program to EXE has been added (requires virtual environment). Add License. Create very detailed readme - including guide images for illustration. All done! Very good project work!
- Loading branch information
Showing
18 changed files
with
279 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
**/__pycache__ | ||
**/__pycache__ | ||
Include | ||
Lib | ||
Scripts | ||
pyvenv.cfg | ||
release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2024 Leo Zhang | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Entire release creation - EXE. | ||
Must use virtual environment, ensure Pyinstaller is installed. | ||
""" | ||
import os | ||
import pathlib | ||
import shutil | ||
import subprocess | ||
|
||
|
||
FOLDER = pathlib.Path(__file__).parent | ||
VENV_SCRIPTS_FOLDER = FOLDER / "Scripts" | ||
RELEASE_FOLDER = FOLDER / "release" | ||
if RELEASE_FOLDER.is_dir(): | ||
shutil.rmtree(RELEASE_FOLDER) | ||
RELEASE_FOLDER.mkdir() | ||
|
||
CODE_PACKAGE_FOLDER = RELEASE_FOLDER / "code" | ||
CODE_PACKAGE_ZIP = RELEASE_FOLDER / "code" | ||
|
||
ICON = FOLDER / "icon.ico" | ||
START_SCRIPT = FOLDER / "src" / "main.py" | ||
|
||
ADDITIONAL_DATA = { | ||
FOLDER / "icon.ico": "." | ||
} | ||
OUTPUT_EXE_NAME = RELEASE_FOLDER / "parkrunscraper.exe" | ||
|
||
|
||
def package_exe() -> None: | ||
"""Packages standalone EXE, ready to run.""" | ||
# Turn on virtual environment. | ||
subprocess.run((str(VENV_SCRIPTS_FOLDER / "activate.bat"),)) | ||
# Build command parts. | ||
command_parts = [ | ||
str(VENV_SCRIPTS_FOLDER / "pyinstaller"), | ||
str(START_SCRIPT), "--noconfirm", "--onefile", | ||
"--windowed", "--icon", str(ICON)] | ||
for add_data_src, add_data_dest in ADDITIONAL_DATA.items(): | ||
command_parts.append("--add-data") | ||
command_parts.append(f"{add_data_src};{add_data_dest}") | ||
# Run Pyinstaller. | ||
os.chdir(RELEASE_FOLDER) | ||
subprocess.run(command_parts) | ||
# Renames output EXE. | ||
output_exe = RELEASE_FOLDER / "dist" / f"{START_SCRIPT.stem}.exe" | ||
output_exe.rename(OUTPUT_EXE_NAME) | ||
# Deletes Pyinstaller files and folders. | ||
(RELEASE_FOLDER / "dist").rmdir() | ||
shutil.rmtree(RELEASE_FOLDER / "build") | ||
(RELEASE_FOLDER / f"{START_SCRIPT.stem}.spec").unlink(True) | ||
|
||
|
||
if __name__ == "__main__": | ||
package_exe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
selenium # Automated scraping. | ||
beautifulsoup4 # HTML parsing. | ||
lxml # Fast parsing of data. | ||
|
||
matplotlib # Graphs | ||
openpyxl # Export to XLSX | ||
python-docx # Export to DOCX | ||
|
||
comtypes # Export to PDF on Windows | ||
docx2pdf # Export to PDF on MacOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters