Skip to content

Commit 3e78241

Browse files
committed
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
2 parents 8062ead + 5659554 commit 3e78241

File tree

9 files changed

+256
-37
lines changed

9 files changed

+256
-37
lines changed

CMakeLists.txt

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,7 @@ if(CMakePythonDistributions_SUPERBUILD)
3232
message(STATUS "Build CMake from source: ${BUILD_CMAKE_FROM_SOURCE}")
3333
message(STATUS "***************************************************")
3434

35-
#-----------------------------------------------------------------------------
36-
# CMake sources
37-
set(unix_source_url "https://cmake.org/files/v3.7/cmake-3.7.0.tar.gz")
38-
set(unix_source_sha256 "ed63e05c41aeb6c036e503114ab15847f29c312f9f21f5f1a7060a4b4ec2fb31")
39-
40-
set(windows_source_url "https://cmake.org/files/v3.7/cmake-3.7.0.zip")
41-
set(windows_source_sha256 "e147c8f95b31b8cb0ef903b39ac21c9f07faf1c2131f7ec54a55e664d70224e7")
42-
43-
#-----------------------------------------------------------------------------
44-
# CMake binaries
45-
46-
set(linux32_binary_url "NA") # Linux 32-bit binaries not available
47-
set(linux32_binary_sha256 "NA")
48-
49-
set(linux64_binary_url "https://cmake.org/files/v3.7/cmake-3.7.0-Linux-x86_64.tar.gz")
50-
set(linux64_binary_sha256 "e075f63e6a9104b1c3d11666ae9546bc8812f7e791a49c4ce11effc063141b2a")
51-
52-
set(macosx_binary_url "https://cmake.org/files/v3.7/cmake-3.7.0-Darwin-x86_64.tar.gz")
53-
set(macosx_binary_sha256 "38ea6955fb8c120eada1ff7985389b61ad5ca60a90a51025024638d92bfb43cf")
54-
55-
set(win32_binary_url "https://cmake.org/files/v3.7/cmake-3.7.0-win32-x86.zip")
56-
set(win32_binary_sha256 "26dc1e0c4e9ba6021ed171463f7c99b241c1c8f8ada4ea652f031ff835c6b928")
57-
58-
set(win64_binary_url "https://cmake.org/files/v3.7/cmake-3.7.0-win64-x64.zip")
59-
set(win64_binary_sha256 "11a2f8c4d52c5dbb6708a80f54d782fdfb2f5cd96c091ac51500c5607534e660")
35+
include(${CMAKE_CURRENT_SOURCE_DIR}/CMakeUrls.cmake)
6036

6137
#-----------------------------------------------------------------------------
6238
# Which archives ?

