Skip to content

Commit 5dd9db9

Browse files
fix
1 parent 436fd93 commit 5dd9db9

4 files changed

Lines changed: 173 additions & 123 deletions

File tree

.github/workflows/prerelease.yml

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -124,45 +124,53 @@ jobs:
124124
echo "set version to ${TARGET_PYTHON}"
125125
python _update_bazel_py_version.py $TARGET_PYTHON
126126
127-
- name: Build with custom toolchain
127+
- name: build custom C++ toolchain
128128
env:
129129
TARGET_PYTHON: ${{ matrix.python-version }}
130130
run: |
131131
. devtools/build_with_custom_toolchain.sh
132-
ls custom_sysroot
132+
133+
- name: Build package
134+
env:
135+
TARGET_PYTHON: ${{ matrix.python-version }}
136+
run: |
137+
export GLIBC_VERSION=2.28
138+
echo $GLIBC_VERSION
139+
sed "s/^MANYLINUX_VERSION.*/MANYLINUX_VERSION=\"manylinux_${GLIBC_VERSION}_x86_64.manylinux2014_x86_64\"/" BUILD -i || true
140+
bazel build --define GLIBC_VERSION=$GLIBC_VERSION --define TARGET_VERSION="$(python -c "print(\"py${TARGET_PYTHON}\".replace(\".\", \"\"))")" --define VERSION="$(cat version/version.txt)" :tesseract_decoder_wheel
133141
134142
135143
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
136144
with:
137145
name: python-wheels-${{ matrix.os }}-${{ matrix.python-version }}
138146
path: ./bazel-bin/*.whl
139147

140-
release-wheels:
141-
name: Publish all wheels
142-
needs: [build_wheels,build_wheels_with_custom_toolchain]
143-
runs-on: ubuntu-24.04
144-
145-
steps:
146-
- name: Download build artifacts
147-
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
148-
with:
149-
pattern: python-wheels-*
150-
merge-multiple: true
151-
path: wheelhouse/
152-
153-
- name: Publish package to testpypi
154-
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
155-
with:
156-
repository_url: https://test.pypi.org/legacy/
157-
user: __token__
158-
password: ${{ secrets.TEST_PYPI_TOKEN }}
159-
packages_dir: wheelhouse/
160-
verbose: true
161-
162-
163-
- name: Publish package to pypi
164-
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
165-
with:
166-
user: __token__
167-
password: ${{ secrets.PYPI_TOKEN }}
168-
packages_dir: wheelhouse/
148+
# release-wheels:
149+
# name: Publish all wheels
150+
# needs: [build_wheels,build_wheels_with_custom_toolchain]
151+
# runs-on: ubuntu-24.04
152+
153+
# steps:
154+
# - name: Download build artifacts
155+
# uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
156+
# with:
157+
# pattern: python-wheels-*
158+
# merge-multiple: true
159+
# path: wheelhouse/
160+
161+
# - name: Publish package to testpypi
162+
# uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
163+
# with:
164+
# repository_url: https://test.pypi.org/legacy/
165+
# user: __token__
166+
# password: ${{ secrets.TEST_PYPI_TOKEN }}
167+
# packages_dir: wheelhouse/
168+
# verbose: true
169+
170+
171+
# - name: Publish package to pypi
172+
# uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
173+
# with:
174+
# user: __token__
175+
# password: ${{ secrets.PYPI_TOKEN }}
176+
# packages_dir: wheelhouse/

MODULE.bazel

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module(name = "tesseract", version = "1.0")
22

3-
bazel_dep(name = "bazel_skylib", version = "1.7.1")
4-
bazel_dep(name = "platforms", version = "0.0.10")
5-
bazel_dep(name = "rules_python", version = "0.40.0")
6-
bazel_dep(name = "rules_cc", version = "0.0.17")
7-
bazel_dep(name = "pybind11_bazel", version = "2.13.6")
3+
bazel_dep(name = "bazel_skylib", version = "1.9.0")
4+
bazel_dep(name = "platforms", version = "1.0.0")
5+
bazel_dep(name = "rules_python", version = "1.9.0")
6+
bazel_dep(name = "rules_cc", version = "0.2.17")
7+
bazel_dep(name = "pybind11_bazel", version = "3.0.0")
88

99
DEFAULT_PYTHON_VERSION = "3.13"
1010

@@ -29,3 +29,98 @@ pip.parse(
2929
)
3030

3131
use_repo(pip, "pypi")
32+
33+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
34+
git_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
35+
bazel_dep(name = "zlib", version = "1.3.2")
36+
37+
HIGHS_VERSION = "1.9.0"
38+
HIGHS_SHA_256 = "dff575df08d88583c109702c7c5c75ff6e51611e6eacca8b5b3fdfba8ecc2cb4"
39+
40+
git_repository(
41+
name = "stim",
42+
commit = "bd60b73525fd5a9b30839020eb7554ad369e4337",
43+
remote = "https://github.com/quantumlib/stim.git",
44+
shallow_since = "1741128853 +0000",
45+
)
46+
47+
http_archive(
48+
name = "highs",
49+
sha256 = HIGHS_SHA_256,
50+
build_file = "//external:highs.BUILD",
51+
strip_prefix = "HiGHS-" + HIGHS_VERSION,
52+
urls = ["https://github.com/ERGO-Code/HiGHS/archive/refs/tags/v" + HIGHS_VERSION + ".tar.gz"],
53+
)
54+
55+
GTEST_VERSION = "1.13.0"
56+
57+
GTEST_SHA256 = "ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363"
58+
59+
http_archive(
60+
name = "gtest",
61+
sha256 = GTEST_SHA256,
62+
strip_prefix = "googletest-%s" % GTEST_VERSION,
63+
urls = ["https://github.com/google/googletest/archive/refs/tags/v%s.tar.gz" % GTEST_VERSION],
64+
)
65+
66+
ARGPARSE_SHA_256 = "3e5a59ab7688dcd1f918bc92051a10564113d4f36c3bbed3ef596c25e519a062"
67+
68+
http_archive(
69+
name = "argparse",
70+
build_file = "//external:argparse.BUILD",
71+
sha256 = ARGPARSE_SHA_256,
72+
strip_prefix = "argparse-3.1",
73+
urls = ["https://github.com/p-ranav/argparse/archive/refs/tags/v3.1.zip"],
74+
)
75+
76+
git_repository(
77+
name = "nlohmann_json",
78+
commit = "9cca280a4d0ccf0c08f47a99aa71d1b0e52f8d03",
79+
remote = "https://github.com/nlohmann/json.git",
80+
shallow_since = "1701207391 +0100",
81+
)
82+
83+
84+
85+
86+
BOOST_VERSION = "1.83.0"
87+
BOOST_ARCHIVE_NAME = "boost_{}".format(BOOST_VERSION.replace(".", "_"))
88+
89+
http_archive(
90+
name = "boost",
91+
urls = [
92+
"https://archives.boost.io/release/{}/source/{}.tar.gz".format(
93+
BOOST_VERSION,
94+
BOOST_ARCHIVE_NAME,
95+
)
96+
],
97+
strip_prefix = BOOST_ARCHIVE_NAME,
98+
sha256 = "c0685b68dd44cc46574cce86c4e17c0f611b15e195be9848dfd0769a0a207628",
99+
build_file = "//external:boost.BUILD",
100+
)
101+
102+
103+
###
104+
105+
cc_compatibility_proxy = use_extension("@rules_cc//cc:extensions.bzl", "compatibility_proxy")
106+
use_repo(cc_compatibility_proxy, "cc_compatibility_proxy")
107+
108+
bazel_dep(name = "toolchains_llvm", version = "1.6.0")
109+
110+
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm")
111+
llvm.toolchain(
112+
name = "llvm_toolchain",
113+
llvm_version = "17.0.6", # Downloads a self-contained Clang/LLVM 17
114+
)
115+
116+
# 3. Inject your custom GLIBC 2.28 sysroot
117+
llvm.sysroot(
118+
name = "llvm_toolchain",
119+
label = "//custom_sysroot:sysroot",
120+
targets = ["linux-x86_64"], # Assuming you are building for x86_64 Linux
121+
)
122+
use_repo(llvm, "llvm_toolchain")
123+
124+
# 4. Register the toolchain to override the host OS compiler
125+
register_toolchains("@llvm_toolchain//:all")
126+

WORKSPACE

Lines changed: 0 additions & 87 deletions
This file was deleted.

devtools/build_with_custom_toolchain.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,37 @@ tar -xzf sysroot.tar.gz -C custom_sysroot
3030
rm sysroot.tar.gz
3131
docker rm -f sysroot-builder
3232

33+
# create custom_sysroot/BUILD
34+
echo """filegroup(
35+
name = \"sysroot\",
36+
srcs = glob([\"**/*\"]),
37+
visibility = [\"//visibility:public\"],
38+
)""" > custom_sysroot/BUILD
39+
40+
# update MODULE.bazel to use the custom toolchain
41+
echo """bazel_dep(name = \"toolchains_llvm\", version = \"1.6.0\")
42+
43+
llvm = use_extension(\"@toolchains_llvm//toolchain/extensions:llvm.bzl\", \"llvm\")
44+
llvm.toolchain(
45+
name = \"llvm_toolchain\",
46+
llvm_version = \"17.0.6\",
47+
)
48+
49+
llvm.sysroot(
50+
name = \"llvm_toolchain\",
51+
label = \"//custom_sysroot:sysroot\",
52+
targets = [\"linux-x86_64\"],
53+
)
54+
use_repo(llvm, \"llvm_toolchain\")
55+
56+
register_toolchains(\"@llvm_toolchain//:all\")
57+
""" >> MODULE.bazel
58+
59+
60+
apt-get update
61+
apt-get install -y libxml2
62+
63+
cd custom_sysroot/lib64/
64+
rm -f ld-linux-x86-64.so.2
65+
ln -s ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 ld-linux-x86-64.so.2
66+
cd ../..

0 commit comments

Comments
 (0)