setup.py tries to install Symengine even if it was not built
Describe the bug
Even when option SYMFORCE_BUILD_SYMENGINE is set to OFF, setup.py still attempts to install Symengine, which will now fail.
To Reproduce
git clone symforce v0.8.0
Set SYMFORCE_BUILD_SYMENGINE to OFF
python3 -m pip install .
...
error: can't copy 'build/temp.macosx-10.9-universal2-cpython-39/symengine_install/lib/python3.9/site-packages/symengine/lib/symengine_wrapper.cpython-39-darwin.so': doesn't exist or not a regular file
I worked around this by commenting out the install code in setup.py:
self.copy_file(
build_dir
/ "symengine_install"
/ "lib"
/ f"python{sys.version_info.major}.{sys.version_info.minor}"
/ "site-packages"
/ "symengine"
/ "lib"
/ build_ext_obj.get_ext_filename("symengine_wrapper"),
Path.cwd()
/ self.install_platlib # type: ignore[attr-defined]
/ "symengine"
/ "lib"
/ build_ext_obj.get_ext_filename("symengine_wrapper"),
)
Expected behavior
Should not try to install Symengine when SYMFORCE_BUILD_SYMENGINE is OFF.
Environment (please complete the following information):
- OS and version: MacOS Ventura 13.3.1
- Python version: Python 3.9.13
- SymForce Version: 0.8.0
Additional context cmake version 3.26.3
Could you elaborate on why you want to set SYMFORCE_BUILD_SYMENGINE=OFF?
Asking because the original reason for providing this flag is to only build the gen and opt packages.
I had difficulty building symengine due to some complex cython compilation problem. Since I had no need for symengine, I decided to just not build it! I am only using the gen, opt, and slam packages.
Ah, so you aren't using any python code at all? Usually we'd recommend installing with cmake and not pip in that case
I am using python code for codegen. And even without symengine, I run the codegen infrequently enough that waiting a couple seconds is plenty fast for me!
Would this problem be different if I were invoking cmake directly instead of through pip?
Regardless, I am installing like this because of the readme saying:
If you want to compile against C++ SymForce types (like sym::Optimizer), you currently need to build from source.
If you just want to build and install SymForce without repeatedly modifying the source, the recommended way to do this is with pip.
Would this problem be different if I were invoking cmake directly instead of through pip?
Yeah invoking cmake directly, you wouldn't run into this
Regardless, I am installing like this because of the readme saying:
If you want to compile against C++ SymForce types (like sym::Optimizer), you currently need to build from source.
If you just want to build and install SymForce without repeatedly modifying the source, the recommended way to do this is with pip.
Ah, good point, we do say that. Curious if you have more info about what was going wrong with Cython? We should really get the packaged install to include everything you need to build against it, but it might also make sense to enable building SymForce from source, but pulling an already-built copy of our modified SymEngine from somewhere instead of needing to build that too, since even most people building SymForce from source aren't modifying SymEngine
The error I'm getting building Symengine with Cython is "Your Cython version is too old. Please upgrade Cython."
I ran python3 -m pip install --upgrade Cython and the newest I get is 0.29.35, which still produces this "too old" error.
It's pretty likely the issue you're seeing is this: https://github.com/symforce-org/symforce/issues/161
Which is resolved by cleaning your build directory as mentioned there