Skip to content
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

Pip editable install reports success, doesn't actually build #939

Open
dan-fritchman opened this issue Apr 14, 2023 · 3 comments
Open

Pip editable install reports success, doesn't actually build #939

dan-fritchman opened this issue Apr 14, 2023 · 3 comments

Comments

@dan-fritchman
Copy link

Editably-install the hello-cpp example from https://github.com/scikit-build/scikit-build-sample-projects/tree/master/projects/hello-cpp. It reports success:

$ pip install -e .
Obtaining scikit-build-sample-projects/projects/hello-cpp
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Building wheels for collected packages: hello-cpp
  Building editable for hello-cpp (pyproject.toml) ... done
  Created wheel for hello-cpp: filename=hello_cpp-1.2.3-0.editable-py3-none-any.whl size=2410 sha256=4ae7f2fbb6338c6e31047184e22ef18043740e5432ba73c5d951732e6a5e4cab
  Stored in directory: /tmp/pip-ephem-wheel-cache-z__c9stq/wheels/59/b7/f0/2bf418c678571a24f6452a534896739888bed824135802ff1a
Successfully built hello-cpp
Installing collected packages: hello-cpp
  Attempting uninstall: hello-cpp
    Found existing installation: hello-cpp 1.2.3
    Uninstalling hello-cpp-1.2.3:
      Successfully uninstalled hello-cpp-1.2.3
Successfully installed hello-cpp-1.2.3

But it doesn't actually work. Doesn't look like it attempts to build the C++ at all.

$ pytest
=== test session starts ===
platform linux -- Python 3.9.16, pytest-7.3.0, pluggy-1.0.0 -- miniconda3/envs/py39/bin/python
cachedir: .pytest_cache
rootdir: scikit-build-sample-projects
configfile: pytest.ini
plugins: xdist-3.2.1, cov-4.0.0, dash-2.9.3, timeout-2.1.0, cpp-2.3.0
collected 0 items / 1 error

=== ERRORS ===
___ ERROR collecting projects/hello-cpp/tests/test_hello_cpp.py ___
ImportError while importing test module 'scikit-build-sample-projects/projects/hello-cpp/tests/test_hello_cpp.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../../miniconda3/envs/py39/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/test_hello_cpp.py:1: in <module>
    import hello
hello/__init__.py:1: in <module>
    from ._hello import (
E   ModuleNotFoundError: No module named 'hello._hello'

Some system & setup info.
Most notably this is on RedHat Linux, which admittedly can be weird.

$ uname -a
Linux eda-1 3.10.0-1160.83.1.el7.x86_64 #1 SMP Mon Dec 19 10:44:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ pip --version
pip 23.0.1 from miniconda3/envs/py39/lib/python3.9/site-packages/pip (python 3.9)
$ python --version
Python 3.9.16

On the same machine and setup, installing the same code non-editably does work:

$ pip install -v .
Using pip 23.0.1 from miniconda3/envs/py39/lib/python3.9/site-packages/pip (python 3.9)

# ...

  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja' generator - success
  --------------------------------------------------------------------------------

# ...

  Not searching for unused variables given on the command line.
  -- The C compiler identification is GNU 4.8.5
  -- The CXX compiler identification is GNU 4.8.5
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found PythonInterp: miniconda3/envs/py39/bin/python (found version "3.9.16")
  -- Found PythonLibs: miniconda3/envs/py39/lib/libpython3.9.so (found version "3.9.16")
  -- Performing Test Weak Link MODULE -> SHARED (gnu_ld_ignore) - Success
  _modinit_prefix:PyInit_
  -- Configuring done (0.9s)
  -- Generating done (0.0s)
  -- Build files have been written to: scikit-build-sample-projects/projects/hello-cpp/_skbuild/linux-x86_64-3.9/cmake-build
  [1/3] Building CXX object CMakeFiles/_hello.dir/hello/_hello.cxx.o
  [2/3] Linking CXX shared module _hello.cpython-39-x86_64-linux-gnu.so
  [2/3] Install the project...

# ...

Successfully installed hello-cpp-1.2.3

$ pytest
=================================== test session starts ===================================
platform linux -- Python 3.9.16, pytest-7.3.0, pluggy-1.0.0 -- miniconda3/envs/py39/bin/python
cachedir: .pytest_cache
rootdir: scikit-build-sample-projects
configfile: pytest.ini
plugins: xdist-3.2.1, cov-4.0.0, dash-2.9.3, timeout-2.1.0, cpp-2.3.0
collected 2 items

tests/test_hello_cpp.py::test_hello PASSED                                          [ 50%]
tests/test_hello_cpp.py::test_elevation PASSED                                      [100%]

==================================== 2 passed in 0.08s ====================================

Originally from ALIGN-analoglayout/ALIGN-public#1278

@henryiii
Copy link
Contributor

We don’t support modern editable installs here, sadley. Initial support is present in scikit-build-core (native builds only ATM). You should also be able to set the envvar for classic editable builds in setuptools.

I do think we could possibly make this an error though until we can support it. (It is tricky to support because we have to produce a list of file to module mappings for setuptools).

@dan-fritchman
Copy link
Author

Thanks for jumping on this, appreciate the quick feedback.
And understand if this is something not worth supporting.

Can you help me understand the "modern" vs "classic" build-modes you're referring to?
I don't immediately see either concept, either in skbuild's or setuptool's documentation.

Thanks again!

@henryiii
Copy link
Contributor

henryiii commented Apr 17, 2023

Setuptools 64: https://setuptools.pypa.io/en/latest/userguide/development_mode.html#development-mode-a-k-a-editable-installs - you set --config-settings editable_mode=compat to get the old mode (sort of, not sure how close it is, as it's still based on the new code). The envvar SETUPTOOLS_ENABLE_FEATURES="legacy-editable" no longer works with pip 23.1, out a few days ago.

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

No branches or pull requests

3 participants
@henryiii @dan-fritchman and others