diff --git a/.gitignore b/.gitignore index b0a8cbc79502..2e0b7c6de3a1 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ build-*/ # Local-only config options configured.bazelrc user.bazelrc +version_info.json # Dear ImGui Ini files imgui.ini diff --git a/CMakeLists.txt b/CMakeLists.txt index 040f8630c83d..f3e65d41bc76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,11 @@ set(IREE_HAL_DRIVERS_TO_BUILD "all" set(IREE_TARGET_BACKENDS_TO_BUILD "all" CACHE STRING "Semicolon-separated list of target backends to build, or \"all\".") +# Properties controlling version and naming of release artifacts. +set(IREE_RELEASE_PACKAGE_SUFFIX "-dev" CACHE STRING "Suffix to append to distributed package names") +set(IREE_RELEASE_VERSION "0.1a1" CACHE STRING "Version to embed in distributed packages") +set(IREE_RELEASE_REVISION "HEAD" CACHE STRING "Version control revision information to embed in distributed packages") + # Master enable for tensorflow build support. # Note that this is a normal CMake variable used to gate build features (not # a cache variable that is user-settable). diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 20e193c19202..b27f1ada28b8 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -18,8 +18,6 @@ set(PYBIND_COPTS "-fexceptions") set(PYBIND_EXTENSION_COPTS "-fvisibility=hidden") # Generated setup scripts. -# TODO: Make the version configurable. -set(IREE_PYTHON_VERSION "0.1a1") configure_file(setup.py setup.py COPYONLY) configure_file(setup_tools_tf.py.in setup_tools_tf.py) diff --git a/bindings/python/pyiree/compiler2/CMakeLists.txt b/bindings/python/pyiree/compiler2/CMakeLists.txt index 05a064b093ca..e48400f44114 100644 --- a/bindings/python/pyiree/compiler2/CMakeLists.txt +++ b/bindings/python/pyiree/compiler2/CMakeLists.txt @@ -26,17 +26,26 @@ iree_py_library( # Installation. configure_file(setup.py.in setup.py) +configure_file(version.py.in version.py) set(_install_component IreePythonCompiler) set(_install_package_dir "${CMAKE_INSTALL_PREFIX}/python_packages/iree_compiler") set(_install_destination "${_install_package_dir}/pyiree/compiler2") install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.py + FILES + ${CMAKE_CURRENT_BINARY_DIR}/setup.py COMPONENT ${_install_component} DESTINATION "${_install_package_dir}" ) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/version.py + COMPONENT ${_install_component} + DESTINATION "${_install_destination}" +) + install( DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ COMPONENT ${_install_component} diff --git a/bindings/python/pyiree/compiler2/setup.py.in b/bindings/python/pyiree/compiler2/setup.py.in index 5c7c8149f444..25262f158d84 100644 --- a/bindings/python/pyiree/compiler2/setup.py.in +++ b/bindings/python/pyiree/compiler2/setup.py.in @@ -95,8 +95,8 @@ except ImportError: bdist_wheel = None setup( - name="iree-compiler@IREE_PYTHON_PACKAGE_SUFFIX@", - version="@IREE_PYTHON_VERSION@", + name="iree-compiler@IREE_RELEASE_PACKAGE_SUFFIX@", + version="@IREE_RELEASE_VERSION@", author="The IREE Team", author_email="iree-discuss@googlegroups.com", license="Apache", diff --git a/bindings/python/pyiree/compiler2/version.py.in b/bindings/python/pyiree/compiler2/version.py.in new file mode 100644 index 000000000000..e932b2fa962b --- /dev/null +++ b/bindings/python/pyiree/compiler2/version.py.in @@ -0,0 +1,17 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +PACKAGE_SUFFIX = "@IREE_RELEASE_PACKAGE_SUFFIX@" +VERSION = "@IREE_RELEASE_VERSION@" +REVISION = "@IREE_RELEASE_REVISION@" diff --git a/bindings/python/pyiree/rt/CMakeLists.txt b/bindings/python/pyiree/rt/CMakeLists.txt index a18c907c5849..af3135f881a0 100644 --- a/bindings/python/pyiree/rt/CMakeLists.txt +++ b/bindings/python/pyiree/rt/CMakeLists.txt @@ -93,17 +93,26 @@ iree_py_test( # Installation. configure_file(setup.py.in setup.py) +configure_file(version.py.in version.py) set(_install_component IreePythonRt) set(_install_package_dir "${CMAKE_INSTALL_PREFIX}/python_packages/iree_rt") set(_install_destination "${_install_package_dir}/pyiree/rt") install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.py + FILES + ${CMAKE_CURRENT_BINARY_DIR}/setup.py COMPONENT ${_install_component} DESTINATION "${_install_package_dir}" ) +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/version.py + COMPONENT ${_install_component} + DESTINATION "${_install_destination}" +) + install( TARGETS bindings_python_pyiree_rt_PyExtRt COMPONENT ${_install_component} diff --git a/bindings/python/pyiree/rt/setup.py.in b/bindings/python/pyiree/rt/setup.py.in index f61380f4c9bd..b0b9cf43c147 100644 --- a/bindings/python/pyiree/rt/setup.py.in +++ b/bindings/python/pyiree/rt/setup.py.in @@ -27,8 +27,8 @@ with the hardware-abstraction-layer. """ setup( - name="iree-runtime@IREE_PYTHON_PACKAGE_SUFFIX@", - version="@IREE_PYTHON_VERSION@", + name="iree-runtime@IREE_RELEASE_PACKAGE_SUFFIX@", + version="@IREE_RELEASE_VERSION@", author="The IREE Team", author_email="iree-discuss@googlegroups.com", license="Apache", diff --git a/bindings/python/pyiree/rt/version.py.in b/bindings/python/pyiree/rt/version.py.in new file mode 100644 index 000000000000..e932b2fa962b --- /dev/null +++ b/bindings/python/pyiree/rt/version.py.in @@ -0,0 +1,17 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +PACKAGE_SUFFIX = "@IREE_RELEASE_PACKAGE_SUFFIX@" +VERSION = "@IREE_RELEASE_VERSION@" +REVISION = "@IREE_RELEASE_REVISION@" diff --git a/build_tools/cmake/cmake_ci.py b/build_tools/cmake/cmake_ci.py index e98743bd7e97..10f18e365ea2 100644 --- a/build_tools/cmake/cmake_ci.py +++ b/build_tools/cmake/cmake_ci.py @@ -103,6 +103,7 @@ def use_tool_path(toolname, varname=None): cmake_command_prefix = [use_cmake] cmake_environ = os.environ + def cmake_commandline(args): return cmake_command_prefix + args @@ -133,13 +134,14 @@ def compute_vcvars_environ(): vcvars_all = os.path.join(vs_install_path, 'VC', 'Auxiliary', 'Build', 'vcvarsall.bat') vcvars_arch = get_setting('VCVARS_ARCH', 'x64') - with tempfile.NamedTemporaryFile(mode='wt', delete=False, suffix='.cmd') as f: + with tempfile.NamedTemporaryFile(mode='wt', delete=False, + suffix='.cmd') as f: f.write('@echo off\n') f.write(f'call "{vcvars_all}" {vcvars_arch} > NUL\n') f.write('set\n') try: - env_vars = subprocess.check_output( - ["cmd", "/c", f.name]).decode('utf-8').splitlines() + env_vars = subprocess.check_output(["cmd", "/c", + f.name]).decode('utf-8').splitlines() finally: os.unlink(f.name) @@ -149,7 +151,7 @@ def compute_vcvars_environ(): cmake_environ[name] = value if 'VCINSTALLDIR' not in cmake_environ: report('vcvars environment did not include VCINSTALLDIR:\n', - cmake_environ) + cmake_environ) return cmake_environ cmake_environ = compute_vcvars_environ() @@ -196,6 +198,9 @@ def load_version_info(): f'-S{repo_root}', f'-DPython3_EXECUTABLE:FILEPATH={sys.executable}', f'-DPython3_INCLUDE_DIR:PATH={sysconfig.get_path("include")}', + f'-DIREE_RELEASE_PACKAGE_SUFFIX:STRING={version_info.get("package-suffix") or "-dev"}', + f'-DIREE_RELEASE_VERSION:STRING={version_info.get("package-version") or "0.0.1a1"}', + f'-DIREE_RELEASE_REVISION:STRING={version_info.get("iree-revision") or "HEAD"}', ] ### HACK: Add a Python3_LIBRARY because cmake needs it, but it legitimately