getkeops / keops

KErnel OPerationS, on CPUs and GPUs, with autodiff and without memory overflows
https://www.kernel-operations.io
MIT License
1.03k stars 65 forks source link

Move keopscore and pykeops into their own sub-directories #222

Closed gdurif closed 2 years ago

gdurif commented 2 years ago

New repository structure :

keops
├── keopscore
│   ├── keopscore
│   │   ├── __init__.py
│   │   └── ...
│   ├── setup.py
│   └── ...
├── pykeops
│   ├── pykeops
│   │   ├── __init__.py
│   │   └── ...
│   ├── setup.py
│   └── ...
└── ... 

TODOs:

[1] local pip install keopscore or pip install pykeops works with pip v22.0.4 but not with pip v20.0.2

[2] pip install -e 'git+https://…/repo.git@branch#egg=package&subdirectory=package'

gdurif commented 2 years ago

Note: To install using pip from git (using this branch) and specifying the subdirectory:

pip install git+https://github.com/getkeops/keops.git@python_package_subdir#subdirectory=pykeops
gdurif commented 2 years ago

Note:

$ python -c "import pykeops"
[KeOps] Warning : Cuda libraries were not detected on the system ; using cpu only mode
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/xxx/.pyenv/lib/python3.8/site-packages/pykeops/__init__.py", line 76, in <module>
    import pykeops.common.keops_io
  File "/xxx/.pyenv/lib/python3.8/site-packages/pykeops/common/keops_io/__init__.py", line 12, in <module>
    import pykeops.common.keops_io.LoadKeOps_cpp
  File "/xxx/.pyenv/lib/python3.8/site-packages/pykeops/common/keops_io/LoadKeOps_cpp.py", line 9, in <module>
    from keopscore.utils.misc_utils import KeOps_OS_Run
ImportError: cannot import name 'KeOps_OS_Run' from 'keopscore.utils.misc_utils' (/xxx/.pyenv/lib/python3.8/site-packages/keopscore/utils/misc_utils.py)

(Same problem with a cuda environment)

Edit: origin of the problem found, c.f. #225

gdurif commented 2 years ago

Note: pip install git+https://github.com/getkeops/keops.git@python_package_subdir#subdirectory=pykeops is not working because it installs keopscore==2.0b1 from PyPI which is buggy (c.f. #225 )

Fix: local install of keopscore before pip git install

$ pip install ./keopscore
Processing ./keopscore
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for keopscore, since package 'wheel' is not installed.
Installing collected packages: keopscore
  Running setup.py install for keopscore ... done
Successfully installed keopscore-2.0b1

$ pip install git+https://github.com/getkeops/keops.git@python_package_subdir#subdirectory=pykeops
Collecting git+https://github.com/getkeops/keops.git@python_package_subdir#subdirectory=pykeops
  Cloning https://github.com/getkeops/keops.git (to revision python_package_subdir) to /tmp/pip-req-build-f9xy05h2
  Running command git clone --filter=blob:none --quiet https://github.com/getkeops/keops.git /tmp/pip-req-build-f9xy05h2
  Running command git checkout -b python_package_subdir --track origin/python_package_subdir
  Switched to a new branch 'python_package_subdir'
  Branch 'python_package_subdir' set up to track remote branch 'python_package_subdir' from 'origin'.
  Resolved https://github.com/getkeops/keops.git to commit 369dc9286bd90d8730e5ff87f385483bd5162c63
  Running command git submodule update --init --recursive -q
  Preparing metadata (setup.py) ... done
Requirement already satisfied: keopscore==2.0b1 in ./.pyenv/lib/python3.8/site-packages (from pykeops==2.0b1) (2.0b1)
Collecting numpy
  Using cached numpy-1.22.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Collecting pybind11
  Using cached pybind11-2.9.1-py2.py3-none-any.whl (211 kB)
Using legacy 'setup.py install' for pykeops, since package 'wheel' is not installed.
Installing collected packages: pybind11, numpy, pykeops
  Running setup.py install for pykeops ... done
Successfully installed numpy-1.22.3 pybind11-2.9.1 pykeops-2.0

$ python -c "import pykeops; pykeops.test_numpy_bindings()"
[KeOps] Warning : Cuda libraries were not detected on the system ; using cpu only mode
[KeOps] Generating code for formula Sum_Reduction((Var(0,3,0)-Var(1,3,1))|(Var(0,3,0)-Var(1,3,1)),1) ... OK
[pyKeOps] Compiling pykeops cpp c872f1d359 module ... OK
pyKeOps with numpy bindings is working!
gdurif commented 2 years ago

Note:

Remaining TODOs (for other PRs):

gdurif commented 2 years ago

@bcharlier @joanglaunes can we merge this?