explosion / srsly

🦉 Modern high-performance serialization utilities for Python (JSON, MessagePack, Pickle)
MIT License
435 stars 31 forks source link

Bug: Cannot install if Cython is not already installed #46

Closed DomHudson closed 3 years ago

DomHudson commented 3 years ago

Summary

The latest version 1 tag (v1.0.5) altered setup.py to directly import from Cython. This means that install fails with No module named 'Cython' unless you have manually installed it.

Projects that use srsly as a dependency will need to be edited to manually install Cython now, whereas before setuptools handed this install.

This also effects version 2 and the master branch.

Edit

I've looked into this and I think the expectation is that pyproject.toml will handle this cython pre-install. I am using python 3.6.5, I suspect this python version (or its setuptools) is not reading this file.

Reproduce

$ docker run -w /home/circleci circleci/python:3.6.5 bash -c "python3 -m venv venv; . venv/bin/activate; pip install srsly==1.0.5" 
Collecting srsly==1.0.5
  Downloading https://files.pythonhosted.org/packages/c7/08/abe935f33b69a08d365b95e62b47ef48f93a69ab734e623248a8a4079ecb/srsly-1.0.5.tar.gz (86kB)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-vjnjnimo/srsly/setup.py", line 11, in <module>
        from Cython.Build import cythonize
    ModuleNotFoundError: No module named 'Cython'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-vjnjnimo/srsly/

I give a docker route to reproduce to match the environment perfectly.

Entities

https://github.com/explosion/srsly/pull/44 https://github.com/explosion/srsly/blob/v1.0.5/setup.py#L11

adrianeboyd commented 3 years ago

Yes, we've decided to have the setup rely on PEP 517/518, which should be implemented as of pip 19.0.

It should be straightforward to upgrade pip in a venv, so I think this should work instead:

$ docker run -w /home/circleci circleci/python:3.6.5 bash -c "python3 -m venv venv; . venv/bin/activate; pip install -U pip setuptools; pip install srsly==1.0.5"

If you can't upgrade pip or setuptools for some reason, you'll need to manage the build dependencies separately, through an additional step like pip install -r requirements.txt or something along those lines.

Most people are installing srsly as a dependency of spacy and we've tried to add the pip upgrade step to the spacy install instructions in as many places as possible, but we haven't updated the srsly README, which would also be a good idea.

DomHudson commented 3 years ago

Thanks for your help!

In case this pops up in someone's search:

https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support