Skip to content

Add pygmt #2525

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

Closed
wants to merge 3 commits into from
Closed

Add pygmt #2525

wants to merge 3 commits into from

Conversation

weiji14
Copy link
Contributor

@weiji14 weiji14 commented May 8, 2022

Description

Placeholder for adding PyGMT (a library for processing geospatial data and making maps) to Pyodide.

TODO, include 2 runtime C dependencies, xref https://github.com/conda-forge/pygmt-feedstock/blob/b7ecf50df60e8e15cbf5d47122a7beb4ce349d9c/recipe/meta.yaml#L24-L31:

Other Python dependencies:

Notes on testing this branch

  1. Follow https://pyodide.org/en/latest/development/new-packages.html, get pyodide development environment set-up
  2. git clone this branch
  3. cd packages/pygmt/
  4. python -m pyodide_build buildpkg meta.yaml
  5. cd ../../
  6. PYODIDE_PACKAGES="pygmt" make
  1. ...

Checklists

  • Add a CHANGELOG entry
  • Add / update tests
  • Add new / update outdated documentation

@weiji14 weiji14 changed the title Add pygmt package for pyodide Add pygmt May 8, 2022
Also need gmt and netCDF4 but commenting those out for now.
@weiji14
Copy link
Contributor Author

weiji14 commented May 11, 2022

Note to self, get libgmt packaged, and update/patch code on PyGMT to fix this error https://app.circleci.com/pipelines/github/pyodide/pyodide/4095/workflows/6cd9a4d7-2f51-4f0b-ae57-15cd7be70b42/jobs/45300?invite=true#step-102-701:

----------------------------- Captured stdout call -----------------------------
JavascriptException message:  Traceback (most recent call last):
  File "/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception
  File "/lib/python3.10/asyncio/tasks.py", line 232, in __step
    result = coro.send(None)
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 500, in eval_code_async
    await CodeRunner(
  File "/lib/python3.10/site-packages/_pyodide/_base.py", line 351, in run_async
    coroutine = eval(self.code, globals, locals)
  File "<exec>", line 1, in <module>
  File "/lib/python3.10/site-packages/pygmt/__init__.py", line 71, in <module>
    _begin()
  File "/lib/python3.10/site-packages/pygmt/session_management.py", line 16, in begin
    with Session() as lib:
  File "/lib/python3.10/site-packages/pygmt/clib/session.py", line 183, in __enter__
    self.create("pygmt-session")
  File "/lib/python3.10/site-packages/pygmt/clib/session.py", line 330, in create
    c_create_session = self.get_libgmt_func(
  File "/lib/python3.10/site-packages/pygmt/clib/session.py", line 282, in get_libgmt_func
    self._libgmt = load_libgmt()
  File "/lib/python3.10/site-packages/pygmt/clib/loading.py", line 47, in load_libgmt
    for libname in lib_fullnames:
  File "/lib/python3.10/site-packages/pygmt/clib/loading.py", line 107, in clib_full_names
    libnames = clib_names(os_name=sys.platform)  # e.g. libgmt.so, libgmt.dylib, gmt.dll
  File "/lib/python3.10/site-packages/pygmt/clib/loading.py", line 85, in clib_names
    raise GMTOSError(f"Operating system '{os_name}' not supported.")
pygmt.exceptions.GMTOSError: Operating system 'emscripten' not supported.

@leouieda
Copy link

@weiji14 this would be awesome! The major challenge will likely be getting GMT in first and all its dependencies. From the pyodide contributing docs it seems that C dependencies should be added separately and then included as dependencies here. So the way forward is probably to try to get all of the GMT dependencies in first: https://github.com/conda-forge/gmt-feedstock/blob/main/recipe/meta.yaml The ones that usually cause problems are GDAL and ghostscript.

@weiji14
Copy link
Contributor Author

weiji14 commented May 31, 2022

@weiji14 this would be awesome!

Yes, the goal is to have an in-browser version of https://github.com/GenericMappingTools/try-gmt. No install needed to try out PyGMT 😄

The major challenge will likely be getting GMT in first and all its dependencies. From the pyodide contributing docs it seems that C dependencies should be added separately and then included as dependencies here. So the way forward is probably to try to get all of the GMT dependencies in first: https://github.com/conda-forge/gmt-feedstock/blob/main/recipe/meta.yaml The ones that usually cause problems are GDAL and ghostscript.

No kidding, this definitely won't be easy, but let's take it one step at a time. There should be some smart people working on the GDAL port (e.g. the geopandas folks at #1569) since that's the basis of most geo-libraries. Ghostscript might be a tougher sell to port to WebAssembly, but hopefully doable (fingers crossed that PyQT doesn't creep in).

I don't have much dedicated time to push this forward, so if anyone wants to build on this, let me know and I can give you access to the branch at https://github.com/weiji14/pyodide/tree/pygmt to work on this (or you can fork a copy and work on it independently).

@agriyakhetarpal
Copy link
Member

Hi @weiji14 and @leouieda, I'm trying to triage older PRs that have been inactive for a while; could you please investigate if running pygmt in the browser is still of interest to you? NetCDF4 has been available for some time now, and it would be okay to add the GMT library within the same PR.

@weiji14
Copy link
Contributor Author

weiji14 commented Dec 30, 2024

Hi @agriyakhetarpal, oh nice, good to know that netcdf4 is available now (though we are thinking of making it an optional dependency in GenericMappingTools/pygmt#3643).

I'm on holiday break and probably won't have much bandwidth to get to this PR anytime soon. Please feel free to close this PR, I can always reopen it or start a new one later.

@agriyakhetarpal
Copy link
Member

Thank you for the response! I'll close this then – wishing you happy holidays and new year :D

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

Successfully merging this pull request may close these issues.

3 participants