I am building a Cython program (called for ex. testpackage) using the command:
python setup.py build_ext --inplace
In a folder like /home/USER/Documents/testpackage/
. The build runs successfully but when I cd into another folder, I can no longer use the module testpackage
. Is there another command I can run instead of --inplace
so that I can import testpackage
in Python in any folder? I looked at the anaconda/lib/python2.7/site-packages/
folder and do not see any reference to testpackage
anywhere. Is this standard for Cython builds?
NOTE: I am doing this through a .sh file using conda build testpackage
so the command python setup.py build_ext --inplace
is actually in the shell file.
Thank you for your help.
python setup.py build_ext --inplace uses the setup.py to build our extension modules. The --inplace flag moves the compiled shared objects into the source tree so that they are in the Python search path.
...as of the last few years all direct invocations of setup.py are effectively deprecated in favor of invocations via purpose-built and/or standards-based CLI tools like pip, build and tox.
you must have a valid setup.py file apart from setup. cfg and pyproject. toml . You can use the same dummy setup file I shared in the previous section that makes just a single call to the setup() method.
The --inplace option creates the shared object file (with .so suffix) in the current directory. To use this module from python this file must be in the python path (sys.path).
To install to the system python folder run
python setup.py build_ext
sudo python setup.py install
If you don't have admin rights, you can also install locally using
python setup.py build_ext
python setup.py install --user
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With