5
5
from pkg_resources import Requirement
6
6
from e3 .main import Main
7
7
from e3 .fs import mkdir , cp
8
+ from datetime import date
8
9
import argparse
9
10
import os
10
11
import re
21
22
wheels:
22
23
name1: url1#branch1
23
24
name2: url2
25
+ update_wheel_version_file: true
24
26
requirements:
25
27
- "req1"
26
28
- "req2"
27
29
- "req3"
28
30
discard_from_closure: "regexp"
29
31
frozen_requirement_file: "requirements.txt"
32
+
30
33
platforms:
31
34
- x86_64-linux
32
35
- x86_64-windows
33
36
- aarch64-linux
34
37
35
- wheels contains the list of wheel that should be locally built
38
+ wheels contains the optional list of wheel that should be locally built
36
39
from source located at a git repository url (branch is specified after
37
40
a #, if no branch is specified master is assumed
38
41
42
+ update_wheel_verison_file is an optional parameter to force version
43
+ update during generation of the wheels based on sources. The update
44
+ works only if the version is stored in a file called VERSION and the
45
+ version in this file has MAJOR.MINOR format. In that case during
46
+ generation the version is updated to MAJOR.MINOR.YYYYMMDD
47
+
39
48
requirements are additional python requirements as string
40
49
41
50
discard_from_closure are packages that should not be copied into the
@@ -87,6 +96,9 @@ def main() -> None:
87
96
# First build the local wheels
88
97
local_wheels = []
89
98
99
+ # Should we attempt to update VERSION files for wheels
100
+ update_version_file = config .get ("update_wheel_version_file" , False )
101
+
90
102
for name , url in config .get ("wheels" , {}).items ():
91
103
logging .info (f"Fetch { name } sources" )
92
104
if "#" in url :
@@ -107,6 +119,24 @@ def main() -> None:
107
119
if not m .args .skip_repo_updates :
108
120
checkout_manager .update (vcs = "git" , url = url , revision = rev )
109
121
122
+ if update_version_file :
123
+ # Try to update the version file for the given repository. Update
124
+ # is one only if there is file called VERSION and that the version
125
+ # has the format MAJOR.MINOR
126
+ version_file = os .path .join (checkout_manager .working_dir , "VERSION" )
127
+ if os .path .isfile (version_file ):
128
+ with open (version_file ) as fd :
129
+ version = fd .read ().strip ()
130
+ logging .info (f"Wheel { name } has version { version } " )
131
+ split_version = version .split ("." )
132
+ if len (split_version ) == 2 :
133
+ # We have a major and minor but no patch so add it automatically
134
+ version = f"{ version } .{ date .today ().strftime ('%Y%m%d' )} "
135
+ with open (version_file , "w" ) as fd :
136
+ fd .write (version )
137
+
138
+ logging .info (f"Wheel { name } version updated to { version } " )
139
+
110
140
local_wheels .append (
111
141
Wheel .build (
112
142
source_dir = checkout_manager .working_dir , dest_dir = wheel_cache_dir
0 commit comments