Touch up Python build instructions. (#11424)
* Our `PYTHONPATH` docs had some references to old paths
(`compiler-api\python_package`) still in there. Windows instructions now
use `.env.bat`, matching the `source .env && export PYTHONPATH`
instructions on Linux.
* Added Python 3.10 to the classifiers that will appear on
https://pypi.org/project/iree-compiler/
* The `iree_benchmark_module` script was missing from one build target -
this was working in some configurations but not all
* Removed a duplicate instruction to install from
`build_requirements.txt` (it was a "prerequisite" and an explicit step)
* Added a recommendation to consider using `py` on Windows instead of
`python`
(https://docs.python.org/3/using/windows.html#python-launcher-for-windows)
diff --git a/.gitignore b/.gitignore
index 977d265..0409f07 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,10 +1,10 @@
# Python
+.env
*.pyc
**/.ipynb_checkpoints/
.pytype/
# Visual Studio files
-.env
.vs/
.vscode/
*.sdf
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 566872e..4ecf827 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -850,14 +850,13 @@
if(IREE_BUILD_PYTHON_BINDINGS)
# Write out a .env file to make IDEs and developers happy.
# Yes, we are writing this to the source dir. It is only for IDEs and if
- # it gets clobbered, it is fine.
+ # it gets clobbered, it is fine (it is also ignored in .gitignore).
set(_PYTHONPATH_ENV "PYTHONPATH=$<SHELL_PATH:${CMAKE_CURRENT_BINARY_DIR}/compiler/bindings/python;${CMAKE_CURRENT_BINARY_DIR}/runtime/bindings/python>\n")
- file(GENERATE OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/.env"
- CONTENT "${_PYTHONPATH_ENV}"
- )
- file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/.env"
- CONTENT "${_PYTHONPATH_ENV}"
- )
+ file(GENERATE OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/.env" CONTENT "${_PYTHONPATH_ENV}")
+ file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/.env" CONTENT "${_PYTHONPATH_ENV}")
+ # Similarly, write out .env.bat for Windows.
+ set(_PYTHONPATH_ENV_BAT "set PYTHONPATH=$<SHELL_PATH:${CMAKE_CURRENT_BINARY_DIR}/compiler/bindings/python;${CMAKE_CURRENT_BINARY_DIR}/runtime/bindings/python>\n")
+ file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/.env.bat" CONTENT "${_PYTHONPATH_ENV_BAT}")
endif()
if(IREE_BUILD_BINDINGS_TFLITE)
diff --git a/compiler/setup.py b/compiler/setup.py
index 9866c57..e60b803 100644
--- a/compiler/setup.py
+++ b/compiler/setup.py
@@ -234,6 +234,7 @@
"-DPython3_EXECUTABLE={}".format(sys.executable),
"-DCMAKE_BUILD_TYPE={}".format(cfg),
get_env_cmake_option("IREE_TARGET_BACKEND_CUDA"),
+ # TODO(scotttodd): include IREE_TARGET_BACKEND_WEBGPU here (and in env)
get_env_cmake_option("IREE_ENABLE_CPUINFO", "ON"),
]
@@ -383,9 +384,11 @@
classifiers=[
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
+ "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
],
ext_modules=[
CMakeExtension("iree.compiler._mlir_libs._mlir"),
diff --git a/docs/website/docs/building-from-source/python-bindings-and-importers.md b/docs/website/docs/building-from-source/python-bindings-and-importers.md
index c48d374..d2c3367 100644
--- a/docs/website/docs/building-from-source/python-bindings-and-importers.md
+++ b/docs/website/docs/building-from-source/python-bindings-and-importers.md
@@ -27,8 +27,6 @@
* A relatively recent Python3 installation >=3.7 (we aim to support
[non-eol Python versions](https://endoflife.date/python)).
-* Installation of python dependencies as specified in
- [`runtime/bindings/python/iree/runtime/build_requirements.txt`](https://github.com/iree-org/iree/blob/main/runtime/bindings/python/iree/runtime/build_requirements.txt).
**CMake Variables:**
@@ -79,6 +77,13 @@
=== "Windows"
``` powershell
+ # Make sure your 'python' is what you expect.
+ # Also consider using the Python launcher 'py' instead of 'python':
+ # https://docs.python.org/3/using/windows.html#python-launcher-for-windows
+ which python
+ python --version
+ py --list-paths
+
# Create a persistent virtual environment (first time only).
python -m venv .venv
@@ -112,8 +117,7 @@
.
cmake --build .
- # Add ./bindings/python and compiler-api/python_package to PYTHONPATH and
- # use the API.
+ # Add the bindings/python paths to PYTHONPATH and use the API.
source .env && export PYTHONPATH
python -c "import iree.compiler"
python -c "import iree.runtime"
@@ -125,9 +129,8 @@
cmake -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DIREE_BUILD_PYTHON_BINDINGS=ON .
cmake --build .
- # Add bindings\python and compiler-api\python_package to PYTHONPATH and use
- # the API.
- set PYTHONPATH="$pwd\compiler-api\python_package;$pwd\bindings\python;%PYTHONPATH%"
+ # Add the bindings/python paths to PYTHONPATH and use the API.
+ .env.bat
python -c "import iree.compiler"
python -c "import iree.runtime"
```
diff --git a/integrations/tensorflow/python_projects/iree_tf/setup.py b/integrations/tensorflow/python_projects/iree_tf/setup.py
index 3a33691..103bf0d 100644
--- a/integrations/tensorflow/python_projects/iree_tf/setup.py
+++ b/integrations/tensorflow/python_projects/iree_tf/setup.py
@@ -94,6 +94,10 @@
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
],
python_requires=">=3.7",
packages=find_namespace_packages(include=[
diff --git a/integrations/tensorflow/python_projects/iree_tflite/setup.py b/integrations/tensorflow/python_projects/iree_tflite/setup.py
index 3173ad7..19d0f14 100644
--- a/integrations/tensorflow/python_projects/iree_tflite/setup.py
+++ b/integrations/tensorflow/python_projects/iree_tflite/setup.py
@@ -94,6 +94,10 @@
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
],
python_requires=">=3.7",
packages=find_namespace_packages(include=[
diff --git a/integrations/tensorflow/python_projects/iree_xla/setup.py b/integrations/tensorflow/python_projects/iree_xla/setup.py
index 22a1a8d..61e1892 100644
--- a/integrations/tensorflow/python_projects/iree_xla/setup.py
+++ b/integrations/tensorflow/python_projects/iree_xla/setup.py
@@ -94,6 +94,10 @@
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
],
python_requires=">=3.7",
packages=find_namespace_packages(include=[
diff --git a/runtime/bindings/python/CMakeLists.txt b/runtime/bindings/python/CMakeLists.txt
index 09806b6..24034af 100644
--- a/runtime/bindings/python/CMakeLists.txt
+++ b/runtime/bindings/python/CMakeLists.txt
@@ -71,6 +71,7 @@
"iree/runtime/system_setup.py"
"iree/runtime/tracing.py"
"iree/runtime/scripts/iree_benchmark_trace/__main__.py"
+ "iree/runtime/scripts/iree_benchmark_module/__main__.py"
"iree/runtime/scripts/iree_run_trace/__main__.py"
"iree/runtime/scripts/iree_run_module/__main__.py"
${_PYTHON_EXTRA_SRCS}
diff --git a/runtime/setup.py b/runtime/setup.py
index 7d1879f..8232661 100644
--- a/runtime/setup.py
+++ b/runtime/setup.py
@@ -372,9 +372,11 @@
classifiers=[
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: Apache Software License",
+ "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.10",
],
url="https://github.com/iree-org/iree",
python_requires=">=3.7",