Closed jhkennedy closed 2 years ago
I've opened a throw away PR to the PySolid feedstock showing this new build methodology works for Linux, Windows, and Mac conda-forge packaging: https://github.com/conda-forge/pysolid-feedstock/pull/3
This is great @jhkennedy!! I tried to follow your note to compile from the source using conda, and the installation seems to work fine.
There is one issue while running the test commands, as below:
(test) yunjunz:~/tools/PySolid>$ python -c "import pysolid; print(pysolid.__version__)"
Traceback (most recent call last):
File "/Users/yunjunz/tools/PySolid/pysolid/grid.py", line 20, in <module>
from .solid import solid_grid
ModuleNotFoundError: No module named 'pysolid.solid'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/yunjunz/tools/PySolid/pysolid/__init__.py", line 1, in <module>
from .grid import *
File "/Users/yunjunz/tools/PySolid/pysolid/grid.py", line 25, in <module>
raise ImportError(msg)
ImportError: Cannot import name 'solid' from 'pysolid'!
Maybe solid.for is NOT compiled yet.
Check instruction at: https://github.com/insarlab/PySolid.
I believe this is because both grid.py
and point.py
use the local import of the pysolid.solid
module. I am not sure if this is related to the libraries
in setup.py. Any idea?
I am wondering did the-empty-solid.txt-file issue (https://github.com/insarlab/PySolid/issues/15) occurred to you for tests of pysolid.grid
on Windows OS?
@yunjunz huh, I can recreate the ImportError: Cannot import name 'solid' from 'pysolid'!
when I install via pip
without a -e
, but solid
is in the installed directory -- wonder why CircleCI or conda-forge isn't having the same problem? I'll see if I can figure out what's going on.
FYI, if I change the import inside grid.py and point.py from:
from .solid import solid_grid
to
from pysolid.solid import solid_grid
it works fine.
@yunjunz yeah if I cd ..
(out of the PySolid repo) it also works -- I think it's weird python shananigans picking up the local repository and not having the build .so
inside it (like it does with an editable install).
I'll change the imports and poke at it a bit more
@yunjunz I switch the relative imports to absolute, and fixed a little of the README instructions. Some people may still see the same import error if they pip install and then try to run/import pysolid from the the repository root, which is why Python tends to recomend a src
layout (e.g., here and here). If you're working in the repository, an editable (-e
) should always work fine and is better for development anyways.
Thank you @jhkennedy for the fix! The test passed on my macOS.
@yunjunz I haven't hand a chance to look at #15 (tests work on linux, focused on the build working on windows), but can try that out as well (will just need to fire up my old desktop).
The ultimate goal of this PR is make windows builds via conda-forge (and therefore allow MintPy on windows via conda-forge insarlab/MintPy#648 ).
It uses the
numpy.f2py
package to provide compilation of the fortran sources at install time via setuptools/pipwhich means:
Fixes #12 , #9