I am trying to install shapely (2.0) from source with custom GEOS library. And I need to build from a local directory cloned from git.
One aspect in the instructions that really confuses me is the use of "development mode" with pip install -e ... in the last line:
$ git clone git@github.com:shapely/shapely.git
$ cd shapely/
$ pip install -e .[test]
The development is something that I really wanted to avoid primarily because as the pip documentation said:
Regular Installs
...
This will install the project into the Python that pip is associated with, in a manner similar to how it would actually be installed.
This is what should be used in CI system and for deployments, since it most closely mirrors how a package would get installed ...
And the primary purpose for my use is to deploy the built shapely to other machines rather than using it on the local machine.
Also, the "editable" mode seems to be some convenience measures that I'd like to skip. The pip documentation says:
caution
It is possible to see behaviour differences between regular installs vs editable installs. ... In case you distribute the project as a “distribution package”, users will see the behaviour of regular installs -- thus, it is important to ensure that regular installs work correctly.
As the documentation didn't say, I'd like to ask here:
Question:
What is the correct way to install shapely from source with custom GEOS and regular installs?
What I have tried so far
After entering the git cloned source folder,
I tried the --no-binary shapely option and removing the -e option as follows:
pip uninstall -y shapely
DEB_PYTHON_INSTALL_LAYOUT=deb_system GEOS_INCLUDE_PATH=/opt/geos/include/ GEOS_LIBRARY_PATH=/opt/geos/lib/ python -m pip install .[test] --no-binary shapely
The pip commands succeeded. But when trying to import the built shapely from python, there is an error:
$ python
Python 3.10.6 (main, May 29 2023, 11:10:38) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shapely
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/user/src/shapely/shapely/__init__.py", line 1, in <module>
from .lib import GEOSException # NOQA
ModuleNotFoundError: No module named 'shapely.lib'
>>>
The "editable" install below can be imported:
pip uninstall -y shapely
DEB_PYTHON_INSTALL_LAYOUT=deb_system GEOS_INCLUDE_PATH=/opt/geos/include/ GEOS_LIBRARY_PATH=/opt/geos/lib/ python -m pip install -e .[test]
The above is tested in a script executed with sudo and under Ubuntu 22.04.