diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64a436e..a285bea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,10 +5,10 @@ jobs: runs-on: windows-latest steps: - uses: actions/checkout@v2 - - name: Setup Miniconda Python 3.8 + - name: Setup Miniconda Python 3.9 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.9 # TODO: The below setp only chaches conda packages, need to cache pip seperatly - name: Cache conda uses: actions/cache@v2 @@ -29,7 +29,7 @@ jobs: - name: Install Miniconda uses: conda-incubator/setup-miniconda@v2 with: - python-version: 3.8 + python-version: 3.9 activate-environment: botty channel-priority: strict environment-file: environment.yml diff --git a/development.md b/development.md index 4be43b6..012adbd 100644 --- a/development.md +++ b/development.md @@ -68,11 +68,6 @@ There are different coordinate systems used and I tried my best to add these to ## Release process -Before releasing make sure that the cv2 path is added to your PYTHONPATH in System variables or User variables for current user:
-Edit the system environment variables -> Environment Variables... -> New...
-Variable name: PYTHONPATH
-Variable value: C:\Users\YOUR_WINDOWS_USER_NAME\miniconda3\envs\botty\Lib\site-packages\cv2
- If you installed your miniconda in another location you will of course have ot change it for that one. ```bash # Adapt new version with x.x.x, build .exe and bundeling all needed resource into one folder diff --git a/environment.yml b/environment.yml index 05571c4..6b13333 100644 --- a/environment.yml +++ b/environment.yml @@ -1,22 +1,19 @@ name: botty dependencies: - - python=3.8 - - pywin32 + - python=3.9 - pip - pip: - - nuitka - - matplotlib + - pyinstaller - opencv-python - transitions - mss - numpy - mouse - keyboard - - graphviz - beautifultable - - zstandard - pytweening - requests - pytest - pytest-env - pytest-pythonpath + - graphviz diff --git a/release.py b/release.py index 53b2b9e..6fd2a25 100644 --- a/release.py +++ b/release.py @@ -1,69 +1,72 @@ import os import shutil from pathlib import Path -import sys from src.version import __version__ +import argparse +import getpass -# Note: Before building you must add cv2 to python path: -# e.g. C:\Users\USER\miniconda3\envs\botty\lib\site-packages\cv2 -# change version -botty_dir = f"botty_v{__version__}" -new_dev_version_code = None -if len(sys.argv) == 2: - print(f"Releasing new version: {sys.argv[1]}") - os.system(f"git checkout -b new-release-v{sys.argv[1]}") - botty_dir = f"botty_v{sys.argv[1]}" +parser = argparse.ArgumentParser(description="Release a new Botty Version") +parser.add_argument( + "version", + type=str, + help="New release version e.g. 0.4.2" +) +parser.add_argument( + "-c", "--conda_path", + type=str, + help="Path to local conda e.g. C:\\Users\\USER\\miniconda3", + default=f"C:\\Users\\{getpass.getuser()}\\miniconda3") +args = parser.parse_args() + + +# clean up +def clean_up(): + if os.path.exists("build"): + shutil.rmtree("build") + if os.path.exists("run.spec"): + os.remove("run.spec") + + +if __name__ == "__main__": + # change version + new_dev_version_code = None + print(f"Releasing new version: {args.version}") + os.system(f"git checkout -b new-release-v{args.version}") + botty_dir = f"botty_v{args.version}" version_code = "" with open('src/version.py', 'r') as f: version_code = f.read() version_code = version_code.split("=") - new_version_code = f"{version_code[0]}= '{sys.argv[1]}'" - new_dev_version_code = f"{version_code[0]}= '{sys.argv[1]}-dev'" + new_version_code = f"{version_code[0]}= '{args.version}'" + new_dev_version_code = f"{version_code[0]}= '{args.version}-dev'" with open('src/version.py', 'w') as f: f.write(new_version_code) -else: - raise ValueError("Please provide new version") -# clean up -def clean_up(): - if os.path.exists("run.dist"): - shutil.rmtree("run.dist") - if os.path.exists("run.build"): - shutil.rmtree("run.build") - if os.path.exists("run.onefile"): - shutil.rmtree("run.onefile") - if os.path.exists("run.onefile-build"): - shutil.rmtree("run.onefile-build") - if os.path.exists("run.exe"): - os.remove("run.exe") + clean_up() -clean_up() + if os.path.exists(botty_dir): + for path in Path(botty_dir).glob("**/*"): + if path.is_file(): + os.remove(path) + elif path.is_dir(): + shutil.rmtree(path) + shutil.rmtree(botty_dir) -if os.path.exists(botty_dir): - for path in Path(botty_dir).glob("**/*"): - if path.is_file(): - os.remove(path) - elif path.is_dir(): - shutil.rmtree(path) - shutil.rmtree(botty_dir) + installer_cmd = f"pyinstaller --onefile --distpath {botty_dir} --exclude-module graphviz --paths .\\src --paths {args.conda_path}\\envs\\botty\\lib\\site-packages src\\run.py" + os.system(installer_cmd) + os.system(f"mkdir {botty_dir}") -installer_cmd = f"python -m nuitka --mingw64 --standalone --onefile --assume-yes-for-downloads --plugin-enable=numpy src/run.py" -os.system(installer_cmd) + with open(f"{botty_dir}/custom.ini", "w") as f: + f.write("; Add parameters you want to overwrite from param.ini here") + shutil.copy("game.ini", f"{botty_dir}/") + shutil.copy("params.ini", f"{botty_dir}/") + shutil.copy("README.md", f"{botty_dir}/") + shutil.copytree("assets", f"{botty_dir}/assets") + clean_up() -os.system(f"mkdir {botty_dir}") - -with open(f"{botty_dir}/custom.ini", "w") as f: - f.write("; Add parameters you want to overwrite from param.ini here") -shutil.copy("run.exe", f"{botty_dir}/") -shutil.copy("game.ini", f"{botty_dir}/") -shutil.copy("params.ini", f"{botty_dir}/") -shutil.copy("README.md", f"{botty_dir}/") -shutil.copytree("assets", f"{botty_dir}/assets") -clean_up() - -if new_dev_version_code is not None: - with open('src/version.py', 'w') as f: - f.write(new_dev_version_code) - os.system(f'git add .') - os.system(f'git commit -m "Bump version to v{sys.argv[1]}"') + if new_dev_version_code is not None: + with open('src/version.py', 'w') as f: + f.write(new_dev_version_code) + os.system(f'git add .') + os.system(f'git commit -m "Bump version to v{args.version}"')