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

Virtualenv support? #26

Open
marklit opened this issue Nov 9, 2024 · 4 comments
Open

Virtualenv support? #26

marklit opened this issue Nov 9, 2024 · 4 comments

Comments

@marklit
Copy link

marklit commented Nov 9, 2024

Are there any plans to make this package installable into a virtual environment?

$ cd /mnt/d/code_gis/isce3/build/packages
$ pip install isce3/
ERROR: Directory 'isce3/' is not installable. Neither 'setup.py' nor 'pyproject.toml' found.
$ find . | grep setup.py | wc -l # 0

I tried setting a few paths manually but I ended up with circular import errors.

export PATH=$PATH:/mnt/d/code_gis/isce3
export PYTHONPATH=$PYTHONPATH:/mnt/d/code_gis/isce3/build/packages
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/d/code_gis/isce3/build/lib
from isce3.core import dateTime, timeDelta, statevector, orbit, ellipsoid, lut2d
from isce3.geometry import rdr2geo_point, rdr2geo_cone
from isce3 import isceextension as ie
ImportError: cannot import name 'isce3' from partially initialized module 'isce3.ext' (most likely due to a circular import) (/mnt/d/code_gis/isce3/build/packages/isce3/ext/__init__.py)
@piyushrpt
Copy link
Member

You should be able to install everything into a virtualenv with the right arguments to cmake.
See https://github.com/conda-forge/isce3-feedstock/blob/main/recipe/build-pkg.sh for example.

@piyushrpt
Copy link
Member

piyushrpt commented Nov 9, 2024

For development, you can also just set LD_LIBRARY_PATH and PYTHONPATH as well if you are iterating

LD_LIBRARY_PATH=LD_LIBRARY_PATH:$installdir/lib
PYTHONPATH=PYTHONPATH:$installdir/packages

@marklit
Copy link
Author

marklit commented Nov 11, 2024

I tried setting those two environment variables and re-compiling but they didn't change the installation path.

$ sudo ldconfig

$ cd ..
$ rm -fr build
$ mkdir build
$ cd build

$ export LD_LIBRARY_PATH=/home/mark/.nasa_sar/lib
$ export PYTHONPATH=/home/mark/.nasa_sar/lib/python3.11/site-packages

$ CC=gcc \
  CXX=g++ \
  GDAL_ROOT=/usr/local/bin \
  cmake \
    -DCMAKE_INSTALL_PREFIX=../install \
    ../

$ make -j$(nproc) VERBOSE=ON
$ make install
...
-- Installing: /mnt/d/code_gis/isce3/install/packages/isce3/parsers/CEOS/CalibrationDataRecordType.py
-- Installing: /mnt/d/code_gis/isce3/install/packages/isce3/parsers/CEOS/CEOSHeaderType.py
-- Installing: /mnt/d/code_gis/isce3/install/packages/isce3/parsers/CEOS/DatasetSummaryRecordType.py
-- Installing: /mnt/d/code_gis/isce3/install/packages/isce3/parsers/CEOS/FacilityRelatedDataRecordType.py
-- Installing: /mnt/d/code_gis/isce3/install/packages/isce3/parsers/CEOS/FileDescriptorType.py
...

I then just set those two environment variables to where the files were installed but I'm still not able to import them.

$ export LD_LIBRARY_PATH=/mnt/d/code_gis/isce3/install/lib
$ export PYTHONPATH=/mnt/d/code_gis/isce3/install/packages
$ ipython
from isce3.core import dateTime, timeDelta, statevector, orbit, ellipsoid, lut2d
ImportError: cannot import name 'dateTime' from 'isce3.core' (/mnt/d/code_gis/isce3/install/packages/isce3/core/__init__.py)

I tried deactivating the venv and seeing if I could import anything.

$ deactivate
$ cd /mnt/d/code_gis/isce3/install
$ export LD_LIBRARY_PATH=/home/mark/.nasa_sar/lib
$ export PYTHONPATH=/home/mark/.nasa_sar/lib/python3.11/site-packages
$ python3
from isce3.core import dateTime, timeDelta, statevector, orbit, ellipsoid, lut2d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'isce3'
$ cd /mnt/d/code_gis/isce3/install/packages
$ python3
from isce3.core import dateTime, timeDelta, statevector, orbit, ellipsoid, lut2d
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/d/code_gis/isce3/install/packages/isce3/__init__.py", line 2, in <module>
    from .ext import extisce3
  File "/mnt/d/code_gis/isce3/install/packages/isce3/ext/__init__.py", line 3, in <module>
    from . import isce3 as extisce3
ImportError: cannot import name 'isce3' from partially initialized module 'isce3.ext' (most likely due to a circular import) (/mnt/d/code_gis/isce3/install/packages/isce3/ext/__init__.py)

I tried compiling with the venv as a target but I'm still fighting a pyre issue.

$ cd /mnt/d/code_gis/isce3/build
$ source ~/.nasa_sar/bin/activate

$ sudo apt install libgtest-dev
$ pip install pyre-check

$ cmake ../ \
    -DPython_EXECUTABLE=/home/mark/.nasa_sar/bin/python3 \
    -DISCE3_FETCH_DEPS=OFF \
    -DISCE3_FETCH_PYRE=OFF \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_INSTALL_PREFIX=/home/mark/.nasa_sar/,/home/mark/.nasa_sar/bin \
    -DCMAKE_INSTALL_LIBDIR=lib \
    -DISCE_PACKAGESDIR=/home/mark/.nasa_sar/lib/python3.11/site-packages \
    -DGTEST_BUILD_TESTS=OFF
CMake Error at extern/CMakeLists.txt:133 (find_package):
  Could not find a package configuration file provided by "pyre" (requested
  version 1.12.5) with any of the following names:

    pyreConfig.cmake
    pyre-config.cmake

  Add the installation prefix of "pyre" to CMAKE_PREFIX_PATH or set
  "pyre_DIR" to a directory containing one of the above files.  If "pyre"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:119 (getpackage_pyre)

Is there some sort of pre-build wheel that statically compiled everything and could be installed via pip on its own?

@piyushrpt
Copy link
Member

There is a whole bunch of funny (not recommended things) going here.

  1. If python version in the virtualenv and your default python are different - this should never work.
  2. You are setting env variables to certain values and might be losing others that are also needed. You should append to these variables.
  3. DCMAKE_INSTALL_PREFIX already has bin which it should not.

Maybe the best thing for you to consider is to work with conda and there is a pre-built package for it. I would also recommend this if your intention is to just use the package as is and you don't plan to actually modify the code.

I don't think there are pip wheels for isce3 yet since this package is rapidly changing and most the dev is happening on a private git - this is just a public copy of the repo that is updated with tested changes once in a while.

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