Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import luisa (Python) after build and setup #63

Closed
bsavery opened this issue Jan 20, 2023 · 5 comments
Closed

Cannot import luisa (Python) after build and setup #63

bsavery opened this issue Jan 20, 2023 · 5 comments

Comments

@bsavery
Copy link

bsavery commented Jan 20, 2023

Describe the bug
After following the build guide for Python, I cannot import luisa or run test files.

in build_release/bin I see lcapi.cpython-310-darwin.so but no .so to import luisa. I'm assuming this is a PyBind11 thing that the lcapi .so will allow importing luisa but it doesn't see to work:

import lcapi
dir(lcapi)
['Accel', 'AccelBuildCommand', 'AccelBuildRequest', 'AccelModification', 'AccelUsageHint', 'AccessExpr', 'BinaryExpr', 'BinaryOp', 'BindlessArrayUpdateCommand', 'BufferCopyCommand', 'BufferDownloadCommand', 'BufferToTextureCopyCommand', 'BufferUploadCommand', 'CallExpr', 'CallOp', 'CastExpr', 'CastOp', 'Command', 'Context', 'Device', 'DeviceInterface', 'Expression', 'ForStmt', 'FsPath', 'Function', 'FunctionBuilder', 'IfStmt', 'LiteralExpr', 'LoopStmt', 'MemberExpr', 'MeshBuildCommand', 'PixelFormat', 'PixelStorage', 'RefExpr', 'Sampler', 'ScopeStmt', 'ShaderDispatchCommand', 'Stream', 'TextureCopyCommand', 'TextureDownloadCommand', 'TextureToBufferCopyCommand', 'TextureUploadCommand', 'Type', 'UnaryExpr', 'UnaryOp', 'doc', 'file', 'loader', 'name', 'package', 'spec', '_vectorstorage_bool2', '_vectorstorage_bool3', '_vectorstorage_bool4', '_vectorstorage_float2', '_vectorstorage_float3', '_vectorstorage_float4', '_vectorstorage_int2', '_vectorstorage_int3', '_vectorstorage_int4', '_vectorstorage_uint2', '_vectorstorage_uint3', '_vectorstorage_uint4', 'abs', 'acos', 'asin', 'atan', 'atan2', 'bool2', 'bool3', 'bool4', 'builder', 'ceil', 'clamp', 'cos', 'cross', 'degrees', 'determinant', 'distance', 'dot', 'exp', 'float2', 'float2x2', 'float3', 'float3x3', 'float4', 'float4x4', 'floor', 'int2', 'int3', 'int4', 'inverse', 'length', 'lerp', 'log', 'log10', 'log2', 'log_level_error', 'log_level_info', 'log_level_verbose', 'log_level_warning', 'make_bool2', 'make_bool3', 'make_bool4', 'make_float2', 'make_float2x2', 'make_float3', 'make_float3x3', 'make_float4', 'make_float4x4', 'make_int2', 'make_int3', 'make_int4', 'make_uint2', 'make_uint3', 'make_uint4', 'max', 'min', 'normalize', 'pixel_storage_channel_count', 'pixel_storage_size', 'pixel_storage_to_format_float', 'pixel_storage_to_format_int', 'pow', 'radians', 'rotation', 'round', 'scaling', 'select', 'sin', 'sqrt', 'tan', 'to_bytes', 'translation', 'transpose', 'uint2', 'uint3', 'uint4']
import luisa
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'luisa'

To Reproduce
Steps to reproduce the behavior:

following https://github.com/LuisaGroup/LuisaCompute/blob/master/README_Python_en.md

  1. cmake -S . -B build_release -D CMAKE_BUILD_TYPE=Release -D CMAKE_C_COMPILER=clang -D CMAKE_CXX_COMPILER=clang++ -D LUISA_COMPUTE_ENABLE_PYTHON=ON (note I removed -G Ninja in instructions and used default generator)
  2. cmake --build build_release -j
  3. source set_python_path.sh build_release
  4. (note no test.py copied to build_release/bin directory as instructions imply)
  5. echo $PYTHONPATH
    /Users/bsavery/Code/LuisaCompute/build_release/bin:/Users/bsavery/Code/LuisaCompute/pyscenes:
  6. run python3 src/py/tests/test_path_tracing.py

Traceback (most recent call last):
File "/Users/bsavery/Code/LuisaCompute/src/py/tests/test_path_tracing.py", line 6, in
import luisa
ModuleNotFoundError: No module named 'luisa'

Desktop (please complete the following information):

  • OS: Macos 13
  • Version Python 3.10
@Mike-Leo-Smith
Copy link
Contributor

Hi, @bsavery. Thanks for reporting this and sorry for the outdated documentation.

LuisaCompute now supports installation via pip. To make that happen, we changed the import paths in the python module, which breaks the original installation method.

Now, to install the Python Luisa package, you could cd into the project root and use the following command via pip:

python -m pip install .

Or, to freshly fetch, compile, and install the latest package from the git repo:

python -m pip install git+https://github.com/LuisaGroup/LuisaCompute.git

No extra steps like source set_python_path.sh are required. The package is directly installed as a Python site-package. You could use python -c "import luisa" to verify the installation and welcome to try out the examples.

@bsavery
Copy link
Author

bsavery commented Jan 23, 2023

Oh ok, Great! I'll try that and close issue if it works!

@bsavery
Copy link
Author

bsavery commented Jan 23, 2023

So a couple points. Should update the docs for sure. I'm not an expert in the python build system, but I did run into a few issues running the command:

python -m pip install . (I didn't try installing from url)

With missing dependencies, which I fixed with:
python -m pip install scikit-build-core pybind11 distlib pyproject-metadata pathspec

Again, not an expert in the python build system is there a way to get these dependencies in pyproject.toml?

@Mike-Leo-Smith
Copy link
Contributor

Thanks for finding out the missing dependencies! And yes, they can be specified in the build-system.requires field in pyproject.toml. I've updated the file in the recent commit ba1ea85. We will also update the documentation soon.

@bsavery
Copy link
Author

bsavery commented Jan 24, 2023

great. Yeah I know sometimes on dev systems you have dependencies installed that aren't found until you move to other machines. Hit that issue plenty of times myself!

@bsavery bsavery closed this as completed Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants