-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'update-to-cmake-3.7.1'
* update-to-cmake-3.7.1: Fix flake8 errors requirements-dev: Update setup.py to support sdist build with scikit-build>=0.5.0 skbuild: Fix build within virtualenv on windows Unpin development requirements Update to CMake v3.7.1 cmake: Add python CLI to easily update version of CMake
- Loading branch information
Showing
9 changed files
with
256 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#----------------------------------------------------------------------------- | ||
# CMake sources | ||
set(unix_source_url "https://cmake.org/files/v3.7/cmake-3.7.1.tar.gz") | ||
set(unix_source_sha256 "449a5bce64dbd4d5b9517ebd1a1248ed197add6ad27934478976fd5f1f9330e1") | ||
|
||
set(windows_source_url "https://cmake.org/files/v3.7/cmake-3.7.1.zip") | ||
set(windows_source_sha256 "17f34341cc63a892679085f2cad3e3d1f172e0518ee7dde43716175033494dfa") | ||
|
||
#----------------------------------------------------------------------------- | ||
# CMake binaries | ||
|
||
set(linux32_binary_url "NA") # Linux 32-bit binaries not available | ||
set(linux32_binary_sha256 "NA") | ||
|
||
set(linux64_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-Linux-x86_64.tar.gz") | ||
set(linux64_binary_sha256 "7b4b7a1d9f314f45722899c0521c261e4bfab4a6b532609e37fef391da6bade2") | ||
|
||
set(macosx_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-Darwin-x86_64.tar.gz") | ||
set(macosx_binary_sha256 "1851d1448964893fdc5a8c05863326119f397a3790e0c84c40b83499c7960267") | ||
|
||
set(win32_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-win32-x86.zip") | ||
set(win32_binary_sha256 "d2ec53ba3e3a12f734ed7127704ff9a83361e7cc6f9a0f0b3e2b56d9868a76b9") | ||
|
||
set(win64_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-win64-x64.zip") | ||
set(win64_binary_sha256 "659ecb8207e1266786188c7eaf45308458ba5f719c985970f6f55ec0b5a96746") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
==================== | ||
Update CMake version | ||
==================== | ||
|
||
A developer should use the following steps to update the version ``X.Y.Z`` | ||
of CMake associated with the current CMake python distributions. | ||
|
||
Available CMake archives can be found at https://cmake.org/files. | ||
|
||
|
||
1. Install `requests` and `beautifulsoup4`:: | ||
|
||
$ pip install requests beautifulsoup4 | ||
|
||
2. Execute `scripts/update_cmake_version.py` command line tool with the desired | ||
``X.Y.Z`` CMake version available for download. For example:: | ||
|
||
$ python scripts/update_cmake_version.py 3.7.1 | ||
Collecting URLs and SHA256s from 'https://cmake.org/files/v3.7' | ||
Collecting URLs and SHA256s from 'https://cmake.org/files/v3.7' - done | ||
Updating 'CMakeUrls.cmake' with CMake version 3.7.1 | ||
Updating 'CMakeUrls.cmake' with CMake version 3.7.1 - done | ||
Updating docs/index.rst | ||
Updating docs/index.rst - done | ||
Updating README.rst | ||
Updating README.rst - done | ||
Updating tests/test_wheel.py | ||
Updating tests/test_wheel.py - done | ||
|
||
3. Create a topic named `update-to-cmake-X.Y.Z` and commit the changes | ||
|
||
4. Create a `Pull Request`. | ||
|
||
5. If all CI tests are passing, merge the topic and consider :doc:`making a new | ||
release </make_a_release>`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
codecov==2.0.5 | ||
coverage==4.2 | ||
flake8==3.0.4 | ||
pytest==3.0.3 | ||
pytest-cov==2.4.0 | ||
pytest-runner==2.9 | ||
pytest-virtualenv==1.2.4 | ||
scikit-build==0.4.0 | ||
virtualenv==15.0.3 | ||
codecov>=2.0.5 | ||
coverage>=4.2 | ||
flake8>=3.0.4 | ||
pytest>=3.0.3 | ||
pytest-cov>=2.4.0 | ||
pytest-runner>=2.9 | ||
pytest-virtualenv>=1.2.5 | ||
scikit-build>=0.5.0 | ||
virtualenv>=15.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
"""Command line executable allowing to update CMakeUrls.cmake | ||
given a CMake version. | ||
""" | ||
|
||
import argparse | ||
import contextlib | ||
import os | ||
import re | ||
import textwrap | ||
|
||
try: | ||
import requests | ||
except ImportError: | ||
raise SystemExit( | ||
"requests not available: " | ||
"consider installing it running 'pip install requests'" | ||
) | ||
|
||
try: | ||
from bs4 import BeautifulSoup | ||
except ImportError: | ||
raise SystemExit( | ||
"BeautifulSoup not available: " | ||
"consider installing it running 'pip install beautifulsoup4'" | ||
) | ||
|
||
ROOT_DIR = os.path.join(os.path.dirname(__file__), "..") | ||
|
||
|
||
@contextlib.contextmanager | ||
def _log(txt, verbose=True): | ||
if verbose: | ||
print(txt) | ||
yield | ||
if verbose: | ||
print("%s - done" % txt) | ||
|
||
|
||
def _major_minor(version): | ||
"""Given a string of the form ``X.Y.Z``, returns ``X.Y``.""" | ||
return ".".join(version.split(".")[:2]) | ||
|
||
|
||
def get_cmake_archive_urls_and_sha256s(version): | ||
files_base_url = "https://cmake.org/files/v%s" % _major_minor(version) | ||
|
||
with _log("Collecting URLs and SHA256s from '%s'" % files_base_url): | ||
|
||
soup = BeautifulSoup(requests.get(files_base_url).text, 'html.parser') | ||
|
||
sha_256_file = "cmake-%s-SHA-256.txt" % version | ||
|
||
expected = { | ||
"cmake-%s.tar.gz" % version: "unix_source", | ||
"cmake-%s.zip" % version: "win_source", | ||
"cmake-%s-Linux-x86_64.tar.gz" % version: "linux64_binary", | ||
"cmake-%s-Darwin-x86_64.tar.gz" % version: "macosx_binary", | ||
"cmake-%s-win32-x86.zip" % version: "win32_binary", | ||
"cmake-%s-win64-x64.zip" % version: "win64_binary", | ||
} | ||
|
||
# Check that (1) "a" text matches "href" value and (2) that all expected | ||
# files are listed on the page. | ||
found = 0 | ||
for a in soup.find_all('a'): | ||
if a.text in expected or a.text == sha_256_file: | ||
found += 1 | ||
assert a.text == a.get("href") | ||
assert len(expected) + 1 == found | ||
|
||
# Get SHA256s and URLs | ||
urls = {} | ||
sha_256_url = files_base_url + "/" + sha_256_file | ||
for line in requests.get(sha_256_url).text.splitlines(): | ||
file = line.split()[1].strip() | ||
if file in expected: | ||
sha256 = line.split()[0].strip() | ||
identifier = expected[file] | ||
urls[identifier] = (files_base_url + "/" + file, sha256) | ||
assert len(urls) == len(expected) | ||
|
||
return urls | ||
|
||
|
||
def generate_cmake_variables(urls_and_sha256s): | ||
template_inputs = {} | ||
|
||
# Get SHA256s and URLs | ||
for var_prefix, urls_and_sha256s in urls_and_sha256s.items(): | ||
template_inputs["%s_url" % var_prefix] = urls_and_sha256s[0] | ||
template_inputs["%s_sha256" % var_prefix] = urls_and_sha256s[1] | ||
|
||
cmake_variables = textwrap.dedent(""" | ||
#----------------------------------------------------------------------------- | ||
# CMake sources | ||
set(unix_source_url "{unix_source_url}") | ||
set(unix_source_sha256 "{unix_source_sha256}") | ||
set(windows_source_url "{win_source_url}") | ||
set(windows_source_sha256 "{win_source_sha256}") | ||
#----------------------------------------------------------------------------- | ||
# CMake binaries | ||
set(linux32_binary_url "NA") # Linux 32-bit binaries not available | ||
set(linux32_binary_sha256 "NA") | ||
set(linux64_binary_url "{linux64_binary_url}") | ||
set(linux64_binary_sha256 "{linux64_binary_sha256}") | ||
set(macosx_binary_url "{macosx_binary_url}") | ||
set(macosx_binary_sha256 "{macosx_binary_sha256}") | ||
set(win32_binary_url "{win32_binary_url}") | ||
set(win32_binary_sha256 "{win32_binary_sha256}") | ||
set(win64_binary_url "{win64_binary_url}") | ||
set(win64_binary_sha256 "{win64_binary_sha256}") | ||
""").format(**template_inputs) | ||
|
||
return cmake_variables | ||
|
||
|
||
def update_cmake_urls_script(version): | ||
content = generate_cmake_variables( | ||
get_cmake_archive_urls_and_sha256s(version)) | ||
cmake_urls_filename = "CMakeUrls.cmake" | ||
cmake_urls_filepath = os.path.join(ROOT_DIR, cmake_urls_filename) | ||
|
||
msg = "Updating '%s' with CMake version %s" % (cmake_urls_filename, version) | ||
with _log(msg), open(cmake_urls_filepath, "w") as cmake_file: | ||
cmake_file.write(content) | ||
|
||
|
||
def _update_file(filepath, regex, replacement): | ||
msg = "Updating %s" % os.path.relpath(filepath, ROOT_DIR) | ||
with _log(msg): | ||
pattern = re.compile(regex) | ||
with open(filepath, 'r') as doc_file: | ||
lines = doc_file.readlines() | ||
updated_content = [] | ||
for line in lines: | ||
updated_content.append( | ||
re.sub(pattern, replacement, line)) | ||
with open(filepath, "w") as doc_file: | ||
doc_file.writelines(updated_content) | ||
|
||
|
||
def update_docs(version): | ||
pattern = re.compile( | ||
r"CMake \d.\d.\d <https://cmake.org/cmake/help/v\d.\d/index.html>") | ||
replacement = ( | ||
"CMake %s <https://cmake.org/cmake/help/v%s/index.html>" % ( | ||
version, _major_minor(version))) | ||
for filename in ["docs/index.rst", "README.rst"]: | ||
_update_file(os.path.join(ROOT_DIR, filename), pattern, replacement) | ||
|
||
|
||
def update_tests(version): | ||
pattern = re.compile(r'expected_version = "\d.\d.\d"') | ||
replacement = 'expected_version = "%s"' % version | ||
_update_file(os.path.join( | ||
ROOT_DIR, "tests/test_wheel.py"), pattern, replacement) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description=__doc__) | ||
parser.add_argument( | ||
'cmake_version', metavar='CMAKE_VERSION', type=str, | ||
help='CMake version of the form X.Y.Z' | ||
) | ||
args = parser.parse_args() | ||
update_cmake_urls_script(args.cmake_version) | ||
update_docs(args.cmake_version) | ||
update_tests(args.cmake_version) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters