StanfordLegion / legion

The Legion Parallel Programming System
https://legion.stanford.edu
Apache License 2.0
678 stars 145 forks source link

CMake: Python installation fails on Sapling #1622

Closed elliottslaughter closed 8 months ago

elliottslaughter commented 9 months ago

Of a related flavor to #1621, but on Sapling (Ubuntu 20.04), I find that I am unable to install Python with CMake:

'/usr/bin/python3.8' '-m' 'pip' 'install' '--global-option=--cmake-build-dir' '--global-option=/scratch/eslaught/legion-ci-python3-cmake/build/runtime' '--global-option=--prefix' '--global-option=/scratch/eslaught/legion-ci-python3-cmake/install' '--ignore-installed' '.'
Processing /scratch/eslaught/legion-ci-python3-cmake/bindings/python
Skipping wheel build for legion, due to binaries being disabled for it.
Installing collected packages: legion
    Running setup.py install for legion: started
    Running setup.py install for legion: finished with status 'error'
/usr/lib/python3/dist-packages/pip/_internal/commands/install.py:255: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option.
  cmdoptions.check_install_build_global(options)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-n58q2_80/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-n58q2_80/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"'
, '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --cmake-build-dir /scratch/eslaught/legion-ci-python3-cmake/build/runtime --prefix /scratch/eslaught/legion-ci-python3-cmake/install install --record /tmp/pip-record-sdybsnu5/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/eslaught/.local/include/python3.8/legion
         cwd: /tmp/pip-req-build-n58q2_80/
    Complete output (36 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-n58q2_80/setup.py", line 36, in <module>
        setup(name='legion',
      File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/lib/python3/dist-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python3.8/distutils/command/install.py", line 589, in run
        self.run_command('build')
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/usr/lib/python3.8/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-req-build-n58q2_80/setup.py", line 31, in run
        legion_cffi_build.build_cffi(None, args.cmake_build_dir, self.build_lib, ['legion.h'], ['runtime'], 'legion_builtin_cffi.py')
      File "/tmp/pip-req-build-n58q2_80/legion_cffi_build.py", line 46, in build_cffi
        prefix_dir, h_path = find_header(header_file, search_dir)
      File "/tmp/pip-req-build-n58q2_80/legion_cffi_build.py", line 39, in find_header
        raise Exception('Unable to locate header file:' + filename + " in:" + runtime_dir)
    Exception: Unable to locate header file:legion.h in:/runtime
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-n58q2_80/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-n58q2_80/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' --cmake-build-dir /scratch/eslaught/legion-ci-python3-cmake/build/runtime --prefix /scratch/eslaught/legion-ci-python3-cmake/install install --record /tmp/pip-record-sdybsnu5/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/eslaught/.local/include/python3.8/legion Check the logs for full command output.

At the moment, CMake does not even catch the error (!!) and thus we sail right past without realizing we have not installed Python, leaving the installation empty of actual Python files.

It appears that CMake 3.19 supports a new COMMAND_ERROR_IS_FATAL attribute which will at least catch the error, but it's surprising that we apparently have a completely broken Python installation.

Ubuntu 20.04, Python 3.8. No Conda, no Homebrew, just default system packages.

rohany commented 8 months ago

I'm also seeing this while trying to build legate on the latest control replication

elliottslaughter commented 8 months ago

This should have been fixed by https://gitlab.com/StanfordLegion/legion/-/merge_requests/1072, which has been merged to master.

We're having CI issues (P100 is down and legion-nvidia-01's GPU is misbehaving) so I think it may not have merged downstream yet, but you can try a local merge to get around this.

lightsighter commented 8 months ago

I already upstreamed this to the latest control replication.

elliottslaughter commented 8 months ago

@rohany Can you confirm if that fixes it, and if not, what commit are you on and what does the output look like?

rohany commented 8 months ago

I am on a branch off of the latest control replication (based on refctxindex) and it does not fix it.

Here's the output (from building Legate):

    '/usr/local/Cellar/cmake/3.28.1/bin/cmake' '-E' 'env' 'CMAKE_SOURCE_DIR=/Users/rohany/Documents/nvidia/legate.core' 'CMAKE_BUILD_DIR=/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-build/_deps/legion-build/runtime' 'CMAKE_INSTALL_PREFIX=/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-install' '/usr/local/anaconda3/envs/fusion/bin/python3' '-m' 'pip' 'install' '--prefix' '/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-install' '--ignore-installed' '--root' '/' '--prefix' '/usr/local/anaconda3/envs/fusion' '.'
    Processing /Users/rohany/Documents/nvidia/legate.core/legion/bindings/python
      Preparing metadata (setup.py): started
      Preparing metadata (setup.py): finished with status 'done'
    Building wheels for collected packages: legion
      Building wheel for legion (setup.py): started
      Building wheel for legion (setup.py): finished with status 'error'
      error: subprocess-exited-with-error

      × python setup.py bdist_wheel did not run successfully.
      │ exit code: 1
      ╰─> [40 lines of output]
          Traceback (most recent call last):
            File "<string>", line 2, in <module>
            File "<pip-setuptools-caller>", line 34, in <module>
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/setup.py", line 43, in <module>
              setup(name='legion',
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
              return run_commands(dist)
                     ^^^^^^^^^^^^^^^^^^
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
              dist.run_commands()
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
              self.run_command(cmd)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/dist.py", line 1244, in run_command
              super().run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 343, in run
              self.run_command("build")
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
              self.distribution.run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/dist.py", line 1244, in run_command
              super().run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 131, in run
              self.run_command(cmd_name)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
              self.distribution.run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/dist.py", line 1244, in run_command
              super().run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/setup.py", line 38, in run
              legion_cffi_build.build_cffi(None, cmake_source_dir, cmake_build_dir, self.build_lib, ['legion.h'], ['runtime'], 'legion_builtin_cffi.py')
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/legion_cffi_build.py", line 45, in build_cffi
              prefix_dir, h_path = find_header(header_file, os.path.join(source_dir, search_dir))
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/legion_cffi_build.py", line 35, in find_header
              raise Exception('Unable to locate header file: ' + filename + ' in: ' + search_dir)
          Exception: Unable to locate header file: legion.h in: /Users/rohany/Documents/nvidia/legate.core/runtime
          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for legion
      Running setup.py clean for legion
    Failed to build legion
    ERROR: Could not build wheels for legion, which is required to install pyproject.toml-based projects
elliottslaughter commented 8 months ago

Does the Legate build suck the entire Legion CMake into the same project as Legate itself? I can try to work around that, but I'm pretty sure I told the Legate team not to do that. The issues with this approach can get really ugly and I won't support fixes (beyond trivial ones) when things go sideways.

rohany commented 8 months ago

cc @manopapad do you know who has the answer to this question?

lightsighter commented 8 months ago

Does the Legate build suck the entire Legion CMake into the same project as Legate itself? I can try to work around that, but I'm pretty sure I told the Legate team not to do that. The issues with this approach can get really ugly and I won't support fixes (beyond trivial ones) when things go sideways.

@trxcllnt to answer this question.

elliottslaughter commented 8 months ago

@rohany Try this diff and see if it fixes the problem:

diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index a3f1648ea..75a7bf290 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -75,8 +75,11 @@ endif()
 # Note: CMake 3.19 required for COMMAND_ERROR_IS_FATAL argument to execute_process()
 cmake_minimum_required(VERSION 3.19)

+cmake_path(GET CMAKE_CURRENT_SOURCE_DIR PARENT_PATH Legion_ROOT_PROJECT_DIR)
+cmake_path(GET Legion_ROOT_PROJECT_DIR PARENT_PATH Legion_ROOT_PROJECT_DIR)
+
 # Use setup.py script to install the Python bindings library
-install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} CMAKE_BUILD_DIR=${Legion_BINARY_DIR}/runtime CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ${Python3_EXECUTABLE} -m pip install --prefix \"\${CMAKE_INSTALL_PREFIX}\" --ignore-installed ${Legion_PYTHON_EXTRA_INSTALL_ARGS} . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)")
+install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${Legion_ROOT_PROJECT_DIR} CMAKE_BUILD_DIR=${Legion_BINARY_DIR}/runtime CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ${Python3_EXECUTABLE} -m pip install --prefix \"\${CMAKE_INSTALL_PREFIX}\" --ignore-installed ${Legion_PYTHON_EXTRA_INSTALL_ARGS} . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)")

 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.py
   DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/python/examples
rohany commented 8 months ago

I see

    [0/1] /usr/local/Cellar/cmake/3.28.1/bin/cmake --regenerate-during-build -S/Users/rohany/Documents/nvidia/legate.core -B/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-build
    -- Found Python3: /usr/local/anaconda3/envs/fusion/bin/python3 (found version "3.11.3") found components: Interpreter Development Development.Module Development.Embed
    -- CPM: adding package Legion@ (/Users/rohany/Documents/nvidia/legate.core/legion)
    -- Found Python3: /usr/local/anaconda3/envs/fusion/bin/python3 (found version "3.11.3") found components: Interpreter
    CMake Error at legion/bindings/python/CMakeLists.txt:78 (cmake_path):
      cmake_path undefined variable for input path.

    CMake Error at legion/bindings/python/CMakeLists.txt:79 (cmake_path):
      cmake_path undefined variable for input path.

    -- Rust Toolchain: stable-x86_64-apple-darwin
    -- Rust Target: x86_64-apple-darwin
    -- Using Corrosion as a subdirectory
    -- CPM: adding package Thrust@1.17.0.0 (1.17.0)
elliottslaughter commented 8 months ago

Sorry, I got the order of arguments wrong. I updated the diff in https://github.com/StanfordLegion/legion/issues/1622#issuecomment-1910877792, can you run again?

