tox4: provide nicer error message when `setup.py` is missing /`tox.ini` is missing

Created on 12 Apr 2021  ·  4Comments  ·  Source: tox-dev/tox

Executing tox / tox4 in an empty directory...

/tmp/tox4.test via 🐍 v3.6.9 (2001)
❯ tox
ERROR: tox config file (either pyproject.toml, tox.ini, setup.cfg) not found

/tmp/tox4.test via 🐍 v3.6.9 (2001)
❯ tox4dev
ROOT: No tox.ini or setup.cfg or pyproject.toml found, assuming empty tox.ini at /tmp/tox4.test
.pkg: get_requires_for_build_sdist> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
.pkg: prepare_metadata_for_build_wheel> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
py: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/tox4.test/.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz
Processing ./.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /tmp/tox4.test/.tox/4/py/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-4sa5c3c7/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-4sa5c3c7/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-w8btfcr4
         cwd: /tmp/pip-req-build-4sa5c3c7/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.8/tokenize.py", line 392, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-4sa5c3c7/setup.py'
    ----------------------------------------
WARNING: Discarding file:///tmp/tox4.test/.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
py: exit 1 (0.86 seconds) /tmp/tox4.test> python -I -m pip install --force-reinstall --no-deps /tmp/tox4.test/.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz pid=19046
.pkg: _exit> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
  py: FAIL code 1 (1.30 seconds)
  evaluation failed :( (1.33 seconds)

Executing tox/tox4 in an empty directory but with a tox.ini.

/tmp/tox4.test via 🐍 v3.6.9 (2001)
❯ echo "[tox]" > tox.ini

/tmp/tox4.test via 🐍 v3.6.9 (2001)
❯ tox
ERROR: No pyproject.toml or setup.py file found. The expected locations are:
  /tmp/tox4.test/pyproject.toml or /tmp/tox4.test/setup.py
You can
  1. Create one:
     https://tox.readthedocs.io/en/latest/example/package.html
  2. Configure tox to avoid running sdist:
     https://tox.readthedocs.io/en/latest/example/general.html
  3. Configure tox to use an isolated_build

/tmp/tox4.test via 🐍 v3.6.9 (2001)
❯ tox4dev
.pkg: get_requires_for_build_sdist> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
.pkg: prepare_metadata_for_build_wheel> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
py: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/tox4.test/.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz
Processing ./.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /tmp/tox4.test/.tox/4/py/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-r75kiifg/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-r75kiifg/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-na8s_jx2
         cwd: /tmp/pip-req-build-r75kiifg/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.8/tokenize.py", line 392, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-req-build-r75kiifg/setup.py'
    ----------------------------------------
WARNING: Discarding file:///tmp/tox4.test/.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
py: exit 1 (0.82 seconds) /tmp/tox4.test> python -I -m pip install --force-reinstall --no-deps /tmp/tox4.test/.tox/4/.pkg/dist/UNKNOWN-0.0.0.tar.gz pid=19227
.pkg: _exit> python /home/jugmac00/Projects/tox/src/tox/util/pep517/backend.py True setuptools.build_meta __legacy__
  py: FAIL code 1 (1.29 seconds)
  evaluation failed :( (1.31 seconds)
normal

All 4 comments

This is a duplicate of https://github.com/tox-dev/tox/issues/1964. I don't think we should error when either is missing. We already assume empty tox.ini if tox.ini missing, we should assume no package if pyproject.toml missing, (or if present, but declares setuptools as backend but not setup.cfg/setup.py).

FYI: the reason I'd like no setup.py/setup.cfg/tox.ini to work is to be able to use tox on projects that otherwise don't use tox. E.g. I can go to a random project repository and say: tox -e py39 --develop and creates to me a working python 3.9 environment of that project. If it's an app just the virtual env (in this case I might do tox -e py39 -x testenv.deps=requirements.txt) and if it's not build and install the package in question.

While I knew --develop, this is new to me! tox -e py39 -x testenv.deps=requirements.txt

We should add this to the documentation, maybe in a tips & tricks or did you know? section... let's see what the docs look like when #1914 lands

Yeah, will be part of that.

Was this page helpful?
0 / 5 - 0 ratings