csurfer / rake-nltk

Python implementation of the Rapid Automatic Keyword Extraction algorithm using NLTK.
https://csurfer.github.io/rake-nltk
MIT License
1.06k stars 150 forks source link

Building wheel fails due post-install hook #30

Open hiir opened 6 years ago

hiir commented 6 years ago

Hello,

When trying to build a wheel for rake-nltk package it fails if system does not have nltk package installed explicitly.

  1. create empty virtual environment & switch to it
  2. issue pip wheel command:

    pip wheel rake-nltk
    ...
    File "/tmp/pip-wheel-u4cxytr5/rake-nltk/setup.py", line 17, in _post_install        
      import nltk                                                                       
    ModuleNotFoundError: No module named 'nltk'                                           
    
    ----------------------------------------                                              
    Failed building wheel for rake-nltk                                                   
    Running setup.py clean for rake-nltk                                                  
    Failed to build rake-nltk                                                               
    ERROR: Failed to build one or more wheels                                               

Apparently during bdist or bdist_wheel commands distutils also does an "fake" install -- and apparently without installing requirements before.

From docs: https://docs.python.org/3/distutils/builtdist.html

then the Distutils builds my module distribution (the Distutils itself in this case), does a “fake” installation

I am not familiar with distutils enough to know if it is possible to distinguish such "fake" install from real install.

Our use case is to build wheels during packaging progress on build server and then later use these wheels to speed up deployment. There is no reason to install python packages on build server itself and in some cases it would be hard to identify requirements before -- for an example if some other package has rake-nltk as install_requirement in setup.py.

This problem would not exists if rake-nltk would be available as wheel on pypi (but then package installation would not automatically download "punkt" and "stopwords").

kiranmahto commented 5 years ago

Is this issue has any solution

mnvoh commented 5 years ago

Running these before installing rake-nltk fixed the problem for me. All of them may or may not be required:

pip3 install -U nltk
pip3 install -U numpy
python3 -m nltk.downloader all
pip3 install rake-nltk
jcbrockschmidt commented 3 years ago

Note that while rake-nltk will be successfully installed by falling back on setup.py install in pip version 20 and prior, this fallback will be deprecated in version 21. Here's the deprecation warning:

  DEPRECATION: rake-nltk was installed using the legacy 'setup.py install' method, because a wheel could not be built for it.
pip 21.0 will remove support for this functionality. A possible replacement is to fix the wheel build issue reported above.
You can find discussion regarding this at https://github.com/pypa/pip/issues/8368.
kuraga commented 3 years ago

Facing the same issue.

Leave downloading datasets to user!