@@ -14,8 +14,16 @@ import (
14
14
// PureWheelBuild aggregates the options controlling a wheel build.
15
15
type PureWheelBuild struct {
16
16
rebuild.Location
17
- Requirements []string `json:"requirements"`
18
- RegistryTime time.Time `json:"registry_time" yaml:"registry_time,omitempty"`
17
+ Requirements []string `json:"requirements"`
18
+ PythonVersion string `json:"python_version"`
19
+ RegistryTime time.Time `json:"registry_time" yaml:"registry_time,omitempty"`
20
+ }
21
+
22
+ type SourceDistributionBuild struct {
23
+ rebuild.Location
24
+ Requirements []string `json:"requirements"`
25
+ PythonVersion string `json:"python_version"`
26
+ RegistryTime time.Time `json:"registry_time" yaml:"registry_time,omitempty"`
19
27
}
20
28
21
29
var _ rebuild.Strategy = & PureWheelBuild {}
@@ -33,16 +41,17 @@ func (b *PureWheelBuild) ToWorkflow() *rebuild.WorkflowStrategy {
33
41
Deps : []flow.Step {{
34
42
Uses : "pypi/deps/basic" ,
35
43
With : map [string ]string {
36
- "registryTime" : registryTime ,
37
- "requirements" : flow .MustToJSON (b .Requirements ),
38
- "venv" : "/deps" ,
44
+ "registryTime" : registryTime ,
45
+ "requirements" : flow .MustToJSON (b .Requirements ),
46
+ "pythonVersion" : b .PythonVersion ,
47
+ "venv" : "deps" ,
39
48
},
40
49
}},
41
50
Build : []flow.Step {{
42
51
Uses : "pypi/build/wheel" ,
43
52
With : map [string ]string {
44
53
"dir" : b .Location .Dir ,
45
- "locator" : "/ deps/bin/" ,
54
+ "locator" : "deps/bin/" ,
46
55
},
47
56
}},
48
57
OutputDir : "dist" ,
@@ -54,15 +63,75 @@ func (b *PureWheelBuild) GenerateFor(t rebuild.Target, be rebuild.BuildEnv) (reb
54
63
return b .ToWorkflow ().GenerateFor (t , be )
55
64
}
56
65
66
+ func (b * SourceDistributionBuild ) ToWorkflow () * rebuild.WorkflowStrategy {
67
+ var registryTime string
68
+ if ! b .RegistryTime .IsZero () {
69
+ registryTime = b .RegistryTime .Format (time .RFC3339 )
70
+ }
71
+ return & rebuild.WorkflowStrategy {
72
+ Location : b .Location ,
73
+ Source : []flow.Step {{
74
+ Uses : "git-checkout" ,
75
+ }},
76
+ Deps : []flow.Step {{
77
+ Uses : "pypi/deps/basic" ,
78
+ With : map [string ]string {
79
+ "registryTime" : registryTime ,
80
+ "requirements" : flow .MustToJSON (b .Requirements ),
81
+ "pythonVersion" : b .PythonVersion ,
82
+ "venv" : "deps" ,
83
+ },
84
+ }},
85
+ Build : []flow.Step {{
86
+ Uses : "pypi/build/sdist" ,
87
+ With : map [string ]string {
88
+ "dir" : b .Location .Dir ,
89
+ "locator" : "deps/bin/" ,
90
+ },
91
+ }},
92
+ OutputDir : "dist" ,
93
+ }
94
+ }
95
+
96
+ func (b * SourceDistributionBuild ) GenerateFor (t rebuild.Target , be rebuild.BuildEnv ) (rebuild.Instructions , error ) {
97
+ return b .ToWorkflow ().GenerateFor (t , be )
98
+ }
99
+
57
100
func init () {
58
101
for _ , t := range toolkit {
59
102
flow .Tools .MustRegister (t )
60
103
}
61
104
}
62
105
106
+ // if ! command -v pyenv &> /dev/null; then
107
+ //
108
+ // curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
109
+ // export PATH="/root/.pyenv/bin:$PATH"
110
+ // eval "$(pyenv init -)"
111
+ // eval "$(pyenv virtualenv-init -)"
112
+ // fi
113
+ //
114
+ // /root/.pyenv/bin/pyenv global {{.With.version}}`)[1:],
115
+ // "bash", "clang", "curl", "build-base", "patch", "zip", "zlib-dev", "libffi-dev", "linux-headers", "readline-dev", "openssl", "openssl-dev", "sqlite-dev", "bzip2-dev"
63
116
// Base tools for individual operations
64
117
var toolkit = []* flow.Tool {
118
+ // Use clang to avoid issues with openssl
119
+ // Python versions before 3.6 cannot be compiled with openssl 3.x, they require 1.0.x
65
120
{
121
+ Name : "pypi/setup-python" ,
122
+ Steps : []flow.Step {{
123
+ Runs : textwrap .Dedent (`
124
+ if [ ! -d "/root/.pyenv" ]; then
125
+ if ! command -v curl &> /dev/null; then
126
+ apk add clang curl build-base patch zip zlib-dev libffi-dev linux-headers readline-dev openssl openssl-dev sqlite-dev bzip2-dev xz-dev
127
+ fi
128
+ curl https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
129
+ fi
130
+ CC=clang /root/.pyenv/bin/pyenv install -s {{.With.version}}` )[1 :],
131
+ Needs : []string {"bash" , "clang" , "curl" , "build-base" , "patch" , "zip" , "zlib-dev" , "libffi-dev" , "linux-headers" , "readline-dev" , "openssl" , "openssl-dev" , "sqlite-dev" , "bzip2-dev" },
132
+ }},
133
+ }, {
134
+
66
135
Name : "pypi/setup-venv" ,
67
136
Steps : []flow.Step {{
68
137
Runs : textwrap .Dedent (`
@@ -95,10 +164,17 @@ var toolkit = []*flow.Tool{
95
164
{
96
165
Name : "pypi/deps/basic" ,
97
166
Steps : []flow.Step {
167
+ {
168
+ Uses : "pypi/setup-python" ,
169
+ With : map [string ]string {
170
+ "version" : "{{.With.pythonVersion}}" ,
171
+ },
172
+ },
98
173
{
99
174
Uses : "pypi/setup-venv" ,
100
175
With : map [string ]string {
101
- "locator" : "/usr/bin/" ,
176
+ // "locator": "/usr/bin/",
177
+ "locator" : "/root/.pyenv/versions/{{.With.pythonVersion}}/bin/" ,
102
178
"path" : "{{.With.venv}}" ,
103
179
},
104
180
},
@@ -125,4 +201,12 @@ var toolkit = []*flow.Tool{
125
201
Needs : []string {"python3" },
126
202
}},
127
203
},
204
+ {
205
+ Name : "pypi/build/sdist" ,
206
+ Steps : []flow.Step {{
207
+ Runs : textwrap .Dedent (`
208
+ {{.With.locator}}python3 -m build --sdist -n{{if and (ne .With.dir ".") (ne .With.dir "")}} {{.With.dir}}{{end}}` )[1 :],
209
+ Needs : []string {"python3" },
210
+ }},
211
+ },
128
212
}
0 commit comments