insarlab / PySolid

A Python wrapper for solid Earth tides
GNU General Public License v3.0
61 stars 7 forks source link

`pip install pysolid` support #42

Closed yunjunz closed 7 months ago

yunjunz commented 1 year ago

pysolid is now available on PyPI (https://pypi.org/project/pysolid/). But pip install pysolid does not work, because a Fortran compiler is required to build the package but is not available via pip, as far as I know. It will be great if pip install could work!

jhkennedy commented 1 year ago

Can be done with cibuildwheel: https://cibuildwheel.readthedocs.io/en/stable/

yunjunz commented 1 year ago

That is great to know! Thank you @jhkennedy. I will take a deeper look at this later.

yunjunz commented 1 year ago

43 solved the pip install pysolid for macOS and Linux, but not for Windows yet. For Windows, there are preliminary recipes in .github/workflows/build-and-publish-to-pypi.yml, which needs further testing and modification.

yunjunz commented 1 year ago

Testing pysolid from Test PyPI (https://test.pypi.org/project/pysolid/) shows the following errors on macOS.

Full script that generated the error

conda create --name test --yes
conda activate test
mamba install pip

# 1st try to install pysolid from Test PyPI
pip install --index-url https://test.pypi.org/simple/ pysolid

# 2nd try to install numpy and pysolid
pip install numpy
pip install --index-url https://test.pypi.org/simple/ pysolid

Full error message

(test) yunjunz:~>$ pip install --index-url https://test.pypi.org/simple/ pysolid
Looking in indexes: https://test.pypi.org/simple/
Collecting pysolid
  Downloading https://test-files.pythonhosted.org/packages/4a/3f/f8e5589c69812c5951ffb9d031fb7b798fd08a61ff53330f006b82c5122d/pysolid-0.2.3.post3-cp311-cp311-macosx_10_9_x86_64.whl (1.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 7.7 MB/s eta 0:00:00
Collecting numpy
  Downloading https://test-files.pythonhosted.org/packages/d5/80/b947c574d9732e39db59203f9aa35cb4d9a5dd8a0ea2328acb89cf10d6e3/numpy-1.9.3.zip (4.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4.5/4.5 MB 30.6 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting scipy
  Downloading https://test-files.pythonhosted.org/packages/68/72/eb962a3ae2755af6b1f31f7a94dccc21bfc41bb1637c5877a043e711b1d7/scipy-0.1.tar.gz (1.3 kB)
  Preparing metadata (setup.py) ... done
Collecting pysolid
  Downloading https://test-files.pythonhosted.org/packages/23/20/baa6086368a2e9e60f3f1d076d9bec3379b2f1f563be0509de65c5fd6c7e/pysolid-0.2.3.post1.tar.gz (39 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/bg/9j3hscxn7t53s3c078rlck7c0000gq/T/pip-install-dxttx7d2/pysolid_c9194f30006741b78d530499d0786d98/setup.py", line 12, in <module>
          from numpy.distutils.core import setup, Extension
      ModuleNotFoundError: No module named 'numpy'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(test) yunjunz:~>$ pip install numpy
Collecting numpy
  Using cached numpy-1.23.4-cp311-cp311-macosx_10_9_x86_64.whl (18.1 MB)
Installing collected packages: numpy
Successfully installed numpy-1.23.4

(test) yunjunz:~>$ pip install --index-url https://test.pypi.org/simple/ pysolid
Looking in indexes: https://test.pypi.org/simple/
Collecting pysolid
  Using cached https://test-files.pythonhosted.org/packages/4a/3f/f8e5589c69812c5951ffb9d031fb7b798fd08a61ff53330f006b82c5122d/pysolid-0.2.3.post3-cp311-cp311-macosx_10_9_x86_64.whl (1.3 MB)
Requirement already satisfied: numpy in ./tools/miniconda3/envs/test/lib/python3.11/site-packages (from pysolid) (1.23.4)
Collecting scipy
  Using cached https://test-files.pythonhosted.org/packages/68/72/eb962a3ae2755af6b1f31f7a94dccc21bfc41bb1637c5877a043e711b1d7/scipy-0.1.tar.gz (1.3 kB)
  Preparing metadata (setup.py) ... done
Collecting pysolid
  Using cached https://test-files.pythonhosted.org/packages/23/20/baa6086368a2e9e60f3f1d076d9bec3379b2f1f563be0509de65c5fd6c7e/pysolid-0.2.3.post1.tar.gz (39 kB)
  Preparing metadata (setup.py) ... done
Discarding https://test-files.pythonhosted.org/packages/23/20/baa6086368a2e9e60f3f1d076d9bec3379b2f1f563be0509de65c5fd6c7e/pysolid-0.2.3.post1.tar.gz (from https://test.pypi.org/simple/pysolid/) (requires-python:>=3.6): Requested pysolid from https://test-files.pythonhosted.org/packages/23/20/baa6086368a2e9e60f3f1d076d9bec3379b2f1f563be0509de65c5fd6c7e/pysolid-0.2.3.post1.tar.gz has inconsistent version: expected '0.2.3.post1', but metadata has '0.2.4'
  Downloading https://test-files.pythonhosted.org/packages/d0/c6/daa04580853f9404af6eca818d87708eebfbe940d67e258bc3cce5dd8243/pysolid-0.2.3.tar.gz (39 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      /private/var/folders/bg/9j3hscxn7t53s3c078rlck7c0000gq/T/pip-install-s7qbn_43/pysolid_96d62e0bf0e34d6d9513d24c6ae32408/setup.py:12: DeprecationWarning:

        `numpy.distutils` is deprecated since NumPy 1.23.0, as a result
        of the deprecation of `distutils` itself. It will be removed for
        Python >= 3.12. For older Python versions it will remain present.
        It is recommended to use `setuptools < 60.0` for those Python versions.
        For more details, see:
          https://numpy.org/devdocs/reference/distutils_status_migration.html

        from numpy.distutils.core import setup, Extension
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/bg/9j3hscxn7t53s3c078rlck7c0000gq/T/pip-install-s7qbn_43/pysolid_96d62e0bf0e34d6d9513d24c6ae32408/setup.py", line 17, in <module>
          from pysolid.version import version
        File "/private/var/folders/bg/9j3hscxn7t53s3c078rlck7c0000gq/T/pip-install-s7qbn_43/pysolid_96d62e0bf0e34d6d9513d24c6ae32408/src/pysolid/__init__.py", line 5, in <module>
          from pysolid.grid import (
        File "/private/var/folders/bg/9j3hscxn7t53s3c078rlck7c0000gq/T/pip-install-s7qbn_43/pysolid_96d62e0bf0e34d6d9513d24c6ae32408/src/pysolid/grid.py", line 18, in <module>
          from skimage.transform import resize
      ModuleNotFoundError: No module named 'skimage'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
yunjunz commented 1 year ago

After #45, the following pip install works for me on macOS, which is great!

mamba install --file ~/tools/PySolid/requirements.txt
pip install --index-url https://test.pypi.org/simple/ pysolid

I am adding back the dependency config in setup.py (#46) and hope this could eliminate the manual dependency installation.

yunjunz commented 1 year ago

After #46, the following one-line installation went through without error. But testing shows the dependencies are not actually installed, even though they are shown in the installation (note the numpy version there is pretty old).

(pysolid) yunjunz:~>$ pip install --index-url https://test.pypi.org/simple/ pysolid
Looking in indexes: https://test.pypi.org/simple/
Collecting pysolid
  Downloading https://test-files.pythonhosted.org/packages/10/35/a49dc0ee11cf5dd70b7132b675fff932ee52e1377edd713558d41c10a584/pysolid-0.2.3.post5-cp311-cp311-macosx_10_9_x86_64.whl (1.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 9.1 MB/s eta 0:00:00
Collecting numpy
  Using cached https://test-files.pythonhosted.org/packages/d5/80/b947c574d9732e39db59203f9aa35cb4d9a5dd8a0ea2328acb89cf10d6e3/numpy-1.9.3.zip (4.5 MB)
  Preparing metadata (setup.py) ... done
Collecting scipy
  Using cached https://test-files.pythonhosted.org/packages/68/72/eb962a3ae2755af6b1f31f7a94dccc21bfc41bb1637c5877a043e711b1d7/scipy-0.1.tar.gz (1.3 kB)
  Preparing metadata (setup.py) ... done
Collecting pysolid
  Using cached https://test-files.pythonhosted.org/packages/06/32/287f9ce979570812189972f2d33a514e17511f19f78dd397c756221ff332/pysolid-0.2.3.post4-cp311-cp311-macosx_10_9_x86_64.whl (1.3 MB)
Installing collected packages: pysolid
Successfully installed pysolid-0.2.3.post4

(pysolid) yunjunz:~>$ ./tools/PySolid/tests/grid.py 
Traceback (most recent call last):
  File "/Users/yunjunz/./tools/PySolid/tests/grid.py", line 10, in <module>
    import pysolid
  File "/Users/yunjunz/tools/miniconda3/envs/pysolid/lib/python3.11/site-packages/pysolid/__init__.py", line 14, in <module>
    from pysolid.grid import (
  File "/Users/yunjunz/tools/miniconda3/envs/pysolid/lib/python3.11/site-packages/pysolid/grid.py", line 17, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'
yunjunz commented 1 year ago

Testing based on the latest version 0.3.0 passed on macOS and Linux. So I guess the previous error using TestPyPI is somehow not happening in PyPI. Cheers!

jhkennedy commented 7 months ago

@yunjunz can we close this issue? I don't see anything left to do here.

yunjunz commented 7 months ago

Yes, I think this is complete! Thank you @jhkennedy!