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

Dependency that is only compatible/needed with/in python 2 in setup.py #147

Closed
prometheanfire opened this issue Apr 6, 2015 · 11 comments
Closed

Comments

@prometheanfire
Copy link

this causes pip install to fail (at least with my py3.4 system)

@colonelpanic8
Copy link
Collaborator

This is working for me on my OSX yosemite machines, and it has not caused in the travis linux (debian, i think) builds. Can you give me some more details about your system?

@colonelpanic8
Copy link
Collaborator

also, can you clarify what the of this issue means?

@prometheanfire
Copy link
Author

 pip install --user --install-option="--install-scripts=/home/mthode/bin" vcrpy
Downloading/unpacking vcrpy
  Downloading vcrpy-1.4.0.tar.gz
  Running setup.py (path:/tmp/pip_build_mthode/vcrpy/setup.py) egg_info for package vcrpy

Requirement already satisfied (use --upgrade to upgrade): PyYAML in /usr/lib64/python3.4/site-packages (from vcrpy)
Requirement already satisfied (use --upgrade to upgrade): mock in /usr/lib64/python3.4/site-packages (from vcrpy)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib64/python3.4/site-packages (from vcrpy)
Requirement already satisfied (use --upgrade to upgrade): contextlib2 in /usr/lib64/python3.4/site-    packages (from vcrpy)
Downloading/unpacking wrapt (from vcrpy)
  Downloading wrapt-1.10.4.tar.gz
  Running setup.py (path:/tmp/pip_build_mthode/wrapt/setup.py) egg_info for package wrapt

Downloading/unpacking backport-collections (from vcrpy)
  Downloading backport_collections-0.1.tar.gz
  Running setup.py (path:/tmp/pip_build_mthode/backport-collections/setup.py) egg_info for     package backport-collections

Installing collected packages: vcrpy, wrapt, backport-collections
  Running setup.py install for vcrpy

  Running setup.py install for wrapt
    building 'wrapt._wrappers' extension
    x86_64-pc-linux-gnu-gcc -pthread -fPIC -I/usr/include/python3.4 -c src/_wrappers.c -o build/temp.linux-x86_64-3.4/src/_wrappers.o
    x86_64-pc-linux-gnu-gcc -pthread -shared build/temp.linux-x86_64-3.4/src/_wrappers.o -L/usr/lib64 -lpython3.4 -o build/lib.linux-x86_64-3.4/wrapt/_wrappers.cpython-34.so

  Running setup.py install for backport-collections
      File "/home/mthode/.local/lib64/python3.4/site-packages/backport_collections.py", line 368
        print class_definition
                             ^
    SyntaxError: invalid syntax


Successfully installed vcrpy wrapt backport-collections
Cleaning up...

@kevin1024
Copy link
Owner

ah, probably just needs something like this:

# setup.py

install_requires = ['somelib1', 'somelib2']

try:
    import collections
except ImportError:
    install_requires.append('backport-collections')

setup(
    ...
    install_requires=install_requires,
    ...
)

@prometheanfire
Copy link
Author

Ya, something like that could work. Either that or checking the python version and using that to append.

@colonelpanic8
Copy link
Collaborator

yeah but then the question is: why isn't this failing in travis?

@prometheanfire
Copy link
Author

The install technically succeeds, I'm guessing other protections protect the tests from importing this lib.

@kevin1024
Copy link
Owner

Maybe travis's pip has a #!/bin/python2 at the start.

@colonelpanic8 colonelpanic8 changed the title p2 only dep listed (backport_collections) Dependency that is only compatible/needed with/in python 2 in setup.py May 19, 2015
@graingert
Copy link
Collaborator

you should use:

extras_require = {
    ':python_version<=2.4': ['contextlib2',],
    ':python_version<=2.6': ['backport_collections',],
    ':python_version<=3.2': ['mock'],
}

in the setup.py

@colonelpanic8
Copy link
Collaborator

ah nice didnt know that you could do that.

Why ':python_versioin<=3.3': ['mock'] ?

I just used mock in python 3.4

 imalison  ~  Projects  dispatch  python3.4                                                                                                                                                                                                                                                                                                                       mf
Python 3.4.3 (default, Apr  7 2015, 08:05:21)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mock
>>> mock.Mock().test
<Mock name='mock.test' id='4436658048'>

And things worked fine.

@graingert
Copy link
Collaborator

You're supposed to use unittest.mock on python 3.3+

colonelpanic8 added a commit that referenced this issue Jul 2, 2015
use conditional requirements for backport libraries closes #147
gokul-uf referenced this issue in openai/baselines Dec 16, 2017
fixes #146

A better (more involved) solution might be to check for a TensorFlow installation manually in setup.py and deal with that accordingly.
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

4 participants