tox-dev / tox-pipenv

A pipenv plugin for Tox
MIT License
124 stars 30 forks source link

Having an Issue running Tox #54

Closed JHowell45 closed 5 years ago

JHowell45 commented 5 years ago

Whenever I try to run pipenv run tox it tries to run /venv/bin/python -m pipenv graph. Basically the same as running pipenv inside pipenv failing because pipenv isn't a dependency. I have a temporary work around by installing pipenv as a --dev dependency, but was wondering if this was an issue with how tox gets executed from within pipenv due to how tox-pipenv works?

jacobhowell@Jacobs-MacBook-Pro-2 ~/N/nal-ml> pipenv run tox
Loading .env environment variables…
ERROR: invocation failed (exit code 1), logfile: /Users/jacobhowell/NotActivelyLooking/nal-ml/.tox/py36/log/py36-4.log
ERROR: actionid: py36
msg: envreport
cmdargs: ['/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/bin/python3.6', '-m', 'pipenv', 'graph']

ERROR:  Traceback (most recent call last):
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/pipenv/vendor/pipdeptree.py", line 16, in <module>
    from pipenv.vendor.pip_shims import get_installed_distributions, FrozenRequirement
ModuleNotFoundError: No module named 'pipenv'

Traceback (most recent call last):
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/bin/tox", line 11, in <module>
    sys.exit(run_main())
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox/session.py", line 40, in run_main
    main(args)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox/session.py", line 46, in main
    retcode = Session(config).runcommand()
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox/session.py", line 415, in runcommand
    return self.subcommand_test()
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox/session.py", line 610, in subcommand_test
    self.runenvreport(venv)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox/session.py", line 622, in runenvreport
    packages = self.hook.tox_runenvreport(venv=venv, action=action)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/pluggy/hooks.py", line 258, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/pluggy/manager.py", line 67, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/pluggy/manager.py", line 61, in <lambda>
    firstresult=hook.spec_opts.get('firstresult'),
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/pluggy/callers.py", line 201, in _multicall
    return outcome.get_result()
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/pluggy/callers.py", line 76, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/pluggy/callers.py", line 180, in _multicall
    res = hook_impl.function(*args)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox_pipenv/plugin.py", line 167, in tox_runenvreport
    output = venv._pcall(args, venv=False, action=action, cwd=basepath)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox/venv.py", line 409, in _pcall
    redirect=redirect, ignore_ret=ignore_ret)
  File "/Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/lib/python3.6/site-packages/tox/session.py", line 212, in popen
    "%s (see %s)" % (invoked, outpath), ret)
tox.InvocationError: InvocationError for command /Users/jacobhowell/.local/share/virtualenvs/nal-ml-OzYvifs4/bin/python3.6 -m pipenv graph (see /Users/jacobhowell/NotActivelyLooking/nal-ml/.tox/py36/log/py36-4.log) (exited with code 1)
tonybaloney commented 5 years ago

This plugin should be used outside of pipenv. Don’t use pipenv run tox because it’ll cause the loop you saw. Just call tox within the venv

JHowell45 commented 5 years ago

So should I run something pipenv shell --> tox or just run tox from the application directory?

JHowell45 commented 5 years ago

nm I found out haha, I need to run pipenv shell and then tox. Why is that by the way if you don't mind me asking?

tonybaloney commented 5 years ago

Pipenv doesn’t have a Python API (by design) so this plugin has to call it on the command line and also set a collection of environment variables to make it behave in a specific way.

JHowell45 commented 5 years ago

Ahh ok thank you. For some reason now when running pipenv run tox it works, i think it was due to when I ran pipenv shell, tox it may have fixed something which is weird, from now on I'll switch to using pipenv shell, tox