opengeos / whitebox-python

WhiteboxTools Python Frontend

Home Page:https://pypi.org/project/whitebox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to stop the binary being downloaded?

mpickering opened this issue · comments

Any use of the python library attempts to download a tarball into a read only directly on my system. I already have whitebox_tools on my path, so I do not want to download it again.

  1. The file should be downloaded into one of the XDG_* directories rather than into this read-only directory.
  2. The file wouldn't work even if it was downloaded on my OS so I would prefer to have the option to skip this step.
[nix-shell:~/whitebox-python]$ ./lidar.py 
Downloading WhiteboxTools pre-compiled binary for first time use ...
Unexpected error: <class 'OSError'>
Traceback (most recent call last):
  File "./lidar.py", line 5, in <module>
    from whitebox.whitebox_tools import WhiteboxTools
  File "/nix/store/cnzdmpl269k27j4j28l0xmi39yr278qw-python3-3.7.7-env/lib/python3.7/site-packages/whitebox/__init__.py", line 10, in <module>
    from .wb_runner import Runner
  File "/nix/store/cnzdmpl269k27j4j28l0xmi39yr278qw-python3-3.7.7-env/lib/python3.7/site-packages/whitebox/wb_runner.py", line 33, in <module>
    wbt = WhiteboxTools()
  File "/nix/store/cnzdmpl269k27j4j28l0xmi39yr278qw-python3-3.7.7-env/lib/python3.7/site-packages/whitebox/whitebox_tools.py", line 144, in __init__
    download_wbt()
  File "/nix/store/cnzdmpl269k27j4j28l0xmi39yr278qw-python3-3.7.7-env/lib/python3.7/site-packages/whitebox/whitebox_tools.py", line 55, in download_wbt
    urllib.request.urlretrieve(url, zip_name)   # Download WhiteboxTools
  File "/nix/store/syqcp8zb9c0vxj2sx6jbv5f9q7yki4jz-python3-3.7.7/lib/python3.7/urllib/request.py", line 257, in urlretrieve
    tfp = open(filename, 'wb')
OSError: [Errno 30] Read-only file system: '/nix/store/cnzdmpl269k27j4j28l0xmi39yr278qw-python3-3.7.7-env/lib/python3.7/site-packages/whitebox/WhiteboxTools_linux_amd64.tar.xz'

Workaround:

  1. Clone the source of the latest release - https://github.com/jblindsay/whitebox-tools/releases/tag/v1.2.0
  2. Create a symlink ln -s $(which whitebox_tools) whitebox_tools in the root folder

I am sorry, but the package is not designed for read-only file system. You can try modifying this line of the source code to specify the WBT directory. You can also directly use whitebox_tools.py within the WBT directory without having to install the package. See here.