stitchfix / pyxley

Python helpers for building dashboards using Flask and React
MIT License
2.27k stars 257 forks source link

setup.py distutils problem (+fix with setuptools) for ignored "install_requires" #6

Closed ianozsvald closed 9 years ago

ianozsvald commented 9 years ago

Using a fresh clone of pyxley today in Python 2.7 (using a freshly-updated Anaconda Python 2.7 environment) I see a problem with setup.py:

pyxley $ python setup.py install
.../lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'install_requires'
...
<rest of setup completes successfully>

This leads to the following pyreact error:

pyxley/examples/datamaps/project $ python app.py 
Traceback (most recent call last):
  File "app.py", line 10, in <module>
    from pyxley import UILayout
  .../lib/python2.7/site-packages/pyxley/__init__.py", line 1, in <module>
    import ui
  .../lib/python2.7/site-packages/pyxley/ui.py", line 1, in <module>
    from react_template import ReactComponent
  File .../lib/python2.7/site-packages/pyxley/react_template.py", line 1, in <module>
    from react import jsx
ImportError: No module named react

Swapping line 1 of setup.py from distutils to setuptools solves the issue:

#from distutils.core import setup
from setuptools import setup

and after a fresh install with python setup.py install the demo runs.

My knowledge of Python packaging is a bit patchy but I'm pretty sure setuptools is the normal way (nowadays, after all the other "normal ways" we've had along the way): https://docs.python.org/3/library/distutils.html "Most Python users will not want to use this module directly, but instead use the cross-version tools maintained by the Python Packaging Authority. In particular, setuptools is an enhanced alternative to distutils that provides: ... The recommended pip installer runs all setup.py scripts with setuptools, even if the script itself only imports distutils. Refer to the Python Packaging User Guide for more information."

For reference these are my versions:

In [2]: distutils.__version__
Out[2]: '2.7.10'
In [4]: setuptools.__version__
Out[4]: '17.1.1'

This explains+fixes the manual install in my other bug report https://github.com/stitchfix/pyxley/issues/5

nmkridler commented 9 years ago

Awesome, thanks for pointing this out. I'll update the setup.py.

nmkridler commented 9 years ago

Fixed! Thanks

darkn3rd commented 7 years ago

I did the following command: apt-get -yqqf install python-setuptools && easy_install pip && pip install --upgrade pip setuptools

And I got this output:

Running pip-9.0.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-dzZuxn/pip-9.0.1/egg-dist-tmp-H5oyYo
/usr/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'python_requires'
  warnings.warn(msg)
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.landscape.yml'
warning: no previously-included files found matching 'pip/_vendor/Makefile'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'dev-requirements.txt'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching '.github'
no previously-included directories found matching '.travis'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'contrib'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'