CMakeUrls.cmake

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
#-----------------------------------------------------------------------------
3+
# CMake sources
4+
set(unix_source_url "https://cmake.org/files/v3.7/cmake-3.7.1.tar.gz")
5+
set(unix_source_sha256 "449a5bce64dbd4d5b9517ebd1a1248ed197add6ad27934478976fd5f1f9330e1")
6+
7+
set(windows_source_url "https://cmake.org/files/v3.7/cmake-3.7.1.zip")
8+
set(windows_source_sha256 "17f34341cc63a892679085f2cad3e3d1f172e0518ee7dde43716175033494dfa")
9+
10+
#-----------------------------------------------------------------------------
11+
# CMake binaries
12+
13+
set(linux32_binary_url "NA") # Linux 32-bit binaries not available
14+
set(linux32_binary_sha256 "NA")
15+
16+
set(linux64_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-Linux-x86_64.tar.gz")
17+
set(linux64_binary_sha256 "7b4b7a1d9f314f45722899c0521c261e4bfab4a6b532609e37fef391da6bade2")
18+
19+
set(macosx_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-Darwin-x86_64.tar.gz")
20+
set(macosx_binary_sha256 "1851d1448964893fdc5a8c05863326119f397a3790e0c84c40b83499c7960267")
21+
22+
set(win32_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-win32-x86.zip")
23+
set(win32_binary_sha256 "d2ec53ba3e3a12f734ed7127704ff9a83361e7cc6f9a0f0b3e2b56d9868a76b9")
24+
25+
set(win64_binary_url "https://cmake.org/files/v3.7/cmake-3.7.1-win64-x64.zip")
26+
set(win64_binary_sha256 "659ecb8207e1266786188c7eaf45308458ba5f719c985970f6f55ec0b5a96746")

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The suite of CMake tools were created by Kitware in response to the need
2020
for a powerful, cross-platform build environment for open-source projects
2121
such as ITK and VTK.
2222

23-
The CMake python wheels provide `CMake 3.7.0 <https://cmake.org/cmake/help/v3.7/index.html>`_.
23+
The CMake python wheels provide `CMake 3.7.1 <https://cmake.org/cmake/help/v3.7/index.html>`_.
2424

2525
This project is maintained by Jean-Christophe Fillion-Robin from Kitware Inc.
2626
It is covered by the `Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>`_.

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The suite of CMake tools were created by Kitware in response to the need
1515
for a powerful, cross-platform build environment for open-source projects
1616
such as ITK and VTK.
1717

18-
The CMake python wheels provide `CMake 3.7.0 <https://cmake.org/cmake/help/v3.6/index.html>`_.
18+
The CMake python wheels provide `CMake 3.7.1 <https://cmake.org/cmake/help/v3.7/index.html>`_.
1919

2020
.. toctree::
2121
:maxdepth: 2
@@ -32,6 +32,7 @@ The CMake python wheels provide `CMake 3.7.0 <https://cmake.org/cmake/help/v3.6/
3232
:maxdepth: 2
3333
:caption: For maintainers
3434

35+
update_cmake_version
3536
make_a_release
3637

3738

docs/update_cmake_version.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
====================
2+
Update CMake version
3+
====================
4+
5+
A developer should use the following steps to update the version ``X.Y.Z``
6+
of CMake associated with the current CMake python distributions.
7+
8+
Available CMake archives can be found at https://cmake.org/files.
9+
10+
11+
1. Install `requests` and `beautifulsoup4`::
12+
13+
$ pip install requests beautifulsoup4
14+
15+
2. Execute `scripts/update_cmake_version.py` command line tool with the desired
16+
``X.Y.Z`` CMake version available for download. For example::
17+
18+
$ python scripts/update_cmake_version.py 3.7.1
19+
Collecting URLs and SHA256s from 'https://cmake.org/files/v3.7'
20+
Collecting URLs and SHA256s from 'https://cmake.org/files/v3.7' - done
21+
Updating 'CMakeUrls.cmake' with CMake version 3.7.1
22+
Updating 'CMakeUrls.cmake' with CMake version 3.7.1 - done
23+
Updating docs/index.rst
24+
Updating docs/index.rst - done
25+
Updating README.rst
26+
Updating README.rst - done
27+
Updating tests/test_wheel.py
28+
Updating tests/test_wheel.py - done
29+
30+
3. Create a topic named `update-to-cmake-X.Y.Z` and commit the changes
31+
32+
4. Create a `Pull Request`.
33+
34+
5. If all CI tests are passing, merge the topic and consider :doc:`making a new
35+
release </make_a_release>`.

requirements-dev.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
codecov==2.0.5
2-
coverage==4.2
3-
flake8==3.0.4
4-
pytest==3.0.3
5-
pytest-cov==2.4.0
6-
pytest-runner==2.9
7-
pytest-virtualenv==1.2.4
8-
scikit-build==0.4.0
9-
virtualenv==15.0.3
1+
codecov>=2.0.5
2+
coverage>=4.2
3+
flake8>=3.0.4
4+
pytest>=3.0.3
5+
pytest-cov>=2.4.0
6+
pytest-runner>=2.9
7+
pytest-virtualenv>=1.2.5
8+
scikit-build>=0.5.0
9+
virtualenv>=15.0.3

scripts/update_cmake_version.py

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
"""Command line executable allowing to update CMakeUrls.cmake
2+
given a CMake version.
3+
"""
4+
5+
import argparse
6+
import contextlib
7+
import os
8+
import re
9+
import textwrap
10+
11+
try:
12+
import requests
13+
except ImportError:
14+
raise SystemExit(
15+
"requests not available: "
16+
"consider installing it running 'pip install requests'"
17+
)
18+
19+
try:
20+
from bs4 import BeautifulSoup
21+
except ImportError:
22+
raise SystemExit(
23+
"BeautifulSoup not available: "
24+
"consider installing it running 'pip install beautifulsoup4'"
25+
)
26+
27+
ROOT_DIR = os.path.join(os.path.dirname(__file__), "..")
28+
29+
30+
@contextlib.contextmanager
31+
def _log(txt, verbose=True):
32+
if verbose:
33+
print(txt)
34+
yield
35+
if verbose:
36+
print("%s - done" % txt)
37+
38+
39+
def _major_minor(version):
40+
"""Given a string of the form ``X.Y.Z``, returns ``X.Y``."""
41+
return ".".join(version.split(".")[:2])
42+
43+
44+
def get_cmake_archive_urls_and_sha256s(version):
45+
files_base_url = "https://cmake.org/files/v%s" % _major_minor(version)
46+
47+
with _log("Collecting URLs and SHA256s from '%s'" % files_base_url):
48+
49+
soup = BeautifulSoup(requests.get(files_base_url).text, 'html.parser')
50+
51+
sha_256_file = "cmake-%s-SHA-256.txt" % version
52+
53+
expected = {
54+
"cmake-%s.tar.gz" % version: "unix_source",
55+
"cmake-%s.zip" % version: "win_source",
56+
"cmake-%s-Linux-x86_64.tar.gz" % version: "linux64_binary",
57+
"cmake-%s-Darwin-x86_64.tar.gz" % version: "macosx_binary",
58+
"cmake-%s-win32-x86.zip" % version: "win32_binary",
59+
"cmake-%s-win64-x64.zip" % version: "win64_binary",
60+
}
61+
62+
# Check that (1) "a" text matches "href" value and (2) that all expected
63+
# files are listed on the page.
64+
found = 0
65+
for a in soup.find_all('a'):
66+
if a.text in expected or a.text == sha_256_file:
67+
found += 1
68+
assert a.text == a.get("href")
69+
assert len(expected) + 1 == found
70+
71+
# Get SHA256s and URLs
72+
urls = {}
73+
sha_256_url = files_base_url + "/" + sha_256_file
74+
for line in requests.get(sha_256_url).text.splitlines():
75+
file = line.split()[1].strip()
76+
if file in expected:
77+
sha256 = line.split()[0].strip()
78+
identifier = expected[file]
79+
urls[identifier] = (files_base_url + "/" + file, sha256)
80+
assert len(urls) == len(expected)
81+
82+
return urls
83+
84+
85+
def generate_cmake_variables(urls_and_sha256s):
86+
template_inputs = {}
87+
88+
# Get SHA256s and URLs
89+
for var_prefix, urls_and_sha256s in urls_and_sha256s.items():
90+
template_inputs["%s_url" % var_prefix] = urls_and_sha256s[0]
91+
template_inputs["%s_sha256" % var_prefix] = urls_and_sha256s[1]
92+
93+
cmake_variables = textwrap.dedent("""
94+
#-----------------------------------------------------------------------------
95+
# CMake sources
96+
set(unix_source_url "{unix_source_url}")
97+
set(unix_source_sha256 "{unix_source_sha256}")
98+
99+
set(windows_source_url "{win_source_url}")
100+
set(windows_source_sha256 "{win_source_sha256}")
101+
102+
#-----------------------------------------------------------------------------
103+
# CMake binaries
104+
105+
set(linux32_binary_url "NA") # Linux 32-bit binaries not available
106+
set(linux32_binary_sha256 "NA")
107+
108+
set(linux64_binary_url "{linux64_binary_url}")
109+
set(linux64_binary_sha256 "{linux64_binary_sha256}")
110+
111+
set(macosx_binary_url "{macosx_binary_url}")
112+
set(macosx_binary_sha256 "{macosx_binary_sha256}")
113+
114+
set(win32_binary_url "{win32_binary_url}")
115+
set(win32_binary_sha256 "{win32_binary_sha256}")
116+
117+
set(win64_binary_url "{win64_binary_url}")
118+
set(win64_binary_sha256 "{win64_binary_sha256}")
119+
""").format(**template_inputs)
120+
121+
return cmake_variables
122+
123+
124+
def update_cmake_urls_script(version):
125+
content = generate_cmake_variables(
126+
get_cmake_archive_urls_and_sha256s(version))
127+
cmake_urls_filename = "CMakeUrls.cmake"
128+
cmake_urls_filepath = os.path.join(ROOT_DIR, cmake_urls_filename)
129+
130+
msg = "Updating '%s' with CMake version %s" % (cmake_urls_filename, version)
131+
with _log(msg), open(cmake_urls_filepath, "w") as cmake_file:
132+
cmake_file.write(content)
133+
134+
135+
def _update_file(filepath, regex, replacement):
136+
msg = "Updating %s" % os.path.relpath(filepath, ROOT_DIR)
137+
with _log(msg):
138+
pattern = re.compile(regex)
139+
with open(filepath, 'r') as doc_file:
140+
lines = doc_file.readlines()
141+
updated_content = []
142+
for line in lines:
143+
updated_content.append(
144+
re.sub(pattern, replacement, line))
145+
with open(filepath, "w") as doc_file:
146+
doc_file.writelines(updated_content)
147+
148+
149+
def update_docs(version):
150+
pattern = re.compile(
151+
r"CMake \d.\d.\d <https://cmake.org/cmake/help/v\d.\d/index.html>")
152+
replacement = (
153+
"CMake %s <https://cmake.org/cmake/help/v%s/index.html>" % (
154+
version, _major_minor(version)))
155+
for filename in ["docs/index.rst", "README.rst"]:
156+
_update_file(os.path.join(ROOT_DIR, filename), pattern, replacement)
157+
158+
159+
def update_tests(version):
160+
pattern = re.compile(r'expected_version = "\d.\d.\d"')
161+
replacement = 'expected_version = "%s"' % version
162+
_update_file(os.path.join(
163+
ROOT_DIR, "tests/test_wheel.py"), pattern, replacement)
164+
165+
166+
def main():
167+
parser = argparse.ArgumentParser(description=__doc__)
168+
parser.add_argument(
169+
'cmake_version', metavar='CMAKE_VERSION', type=str,
170+
help='CMake version of the form X.Y.Z'
171+
)
172+
args = parser.parse_args()
173+
update_cmake_urls_script(args.cmake_version)
174+
update_docs(args.cmake_version)
175+
update_tests(args.cmake_version)
176+
177+
178+
if __name__ == "__main__":
179+
main()

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
def _parse_requirements(filename):
1818
return [str(ir.req) for ir in parse_requirements(filename, session=False)]
1919

20+
2021
requirements = []
2122
dev_requirements = _parse_requirements('requirements-dev.txt')
2223

@@ -39,6 +40,7 @@ def _parse_requirements(filename):
3940
packages=['cmake'],
4041

4142
cmake_install_dir='cmake/data',
43+
cmake_with_sdist=True,
4244

4345
entry_points={
4446
'console_scripts': [

tests/test_wheel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_command_line(virtualenv, tmpdir):
1313

1414
virtualenv.run("pip install %s" % wheels[0])
1515

16-
expected_version = "3.7.0"
16+
expected_version = "3.7.1"
1717

1818
for executable_name in ["cmake", "cpack", "ctest"]:
1919
output = virtualenv.run(

0 commit comments

Comments
 (0)