Skip to content

Commit

Permalink
Plumb package suffix, version, and revision info to release packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
stellaraccident committed Jan 5, 2021
1 parent 995d0b7 commit bb1de96
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ build-*/
# Local-only config options
configured.bazelrc
user.bazelrc
version_info.json

# Dear ImGui Ini files
imgui.ini
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 0 additions & 2 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 10 additions & 1 deletion bindings/python/pyiree/compiler2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/pyiree/compiler2/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions bindings/python/pyiree/compiler2/version.py.in
Original file line number Diff line number Diff line change
@@ -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@"
11 changes: 10 additions & 1 deletion bindings/python/pyiree/rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions bindings/python/pyiree/rt/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions bindings/python/pyiree/rt/version.py.in
Original file line number Diff line number Diff line change
@@ -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@"
13 changes: 9 additions & 4 deletions build_tools/cmake/cmake_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb1de96

Please sign in to comment.