From 22411a314a7b78da3314525522a7363e53940fd9 Mon Sep 17 00:00:00 2001 From: "firedcto@gmail.com" Date: Wed, 27 Nov 2024 21:22:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=80=A7=E8=83=BD=E4=BB=A5=E5=8F=8A=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 77 ++++++++++------------------ .github/workflows/push_repos.yml | 52 ------------------- .github/workflows/remove_sources.yml | 29 ----------- deploy.txt | 13 +++++ requirements-dev.txt | 2 + requirements.txt | 2 +- setup.py | 63 +++++++++++++++++++++++ 7 files changed, 107 insertions(+), 131 deletions(-) delete mode 100644 .github/workflows/push_repos.yml delete mode 100644 .github/workflows/remove_sources.yml create mode 100644 deploy.txt create mode 100644 requirements-dev.txt create mode 100644 setup.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 63e4dd7..33bb39e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,42 +39,49 @@ jobs: - name: Install Dependencies run: | - python -m pip install --upgrade pip pip install -r requirements.txt + pip install -r requirements-dev.txt - name: Copy ok-script lib run: | python -m ok.update.copy_ok_folder + - name: Rename .py files to .pyx + run: | + Get-ChildItem -Path .\src -Recurse -Filter *.py -Exclude '__init__.py' | ForEach-Object { Rename-Item $_.FullName -NewName ($_.FullName -replace '\.py$', '.pyx') } + + - name: build cython + run: | + python setup.py build_ext --inplace + Get-ChildItem -Path .\src -Recurse -Filter *.pyx | ForEach-Object { Remove-Item $_.FullName } + Get-ChildItem -Path .\src -Recurse -Filter *.cpp | ForEach-Object { Remove-Item $_.FullName } + + - name: Run tests + run: | + python -m ok.test.RunTests + - name: Build Executable run: | echo "tag: ${{ steps.changes.outputs.tag }}" echo "changes: ${{ steps.changes.outputs.changes }}" - python -m ok.update.package_launcher ${{ steps.tagName.outputs.tag }} - python -m ok.update.gen_md5 .\dist - Copy-Item -Path "dist" -Destination "ok-ww" -Recurse - 7z a -t7z -r "ok-ww-release-${{ steps.tagName.outputs.tag }}.7z" "ok-ww" - 7z a -tzip -r "ok-ww-${{ steps.tagName.outputs.tag }}.zip" "ok-ww" - Remove-Item -Path "ok-ww" -Recurse -Force + python -m ok.update.package_launcher ${{ steps.tagName.outputs.tag }} deploy.txt python -m ok.update.package_full_with_profile ${{ steps.tagName.outputs.tag }} 1 - python -m ok.update.gen_md5 .\dist Copy-Item -Path "dist" -Destination "ok-ww" -Recurse 7z a -t7z -r "ok-ww-CPU-full-${{ steps.tagName.outputs.tag }}.7z" "ok-ww" Remove-Item -Path "ok-ww" -Recurse -Force python -m ok.update.package_full_with_profile ${{ steps.tagName.outputs.tag }} 0 - python -m ok.update.gen_md5 .\dist Copy-Item -Path "dist" -Destination "ok-ww" -Recurse 7z a -t7z -r "ok-ww-Nvidia-GPU-full-${{ steps.tagName.outputs.tag }}.7z" "ok-ww" Remove-Item -Path "ok-ww" -Recurse -Force shell: pwsh - - name: Create Release - id: create_release - uses: actions/create-release@v1 + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: @@ -87,43 +94,15 @@ jobs: ${{ steps.changes.outputs.changes }} draft: false prerelease: true + files: | + ok-ww-CPU-full-${{ steps.tagName.outputs.tag }}.7z + ok-ww-Nvidia-GPU-full-${{ steps.tagName.outputs.tag }}.7z - - name: upload-7z - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./ok-ww-release-${{ steps.tagName.outputs.tag }}.7z - asset_name: ok-ww-release-${{ steps.tagName.outputs.tag }}.7z - asset_content_type: application/x-7z-compressed + - name: push to ok-ww-update + run: | + python -m ok.update.push_repos --repos https://ok-oldking:${{ secrets.OK_GH }}@github.com/ok-oldking/ok-ww-update --files src ok config.py launcher.json launcher.py main.py ok-ww.exe main.py main_debug.py main_gpu.py main_gpu_debug.py assets i18n icon.png requirements.txt - - name: upload-zip - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./ok-ww-${{ steps.tagName.outputs.tag }}.zip - asset_name: ok-ww-${{ steps.tagName.outputs.tag }}.zip - asset_content_type: application/zip + - name: push to coding + run: | + python -m ok.update.push_repos --repos https://${{ secrets.CODING_USERNAME }}:${{ secrets.CODING_PASSWORD }}@e.coding.net/g-frfh1513/ok-wuthering-waves/ok-wuthering-waves.git --files src ok config.py launcher.json launcher.py main.py ok-ww.exe main.py main_debug.py main_gpu.py main_gpu_debug.py assets i18n icon.png requirements.txt - - name: upload-7z-gpu - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./ok-ww-Nvidia-GPU-full-${{ steps.tagName.outputs.tag }}.7z - asset_name: ok-ww-Nvidia-GPU-full-${{ steps.tagName.outputs.tag }}.7z - asset_content_type: application/x-7z-compressed - - - name: upload-7z-cpu - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: ./ok-ww-CPU-full-${{ steps.tagName.outputs.tag }}.7z - asset_name: ok-ww-CPU-full-${{ steps.tagName.outputs.tag }}.7z - asset_content_type: application/x-7z-compressed diff --git a/.github/workflows/push_repos.yml b/.github/workflows/push_repos.yml deleted file mode 100644 index bc15778..0000000 --- a/.github/workflows/push_repos.yml +++ /dev/null @@ -1,52 +0,0 @@ -on: - push: - # Sequence of patterns matched against refs/tags - tags: - - 'lts' - - 'v*' - branches: - - master - -jobs: - build: - name: push to update repos - runs-on: windows-latest - steps: - - name: Configure git - run: | - git config --global user.email "ok-oldking@users.noreply.github.com" - git config --global user.name "ok-oldking" - - - name: Checkout source repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.OK_GH }} - fetch-depth: 0 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.12' # Use the version of Python you need - - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install -r requirements.txt - - - name: test - run: | - python -m unittest discover tests - - - name: Copy ok-script lib - run: | - python -m ok.update.copy_ok_folder - - - name: push to ok-ww-update - run: | - python -m ok.update.push_repos --repos https://ok-oldking:${{ secrets.OK_GH }}@github.com/ok-oldking/ok-ww-update --files src ok config.py launcher.json launcher.py main.py ok-ww.exe main.py main_debug.py main_gpu.py main_gpu_debug.py assets i18n icon.png requirements.txt - - - name: push to coding - run: | - python -m ok.update.push_repos --repos https://${{ secrets.CODING_USERNAME }}:${{ secrets.CODING_PASSWORD }}@e.coding.net/g-frfh1513/ok-wuthering-waves/ok-wuthering-waves.git --files src ok config.py launcher.json launcher.py main.py ok-ww.exe main.py main_debug.py main_gpu.py main_gpu_debug.py assets i18n icon.png requirements.txt - - diff --git a/.github/workflows/remove_sources.yml b/.github/workflows/remove_sources.yml deleted file mode 100644 index 3716f0e..0000000 --- a/.github/workflows/remove_sources.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Remove Source Archives - -on: - release: - types: [ published ] - -jobs: - remove-source-archives: - runs-on: ubuntu-latest - steps: - - name: Set up GitHub CLI - run: | - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0 - sudo apt-add-repository https://cli.github.com/packages - sudo apt-get update - sudo apt-get install gh - - - name: Authenticate GitHub CLI - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh auth login --with-token <<< "$GITHUB_TOKEN" - - - name: Remove Source Archives - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - release_id=$(gh release view ${{ github.event.release.tag_name }} --json id --jq .id) - gh api repos/${{ github.repository }}/releases/$release_id/assets --jq '.[] | select(.name | endswith(".zip") or endswith(".tar.gz")).id' | - xargs -I {} gh api repos/${{ github.repository }}/releases/assets/{} -X DELETE diff --git a/deploy.txt b/deploy.txt new file mode 100644 index 0000000..fac12f5 --- /dev/null +++ b/deploy.txt @@ -0,0 +1,13 @@ +src +ok +config.py +launcher.json +launcher.py +main.py +ok-ww.exe +main.py +main_debug.py +main_gpu.py +assets +icon.png +requirements.txt \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..f7ea39a --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +cython==3.0.11 +setuptools==75.4.0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 8cdb874..6f04ed9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ok-script==0.0.332 +ok-script==0.0.357 #rapidocr_onnxruntime rapidocr_openvino pySide6-Fluent-Widgets>=1.5.5 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..df6a9f8 --- /dev/null +++ b/setup.py @@ -0,0 +1,63 @@ +import setuptools +from Cython.Build import cythonize +from distutils.extension import Extension +from setuptools import Extension + +import os + +os.environ["PYTHONIOENCODING"] = "utf-8" + + +def find_pyx_packages(base_dir): + extensions = [] + for dirpath, _, filenames in os.walk(base_dir): + for filename in filenames: + if filename.endswith(".pyx"): + module_path = os.path.join(dirpath, filename).replace('/', '.').replace('\\', '.') + module_name = module_path[:-4] # Remove the .pyx extension + extensions.append( + Extension(name=module_name, language="c++", sources=[os.path.join(dirpath, filename)])) + print(f'add Extension: {module_name} {[os.path.join(dirpath, filename)]}') + return extensions + + +def find_packages_with_init_files(base_dir): + packages = [] + for dirpath, dirnames, filenames in os.walk(base_dir): + if '__init__.py' in filenames: + package = dirpath.replace('/', '.').replace('\\', '.') + packages.append(package) + return packages + + +base_dir = "src" +extensions = find_pyx_packages(base_dir) + +setuptools.setup( + name="ok-ww", + version="0.0.1", + author="ok-oldking", + author_email="firedcto@gmail.com", + description="Automation with Computer Vision for Python", + url="https://github.com/ok-oldking/ok-script", + packages=setuptools.find_packages(), + include_package_data=True, + classifiers=[ + "Programming Language :: Python :: 3", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: Microsoft :: Windows", + ], + install_requires=[ + 'pywin32>=306', + 'darkdetect>=0.8.0', + 'PySideSix-Frameless-Window>=0.4.3', + 'typing-extensions>=4.11.0', + 'PySide6-Essentials>=6.7.0', + 'GitPython>=3.1.43', + 'requests>=2.32.3', + 'psutil>=6.0.0' + ], + python_requires='>=3.9', + ext_modules=cythonize(extensions, compiler_directives={'language_level': "3"}) +)