Pebaz / nimporter

Compile Nim Extensions for Python On Import!
MIT License
824 stars 33 forks source link

Install works as editable but not regular #33

Closed Benjamin-Lee closed 3 years ago

Benjamin-Lee commented 4 years ago

I'm in a different directory as my main library in a different virtualenv. It works when I do a pip install -e install but not a regular (no -e flag) install:

~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ pip install ../librtd/librtd-py
Processing /Users/BenjaminLee/Desktop/Python/Research/librtd/librtd-py
Processing /Users/BenjaminLee/Library/Caches/pip/wheels/9b/04/dd/7daf4150b6d9b12949298737de9431a324d4b797ffd63f526e/docopt-0.6.2-py2.py3-none-any.whl
Building wheels for collected packages: librtd
  Building wheel for librtd (setup.py) ... done
  Created wheel for librtd: filename=librtd-0.0.1-cp37-cp37m-macosx_10_15_x86_64.whl size=141098 sha256=549d98793215bc354b3faf5eb7a37b10ac530be44e11da67a6b0d5315b978dab
  Stored in directory: /Users/BenjaminLee/Library/Caches/pip/wheels/29/7f/c4/4fba79502ea438c55740cfddce1b8f317ce3078f8913bae1fc
Successfully built librtd
Installing collected packages: docopt, librtd
Successfully installed docopt-0.6.2 librtd-0.0.1
WARNING: You are using pip version 20.1; however, version 20.2 is available.
You should consider upgrading via the '/Users/BenjaminLee/.virtualenvs/corona/bin/python3.7 -m pip install --upgrade pip' command.
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ rtd
Traceback (most recent call last):
  File "/Users/BenjaminLee/.virtualenvs/corona/bin/rtd", line 5, in <module>
    from cli_wrapper import cli_wrapper
ModuleNotFoundError: No module named 'cli_wrapper'
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ pip install ../librtd/librtd-py^C
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ python
Python 3.7.7 (default, Mar 18 2020, 19:38:56)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import librtd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'librtd'
>>>
KeyboardInterrupt
>>>
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ pip uninstall ../librtd/librtd-py
ERROR: You must give at least one requirement to uninstall (see "pip help uninstall")
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ pip uninstall librtd
Found existing installation: librtd 0.0.1
Uninstalling librtd-0.0.1:
  Would remove:
    /Users/BenjaminLee/.virtualenvs/corona/bin/rtd
    /Users/BenjaminLee/.virtualenvs/corona/lib/python3.7/site-packages/cli.cpython-37m-darwin.so
    /Users/BenjaminLee/.virtualenvs/corona/lib/python3.7/site-packages/librtd-0.0.1.dist-info/*
    /Users/BenjaminLee/.virtualenvs/corona/lib/python3.7/site-packages/librtdpy.cpython-37m-darwin.so
Proceed (y/n)? y
  Successfully uninstalled librtd-0.0.1
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ pip install -e ../librtd/librtd-py
Obtaining file:///Users/BenjaminLee/Desktop/Python/Research/librtd/librtd-py
Requirement already satisfied: docopt in /Users/BenjaminLee/.virtualenvs/corona/lib/python3.7/site-packages (from librtd==0.0.1) (0.6.2)
Installing collected packages: librtd
  Running setup.py develop for librtd
Successfully installed librtd
WARNING: You are using pip version 20.1; however, version 20.2 is available.
You should consider upgrading via the '/Users/BenjaminLee/.virtualenvs/corona/bin/python3.7 -m pip install --upgrade pip' command.
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯ rtd
Usage:
rtd <k> <input> [<output>] [--reverse-complement|--pairwise]
rtd (-h | --help)
rtd --version
~/D/P/R/coronavirus_genome_phylogeny ❯❯❯

Any idea why that would be?

Pebaz commented 4 years ago

Ah yes, I am unsure of the absolute root cause for this but one thing I do know is that Nimporter libs cannot be installed from source. You have to compile a Wheel first using python setup.py bdist_wheel and then upload that to PyPi/etc. From what I can see in the terminal session, you are trying to install it from source (meaning compiling Nim source to C, which would then compile to a Python extension). While is is definitely possible, it is only possible for people who have the Nim compiler installed. Since you are trying from (outside?) the virtual environment, this could be what is causing issues.

Recommended next debugging step: From within the venv, compile a Wheel and then outside (or on another machine): pip install /path/to/wheel.whl which should have the already-compiled C sources, which should essentially be Pip copying and pasting them into site-packages, etc.

Let me know if this doesn't work and good luck!

Pebaz commented 3 years ago

Closing due to inactivity. Let me know if I can be of further help!