forked from replicate/cog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
82 lines (62 loc) · 1.94 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
SHELL := /bin/bash
COG_VERSION ?= $(shell git describe --tags --match 'v*' --abbrev=0)+dev
RELEASE_DIR := release
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
BINARY := $(RELEASE_DIR)/$(GOOS)/$(GOARCH)/cog
INSTALL_PATH := /usr/local/bin/cog
MAIN := cmd/cog/cog.go
BUILD_TIME := $(shell date +%Y-%m-%dT%H:%M:%S%z)
LDFLAGS := -ldflags "-X github.com/replicate/cog/pkg/global.Version=$(COG_VERSION) -X github.com/replicate/cog/pkg/global.BuildTime=$(BUILD_TIME) -w"
default: build
pkg/dockerfile/embed/cog.whl: python/* python/cog/* python/cog/server/* python/cog/command/*
@echo "Building Python library"
rm -rf python/dist
cd python && python setup.py bdist_wheel
mkdir -p pkg/dockerfile/embed
cp python/dist/*.whl pkg/dockerfile/embed/cog.whl
build-dependencies: pkg/dockerfile/embed/cog.whl
.PHONY: build
build: clean build-dependencies
@mkdir -p $(RELEASE_DIR)
CGO_ENABLED=0 go build $(LDFLAGS) -o $(BINARY) $(MAIN)
.PHONY: clean
clean:
rm -rf $(RELEASE_DIR)
rm -f pkg/dockerfile/embed/cog.whl
.PHONY: generate
generate:
go generate ./...
.PHONY: test-go
test-go: build-dependencies check-fmt vet lint
go get gotest.tools/gotestsum
go run gotest.tools/gotestsum -- -timeout 1200s -parallel 5 ./... $(ARGS)
# TODO(bfirsh): use local copy of cog so we don't have to install globally
.PHONY: test-integration
test-integration: install
cd test-integration/ && $(MAKE)
.PHONY: test-python
test-python:
cd python/ && pytest -vv
.PHONY: test
test: test-go test-python test-integration
.PHONY: install
install: build-dependencies
go install $(LDFLAGS) $(MAIN)
.PHONY: fmt
fmt:
go run golang.org/x/tools/cmd/goimports -w -d .
.PHONY: vet
vet:
go vet ./...
.PHONY: check-fmt
check-fmt:
go run golang.org/x/tools/cmd/goimports -d .
@test -z $$(go run golang.org/x/tools/cmd/goimports -l .)
.PHONY: lint
lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./...
mypy python/cog
.PHONY: mod-tidy
mod-tidy:
go mod tidy