From 239a5c14eff3c2f1ec411398a46ddbe14b60e758 Mon Sep 17 00:00:00 2001 From: Richard Guo Date: Wed, 10 May 2023 13:57:54 -0400 Subject: [PATCH] refactor circle ci config --- .circleci/config.yml | 177 +++++++++++++++++++ gpt4all-bindings/python/README.md | 1 - gpt4all-bindings/python/gpt4all/pyllmodel.py | 2 +- 3 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..d0b4d8db --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,177 @@ +version: 2.1 +orbs: + win: circleci/windows@5.0 + python: circleci/python@1.2 + +jobs: + build-linux: + docker: + - image: circleci/python:3.8 + steps: + - checkout + - run: + name: Install dependencies + command: | + sudo apt-get update + sudo apt-get install -y cmake build-essential + pip install setuptools wheel cmake + - run: + name: Build C library + command: | + git submodule init + git submodule update + cd gpt4all-backend/llmodel + mkdir build + cd build + cmake .. + cmake --build . --parallel + - run: + name: Build wheel + command: | + cd gpt4all-bindings/python/ + python setup.py bdist_wheel --plat-name=manylinux1_x86_64 + - persist_to_workspace: + root: gpt4all-bindings/python/dist + paths: + - "*.whl" + + build-macos: + macos: + xcode: "14.2.0" + resource_class: macos.m1.large.gen1 + steps: + - checkout + - run: + name: Install dependencies + command: | + brew install cmake + pip install setuptools wheel cmake + - run: + name: Build C library + command: | + git submodule init + git submodule update + cd gpt4all-backend/llmodel + mkdir build + cd build + cmake .. -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" + cmake --build . --parallel + - run: + name: Build wheel + command: | + cd gpt4all-bindings/python + python setup.py bdist_wheel --plat-name=macosx_10_9_universal2 + - persist_to_workspace: + root: gpt4all-bindings/python/dist + paths: + - "*.whl" + + # build-linux: + # docker: + # - image: circleci/python:3.8 + # steps: + # - checkout + # - run: + # name: Install dependencies + # command: | + # sudo apt-get update + # sudo apt-get install -y cmake build-essential + # pip install setuptools wheel cmake + # - run: + # name: Install MingW + # command: sudo apt-get install -y mingw-w64 + # - run: + # name: Build C library + # command: | + # git submodule init + # git submodule update + # cd llmodel + # mkdir build + # cd build + # cmake \ + # -DCMAKE_SYSTEM_NAME=Windows \ + # -DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \ + # -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \ + # -DCMAKE_EXECUTABLE_SUFFIX=".exe" \ + # -DCMAKE_SHARED_LIBRARY_SUFFIX=".dll" \ + # .. + # cmake --build . --parallel + # - run: + # name: Build wheel + # command: | + # cd bindings/python/ + # python setup.py bdist_wheel --plat-name=manylinux1_x86_64 + # - persist_to_workspace: + # root: bindings/python/dist + # paths: + # - "*.whl" + + build-windows: + executor: + name: win/default + steps: + - checkout + - run: + name: Install MinGW64 + command: choco install -y mingw --force --no-progress + - run: + name: Add MinGW64 to PATH + command: $env:Path += ";C:\ProgramData\chocolatey\lib\mingw\tools\install\mingw64\bin" + - run: + name: Install dependencies + command: choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' + - run: + name: Install Python dependencies + command: pip install setuptools wheel cmake + - run: + name: Build C library + command: | + git submodule init + git submodule update + cd gpt4all-backend/llmodel + mkdir build + cd build + cmake -G "MinGW Makefiles" .. + cmake --build . --parallel + - run: + name: Build wheel + command: | + cd gpt4all-bindings/python + python setup.py bdist_wheel --plat-name=win_amd64 + - persist_to_workspace: + root: gpt4all-bindings/python/dist + paths: + - "*.whl" + + store-and-upload-wheels: + docker: + - image: circleci/python:3.8 + steps: + - setup_remote_docker + - attach_workspace: + at: /tmp/workspace + - run: + name: Install dependencies + command: | + sudo apt-get update + sudo apt-get install -y cmake build-essential + pip install setuptools wheel twine + # - run: + # name: Upload Python package + # command: | + # twine upload /tmp/workspace/*.whl --username __token__ --password $PYPI_CRED + - store_artifacts: + path: /tmp/workspace + +workflows: + version: 2 + build-deploy: + jobs: + #- build-linux + #- build-macos + - build-windows + - store-and-upload-wheels: + requires: + - build-windows + # - build-linux + # - build-macos diff --git a/gpt4all-bindings/python/README.md b/gpt4all-bindings/python/README.md index 4275fbb4..057704d1 100644 --- a/gpt4all-bindings/python/README.md +++ b/gpt4all-bindings/python/README.md @@ -38,4 +38,3 @@ messages = [{"role": "user", "content": "Name 3 colors"}] gptj.chat_completion(messages) ``` - diff --git a/gpt4all-bindings/python/gpt4all/pyllmodel.py b/gpt4all-bindings/python/gpt4all/pyllmodel.py index c08b7919..bfba0468 100644 --- a/gpt4all-bindings/python/gpt4all/pyllmodel.py +++ b/gpt4all-bindings/python/gpt4all/pyllmodel.py @@ -7,7 +7,7 @@ import re import sys # TODO: provide a config file to make this more robust -LLMODEL_PATH = os.path.join("llmodel_DO_NOT_MODIFY", "build") +LLMODEL_PATH = os.path.join("llmodel_DO_NOT_MODIFY", "build").replace("\\", "\\\\") def load_llmodel_library(): system = platform.system()