Skip to content

Commit eac2ea9

Browse files
expect libtokenizers.a in tokenizer src directory
1 parent 171c6c7 commit eac2ea9

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ target
99

1010
# Python
1111
.env
12+
13+
# macos
14+
.DS_Store

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ release-darwin-%: test
1616
cp artifacts/darwin-$*/libtokenizers.darwin-$*.tar.gz artifacts/all/libtokenizers.darwin-$*.tar.gz
1717

1818
release-linux-%: test
19-
docker buildx build --platform linux/$* --build-arg="DOCKER_TARGETPLATFORM=linux/$*" -f release/Dockerfile . -t tokenizers.linux-$*
19+
docker buildx build --platform linux/$* -f release/Dockerfile . -t tokenizers.linux-$*
2020
mkdir -p artifacts/linux-$*
21-
docker run -v $(PWD)/artifacts/linux-$*:/mnt --entrypoint ls tokenizers.linux-$* /workspace/tokenizers/lib/linux
22-
docker run -v $(PWD)/artifacts/linux-$*:/mnt --entrypoint cp tokenizers.linux-$* /workspace/tokenizers/lib/linux/$*/libtokenizers.a /mnt/libtokenizers.a
21+
docker run -v $(PWD)/artifacts/linux-$*:/mnt --entrypoint cp tokenizers.linux-$* /workspace/tokenizers/libtokenizers.a /mnt/libtokenizers.a
2322
cd artifacts/linux-$* && \
2423
tar -czf libtokenizers.linux-$*.tar.gz libtokenizers.a
2524
mkdir -p artifacts/all
@@ -31,10 +30,10 @@ release: release-darwin-aarch64 release-darwin-x86_64 release-linux-arm64 releas
3130
cp artifacts/all/libtokenizers.linux-x86_64.tar.gz artifacts/all/libtokenizers.linux-amd64.tar.gz
3231

3332
test: build
34-
@go test -ldflags="-extldflags '-L./'" -v ./... -count=1
33+
@go test -v ./... -count=1
3534

3635
clean:
3736
rm -rf libtokenizers.a target
3837

3938
bazel-sync:
40-
CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index
39+
CARGO_BAZEL_REPIN=1 bazel sync --only=crate_index

example/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ RUN curl -fsSL https://github.com/cohere-ai/tokenizers/releases/download/${VERSI
88
COPY ./example .
99
COPY ./test/data ./test/data
1010
RUN go mod download
11-
RUN mv ./libtokenizers.a /go/pkg/mod/github.com/cohere-ai/tokenizers@${VERSION}/lib/$(echo ${TARGETPLATFORM} | tr / -)/libtokenizers.a
11+
RUN mv ./libtokenizers.a /go/pkg/mod/github.com/daulet/tokenizers@${VERSION}/libtokenizers.a
1212
# mounting Go cache won't work since we mutate it above
13-
RUN go run main.go
13+
RUN go run main.go

release/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ COPY ./Cargo.lock ./Cargo.lock
1010
RUN cargo build --release
1111

1212
FROM golang:1.21 as builder-go
13-
ARG DOCKER_TARGETPLATFORM
13+
ARG TARGETPLATFORM
1414
WORKDIR /workspace
1515
COPY ./release/go.mod .
1616
COPY ./release/main.go .
@@ -19,6 +19,6 @@ COPY tokenizer.go ./tokenizers/
1919
COPY tokenizers.h ./tokenizers/
2020
COPY --from=builder-rust \
2121
/workspace/target/release/libtokenizers.a \
22-
./tokenizers/lib/${DOCKER_TARGETPLATFORM}/
22+
./tokenizers/
2323
COPY ./test/data ./test/data
24-
RUN go run -ldflags="-extldflags '-L./tokenizers/lib/${DOCKER_TARGETPLATFORM}'" .
24+
RUN go run .

tokenizer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package tokenizers
33
// TODO packaging: how do we build the rust lib for distribution?
44

55
/*
6-
#cgo LDFLAGS: -ltokenizers -ldl -lm -lstdc++
6+
#cgo LDFLAGS: ${SRCDIR}/libtokenizers.a -ldl -lm -lstdc++
77
#include <stdlib.h>
88
#include "tokenizers.h"
99
*/

0 commit comments

Comments
 (0)