2626
2727REQ_BUFFER_SIZE = 65536 # Chunk size when iterating a download body
2828
29- NINJA_RELEASES_GITHUB_REPO = "ninja-build /ninja"
29+ NINJA_RELEASES_GITHUB_REPO = "kitware /ninja"
3030
3131NINJA_SRC_ARCHIVE_URL_TEMPLATE = \
3232 "https://github.com/" + NINJA_RELEASES_GITHUB_REPO + "/archive/%s"
@@ -108,11 +108,18 @@ def get_ninja_archive_urls_and_sha256s(version):
108108 tag_name + ".zip" )
109109 }
110110
111- expected = {
112- "ninja-linux.zip" : "linux64_binary" ,
113- "ninja-mac.zip" : "macosx_binary" ,
114- "ninja-win.zip" : "win64_binary" ,
115- }
111+ if NINJA_RELEASES_GITHUB_REPO == "ninja-build/ninja" :
112+ expected = {
113+ "ninja-linux.zip" : "linux64_binary" ,
114+ "ninja-mac.zip" : "macosx_binary" ,
115+ "ninja-win.zip" : "win64_binary" ,
116+ }
117+ else :
118+ expected = {
119+ "ninja-%s_x86_64-linux-gnu.tar.gz" % version : "linux64_binary" ,
120+ "ninja-%s_x86_64-apple-darwin.tar.gz" % version : "macosx_binary" ,
121+ "ninja-%s_i686-pc-windows-msvc.zip" % version : "win64_binary" ,
122+ }
116123
117124 found = 0
118125 for asset in release ["assets" ]:
@@ -180,9 +187,9 @@ def update_cmake_urls_script(version):
180187 cmake_file .write (content )
181188
182189
183- def _update_file (filepath , regex , replacement ):
190+ def _update_file (filepath , regex , replacement , verbose = True ):
184191 msg = "Updating %s" % os .path .relpath (filepath , ROOT_DIR )
185- with _log (msg ):
192+ with _log (msg , verbose = verbose ):
186193 pattern = re .compile (regex )
187194 with open (filepath , 'r' ) as doc_file :
188195 lines = doc_file .readlines ()
@@ -195,21 +202,33 @@ def _update_file(filepath, regex, replacement):
195202
196203
197204def update_docs (version ):
198- pattern = re .compile (r"ninja \d.\d.\d" )
205+ pattern = re .compile (r"ninja \d.\d.\d(\.[\w\-]+)* " )
199206 replacement = "ninja %s" % version
200207 _update_file (
201208 os .path .join (ROOT_DIR , "README.rst" ),
202209 pattern , replacement )
203210
204- pattern = re .compile (r"\d.\d.\d" )
211+ pattern = re .compile (r"(?<=v) \d.\d.\d(?:\.[\w\-]+)*(?=(?:\.zip|\.tar\.gz|\/)) " )
205212 replacement = version
206213 _update_file (
207214 os .path .join (ROOT_DIR , "docs/update_ninja_version.rst" ),
208215 pattern , replacement )
209216
217+ pattern = re .compile (r"(?<!v)\d.\d.\d(?:\.[\w\-]+)*" )
218+ replacement = version
219+ _update_file (
220+ os .path .join (ROOT_DIR , "docs/update_ninja_version.rst" ),
221+ pattern , replacement , verbose = False )
222+
223+ pattern = re .compile (r"github\.com\/[\w\-_]+\/[\w\-_]+(?=\/(?:release|archive))" )
224+ replacement = "github.com/" + NINJA_RELEASES_GITHUB_REPO
225+ _update_file (
226+ os .path .join (ROOT_DIR , "docs/update_ninja_version.rst" ),
227+ pattern , replacement , verbose = False )
228+
210229
211230def update_tests (version ):
212- pattern = re .compile (r'expected_version = "\d.\d.\d"' )
231+ pattern = re .compile (r'expected_version = "\d.\d.\d(\.[\w\-]+)* "' )
213232 replacement = 'expected_version = "%s"' % version
214233 _update_file (os .path .join (
215234 ROOT_DIR , "tests/test_distribution.py" ), pattern , replacement )
0 commit comments