How do you write a setup.py to compile .pyx files in an arbitrary location and install the compiled code in another arbitrary location? For example dirA/spam.pyx to build/dirB/spam.so?
1 Answer
According to the distutils documentation, you can build any compiled python modules in an arbitrary location using the command line option --build-base, e.g.:
python setup.py build --build-base=/build/dirB
If you want to keep the default build directory, but install to a custom location, you should use one of the options --user --home, --prefix, --exec-prefix, --install-base or --install-platbase
Finally, if you just want the .so file in the current directory, use the option --inplace
build/lib-linux-<arch>-<ver>/spam-cpython-<ver>.so. I asked because I couldn't get it to install it elsewhere.