Skip to content

Commit

Permalink
conda env
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterJH5574 committed Nov 17, 2024
1 parent d1606f6 commit 9b0d50b
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 44 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/wheel_mac_arm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/wheel_mac_x86.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheel_manylinux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/wheel_windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions scripts/build-environment.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion scripts/build_xgrammar_lib_osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_xgrammar_lib_win.bat
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 0 additions & 32 deletions scripts/sync_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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 == "":
Expand All @@ -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)


Expand Down

0 comments on commit 9b0d50b

Please sign in to comment.