rohany commented 8 months ago

It does not work, gives me the same error as the beginning:

      × python setup.py bdist_wheel did not run successfully.
      │ exit code: 1
      ╰─> [40 lines of output]
          Traceback (most recent call last):
            File "<string>", line 2, in <module>
            File "<pip-setuptools-caller>", line 34, in <module>
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/setup.py", line 43, in <module>
              setup(name='legion',
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
              return run_commands(dist)
                     ^^^^^^^^^^^^^^^^^^
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
              dist.run_commands()
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
              self.run_command(cmd)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/dist.py", line 1244, in run_command
              super().run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/wheel/bdist_wheel.py", line 343, in run
              self.run_command("build")
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
              self.distribution.run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/dist.py", line 1244, in run_command
              super().run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/command/build.py", line 131, in run
              self.run_command(cmd_name)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
              self.distribution.run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/dist.py", line 1244, in run_command
              super().run_command(command)
            File "/usr/local/anaconda3/envs/fusion/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
              cmd_obj.run()
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/setup.py", line 38, in run
              legion_cffi_build.build_cffi(None, cmake_source_dir, cmake_build_dir, self.build_lib, ['legion.h'], ['runtime'], 'legion_builtin_cffi.py')
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/legion_cffi_build.py", line 45, in build_cffi
              prefix_dir, h_path = find_header(header_file, os.path.join(source_dir, search_dir))
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            File "/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python/legion_cffi_build.py", line 35, in find_header
              raise Exception('Unable to locate header file: ' + filename + ' in: ' + search_dir)
          Exception: Unable to locate header file: legion.h in: /Users/rohany/Documents/nvidia/legate.core/runtime
          [end of output]

      note: This error originates from a subprocess, and is likely not a problem with pip.
      ERROR: Failed building wheel for legion
      Running setup.py clean for legion
    Failed to build legion
elliottslaughter commented 8 months ago

Can you check your CMakeCaches.txt to see what the value of Legion_BINARY_DIR is?

elliottslaughter commented 8 months ago

Alternatively you could modify bindings/python/CMakeLists.txt to add something like:

message(FATAL_ERROR "variables: CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR} Legion_ROOT_PROJECT_DIR=${Legion_ROOT_PROJECT_DIR} Legion_BINARY_DIR/runtime=${Legion_BINARY_DIR}/runtime CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
rohany commented 8 months ago

Legion_BINARY_DIR:STATIC=/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-build/_deps/legion-build

elliottslaughter commented 8 months ago

Thanks, but I think I need to the output of https://github.com/StanfordLegion/legion/issues/1622#issuecomment-1911091715 (added just before or just after the install(CODE ...) line) to be able to see what's going wrong.

rohany commented 8 months ago
    CMake Error at legion/bindings/python/CMakeLists.txt:78 (message):
      variables:
      CMAKE_CURRENT_SOURCE_DIR=/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python
      Legion_ROOT_PROJECT_DIR=
      Legion_BINARY_DIR/runtime=/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-build/_deps/legion-build/runtime
      CMAKE_INSTALL_PREFIX=/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-install
elliottslaughter commented 8 months ago

Er, and is that after the two cmake_path(GET ...) lines?

I was expecting to see something like Legion_ROOT_PROJECT_DIR=/Users/rohany/Documents/nvidia/legate.core/legion, which based on my local testing seems to be coming out fine.

rohany commented 8 months ago

Sorry, i didn't also include your patch from above. Here's the updated output:

      variables:
      CMAKE_CURRENT_SOURCE_DIR=/Users/rohany/Documents/nvidia/legate.core/legion/bindings/python
      Legion_ROOT_PROJECT_DIR=/Users/rohany/Documents/nvidia/legate.core/legion
      Legion_BINARY_DIR/runtime=/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-build/_deps/legion-build/runtime
      CMAKE_INSTALL_PREFIX=/Users/rohany/Documents/nvidia/legate.core/_skbuild/macosx-13.0-x86_64-3.11/cmake-install
elliottslaughter commented 8 months ago

Thanks. Given these values, I'm not sure how you're getting:

Exception: Unable to locate header file: legion.h in: /Users/rohany/Documents/nvidia/legate.core/runtime

From your comment https://github.com/StanfordLegion/legion/issues/1622#issuecomment-1910997135

Because your most recent printout clearly shows .../legion as the value and that should be what's getting passed in via CMAKE_SOURCE_DIR=${Legion_ROOT_PROJECT_DIR} in the diff https://github.com/StanfordLegion/legion/issues/1622#issuecomment-1910877792.

I suppose the next thing you could try is resetting the diff to https://github.com/StanfordLegion/legion/issues/1622#issuecomment-1910877792 and then modify setup.py as follows:

diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 50fae74cc..bf9420255 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -22,6 +22,8 @@ cmake_source_dir = os.environ.get('CMAKE_SOURCE_DIR')
 cmake_build_dir = os.environ.get('CMAKE_BUILD_DIR')
 cmake_install_prefix = os.environ.get('CMAKE_INSTALL_PREFIX')

+print('setup.py CMAKE_SOURCE_DIR=%s CMAKE_BUILD_DIR=%s CMAKE_INSTALL_PREFIX=%s' % (cmake_source_dir, cmake_build_dir, cmake_install_prefix))
+
 canonical_python_lib = None
 system = platform.system()
 if system == 'Linux' or system == 'FreeBSD':

We'll just keep peeling back layers of the onion until we find out where it goes bad, I guess.

rohany commented 8 months ago

So I don't know what changed, but the build has started to work for me....

Here's the diff applied on my repo:

➜  legion git:(automatic-tracing-ctx-index-refactor) ✗ cat diff.txt                                                                                                                                                                                                         (fusion) 16:35:01
diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index a3f1648ea..28554476a 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -75,8 +75,11 @@ endif()
 # Note: CMake 3.19 required for COMMAND_ERROR_IS_FATAL argument to execute_process()
 cmake_minimum_required(VERSION 3.19)

+cmake_path(GET CMAKE_CURRENT_SOURCE_DIR PARENT_PATH Legion_ROOT_PROJECT_DIR)
+cmake_path(GET Legion_ROOT_PROJECT_DIR PARENT_PATH Legion_ROOT_PROJECT_DIR)
+
 # Use setup.py script to install the Python bindings library
-install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR} CMAKE_BUILD_DIR=${Legion_BINARY_DIR}/runtime CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ${Python3_EXECUTABLE} -m pip install --prefix \"\${CMAKE_INSTALL_PREFIX}\" --ignore-installed ${Legion_PYTHON_EXTRA_INSTALL_ARGS} . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)")
+install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E env CMAKE_SOURCE_DIR=${Legion_ROOT_PROJECT_DIR} CMAKE_BUILD_DIR=${Legion_BINARY_DIR}/runtime CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ${Python3_EXECUTABLE} -m pip install --prefix \"\${CMAKE_INSTALL_PREFIX}\" --ignore-installed ${Legion_PYTHON_EXTRA_INSTALL_ARGS} . WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMAND_ECHO STDOUT COMMAND_ERROR_IS_FATAL ANY)")

 install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/hello.py
   DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/python/examples
diff --git a/bindings/python/setup.py b/bindings/python/setup.py
index 50fae74cc..bf9420255 100644
--- a/bindings/python/setup.py
+++ b/bindings/python/setup.py
@@ -22,6 +22,8 @@ cmake_source_dir = os.environ.get('CMAKE_SOURCE_DIR')
 cmake_build_dir = os.environ.get('CMAKE_BUILD_DIR')
 cmake_install_prefix = os.environ.get('CMAKE_INSTALL_PREFIX')

+print('setup.py CMAKE_SOURCE_DIR=%s CMAKE_BUILD_DIR=%s CMAKE_INSTALL_PREFIX=%s' % (cmake_source_dir, cmake_build_dir, cmake_install_prefix))
+
 canonical_python_lib = None
 system = platform.system()
 if system == 'Linux' or system == 'FreeBSD':
elliottslaughter commented 8 months ago

I posted the patch here: https://gitlab.com/StanfordLegion/legion/-/merge_requests/1087