From 9b0d50ba29320e84d624e63d0181bcf89ad1c3b6 Mon Sep 17 00:00:00 2001 From: Ruihang Lai Date: Sun, 17 Nov 2024 13:52:20 -0500 Subject: [PATCH] conda env --- .github/workflows/wheel_mac_arm.yaml | 6 ++--- .github/workflows/wheel_mac_x86.yaml | 6 ++--- .github/workflows/wheel_manylinux.yaml | 2 +- .github/workflows/wheel_windows.yaml | 6 ++--- scripts/build-environment.yaml | 18 +++++++++++++++ scripts/build_xgrammar_lib_osx.sh | 2 +- scripts/build_xgrammar_lib_win.bat | 2 +- scripts/sync_package.py | 32 -------------------------- 8 files changed, 30 insertions(+), 44 deletions(-) create mode 100644 scripts/build-environment.yaml diff --git a/.github/workflows/wheel_mac_arm.yaml b/.github/workflows/wheel_mac_arm.yaml index 60cda0c..1f2138d 100644 --- a/.github/workflows/wheel_mac_arm.yaml +++ b/.github/workflows/wheel_mac_arm.yaml @@ -27,16 +27,16 @@ jobs: # git clone https://github.com/mlc-ai/package package --recursive # - name: Setup script env # run: | - # mv package/conda/tvm-unity/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml + # mv scripts/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml # rm -rf conda # ln -s package/3rdparty/tlcpack/conda conda # - name: Sync XGrammar Package # run: | - # python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} --skip-conda + # python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} # # Use conda for LLVM dep # - uses: conda-incubator/setup-miniconda@v3 # with: - # activate-environment: tlcpack-build + # activate-environment: xgrammar-build # channel-priority: strict # environment-file: conda/build-environment.yaml # auto-activate-base: false diff --git a/.github/workflows/wheel_mac_x86.yaml b/.github/workflows/wheel_mac_x86.yaml index 9a65b82..4ea8dea 100644 --- a/.github/workflows/wheel_mac_x86.yaml +++ b/.github/workflows/wheel_mac_x86.yaml @@ -29,16 +29,16 @@ jobs: # git clone https://github.com/mlc-ai/package package --recursive # - name: Setup script env # run: | - # mv package/conda/tvm-unity/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml + # mv scripts/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml # rm -rf conda # ln -s package/3rdparty/tlcpack/conda conda # - name: Sync XGrammar Package # run: | - # python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} --skip-conda + # python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} # # Use conda for LLVM dep # - uses: conda-incubator/setup-miniconda@v3 # with: - # activate-environment: tlcpack-build + # activate-environment: xgrammar-build # channel-priority: strict # environment-file: conda/build-environment.yaml # auto-activate-base: false diff --git a/.github/workflows/wheel_manylinux.yaml b/.github/workflows/wheel_manylinux.yaml index 2f8664a..7d5c9ed 100644 --- a/.github/workflows/wheel_manylinux.yaml +++ b/.github/workflows/wheel_manylinux.yaml @@ -41,7 +41,7 @@ jobs: # ln -s package/3rdparty/tlcpack/conda conda # - name: Sync XGrammar Package # run: | - # python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} --skip-conda + # python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} # - name: Build XGrammar # env: # IMAGE: ${{ matrix.config.image }} diff --git a/.github/workflows/wheel_windows.yaml b/.github/workflows/wheel_windows.yaml index 20c26e4..714fcb7 100644 --- a/.github/workflows/wheel_windows.yaml +++ b/.github/workflows/wheel_windows.yaml @@ -30,16 +30,16 @@ jobs: git clone https://github.com/mlc-ai/package package --recursive - name: Setup script env run: | - mv package/conda/tvm-unity/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml + mv scripts/build-environment.yaml package/3rdparty/tlcpack/conda/build-environment.yaml rm -rf conda ln -s package/3rdparty/tlcpack/conda conda - name: Sync XGrammar Package run: | - python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} --skip-conda + python scripts/sync_package.py --package . --package-name xgrammar --version ${{ github.ref_name }} # Use conda for LLVM dep - uses: conda-incubator/setup-miniconda@v3 with: - activate-environment: tlcpack-build + activate-environment: xgrammar-build channel-priority: strict environment-file: conda/build-environment.yaml auto-activate-base: false diff --git a/scripts/build-environment.yaml b/scripts/build-environment.yaml new file mode 100644 index 0000000..a24e1d5 --- /dev/null +++ b/scripts/build-environment.yaml @@ -0,0 +1,18 @@ +name: xgrammar-build + +channels: + - conda-forge + +dependencies: + - llvmdev>=15 + - cmake>=3.24 + - zlib + - zstd-static + - git + - conda-build + - numpy + - pytest + - pip + - cython + - pybind11 + - ninja diff --git a/scripts/build_xgrammar_lib_osx.sh b/scripts/build_xgrammar_lib_osx.sh index 2f219a2..46e1a17 100755 --- a/scripts/build_xgrammar_lib_osx.sh +++ b/scripts/build_xgrammar_lib_osx.sh @@ -12,7 +12,7 @@ echo set\(XGRAMMAR_BUILD_CXX_TESTS OFF\) >>config.cmake # compile the xgrammar -python3 -m pip install ninja pybind11 torch +python3 -m pip install torch rm -rf build mkdir -p build cd build diff --git a/scripts/build_xgrammar_lib_win.bat b/scripts/build_xgrammar_lib_win.bat index 39cf630..40f9804 100644 --- a/scripts/build_xgrammar_lib_win.bat +++ b/scripts/build_xgrammar_lib_win.bat @@ -1,6 +1,6 @@ echo on -python3 -m pip install ninja pybind11 torch +python3 -m pip install torch del /f config.cmake echo set(XGRAMMAR_BUILD_PYTHON_BINDINGS ON) >> config.cmake diff --git a/scripts/sync_package.py b/scripts/sync_package.py index a440cbd..17f68a5 100644 --- a/scripts/sync_package.py +++ b/scripts/sync_package.py @@ -71,30 +71,6 @@ def get_version_tag(args): return pub_ver, local_ver -def update_conda(args, pkg, package_name): - pub_ver, _ = get_version_tag(args) - - # create initial yaml file - meta_yaml = os.path.join("conda", pkg, "recipe", "meta.yaml") - with open(meta_yaml, "w") as fo: - fo.write(open(os.path.join("conda", pkg, "recipe", "meta.in.yaml")).read()) - - update( - meta_yaml, - [ - (r"(?<=default_pkg_name = ')[^\']+", package_name), - (r"(?<=version = ')[.0-9a-z]+", pub_ver), - ], - args.dry_run, - ) - - update( - os.path.join("conda", pkg, "build_config.yaml"), - [("(?<=pkg_name: ')[^']+", package_name)], - args.dry_run, - ) - - def update_setup(args, package_name): pub_ver, _ = get_version_tag(args) rewrites = [ @@ -141,11 +117,6 @@ def main(): required=True, help="The version string (e.g., v0.1.0)", ) - parser.add_argument( - "--skip-conda", - action="store_true", - help="Skip version string replacement in conda.", - ) args = parser.parse_args() if args.src == "": @@ -154,9 +125,6 @@ def main(): checkout_source(args.src, args.version) - if not args.skip_conda: - update_conda(args, args.package, package_name) - update_setup(args, package_name)