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

warn if user creates an environment that would conflict with an internal directory (dist/distshare/packaging) #696

Open
rpkilby opened this issue Dec 5, 2017 · 6 comments
Assignees
Labels
area:testenv-creation feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.

Comments

@rpkilby
Copy link
Member

rpkilby commented Dec 5, 2017

Problem

Some testenv names may unintentionally conflict with other directories created in the toxworkdir. For example, I recently wanted to add a specific build for testing the distribution, naturally naming it dist. My tox.ini looked something like:

[tox]
envlist = py27,py34,py35,py36,dist

[testenv]
commands = coverage run setup.py test
usedevelop = True

[testenv:dist]
commands = python setup.py test
usedevelop = False

Running tox -e dist generating the following error, which was a little confusing:

Traceback (most recent call last):
  File "./.venv/bin/tox", line 11, in <module>
    sys.exit(cmdline())
  File "./.venv/lib/python3.6/site-packages/tox/session.py", line 40, in main
    retcode = Session(config).runcommand()
  File "./.venv/lib/python3.6/site-packages/tox/session.py", line 392, in runcommand
    return self.subcommand_test()
  File "./.venv/lib/python3.6/site-packages/tox/session.py", line 567, in subcommand_test
    self.installpkg(venv, path)
  File "./.venv/lib/python3.6/site-packages/tox/session.py", line 503, in installpkg
    self.resultlog.set_header(installpkg=py.path.local(path))
  File "./.venv/lib/python3.6/site-packages/tox/result.py", line 25, in set_header
    md5=installpkg.computehash("md5"),
  File "./.venv/lib/python3.6/site-packages/py/_path/local.py", line 232, in computehash
    f = self.open('rb')
  File "./.venv/lib/python3.6/site-packages/py/_path/local.py", line 361, in open
    return py.error.checked_call(open, self.strpath, mode)
  File "./.venv/lib/python3.6/site-packages/py/_error.py", line 86, in checked_call
    raise cls("%s%r" % (func.__name__, args))
py.error.ENOENT: [No such file or directory]: open('./.tox/dist/package-0.0.1.zip', 'rb')

The issue was that the sdist was being built in the dist directory, which conflicted with the dist testenv.

Proposed changes

  • Change the default envdir to something like {toxworkdir}/venvs/{envname}. idk if this would be considered backwards incompatible.
  • Raise a more infromative exception that complains about known bad testenv names, suggesting that they either change the name or set envdir to {toxworkdir}/venvs/{envname}.

This isn't exactly a high priority issue or anything. The immediate fix is to just change the envdir, as demonstrated above.

@gaborbernat gaborbernat added area:testenv-creation feature:change something exists already but should behave differently labels Dec 5, 2017
@gaborbernat
Copy link
Member

Fair point, I don't think this would be backward incompatible upfront as the workdir is kinda private; could prove breaking with users scripts. I would probably prefer having the other way around, e.g. having a .tmp folder in the workdir where we build the dist, and wheels and so on.

@asottile
Copy link
Contributor

asottile commented Dec 7, 2017

fwiw, the longer we make the paths for envdirs the more likely we'll run into shebang length limits on posix platforms

@obestwalter
Copy link
Member

obestwalter commented Jan 23, 2018

I am -1 on changing this for the same reason that @asottile mentioned. The 80 char limit is there to stay for a long time, so we better make sure we don't add to the length of the path more than we already do.

To prevent the above error and make it clearer to users we could add a check that makes sure that no envname is chosen that is "reserved" by tox. This is dist and logs so far and I don't think that list will grow much in the future.

@rpkilby
Copy link
Member Author

rpkilby commented Jan 28, 2018

Just as a note, tox should probably check conflicting paths instead of conflicting names. eg, if a user sets envdir to {toxworkdir}/venvs/{envname}, a dist env would no longer conflict with {toxworkdir}/dist.

altendky added a commit to altendky/canmatrix that referenced this issue Sep 7, 2018
@altendky
Copy link

altendky commented Sep 7, 2018

I haven't dug much so this may be a silly idea. Instead of .tox/{dist,log} have those in .tox-meta or such and leave .tox for purely envs?

But yes, at least an error message on anything using those non-env directories.

ebroecker pushed a commit to ebroecker/canmatrix that referenced this issue Sep 7, 2018
* Add pytest and tox

#184

* Try again for both 3.4 and 3.7 on Travis

* Add PyPy and PyPy3.5 on Travis

* Trigger for AppVeyor

* Try again on build version setting for AppVeyor

* add missing get_version.py

* Separate wheel build on AppVeyor

* Print sys.version for each Tox env

* Drop 32/64 on AppVeyor

* fix

* Add pypy/pypy3 for AppVeyor

* Print sys.version for the AppVeyor virtualenv

* Switch to 3.7/venv on AppVeyor

* Allow pypy3 to fail on AppVeyor for now

Could fork https://github.com/kirbyfan64/python.pypy

* fix

* fix

* Trigger for AppVeyor

* Attempt to add wheel job on Travis

* Revert "Attempt to add wheel job on Travis"

This reverts commit f308893.

* Try again for a wheel job on Travis

* Add coverage.py/codecov.io

* Add back old tests on Travis

* and old tests for 2.7 too

* correct old tests for 3.7

* sdist as well

* and collect sdist as well on AppVeyor

* set envdir for dist tox target

tox-dev/tox#696

* CI build dist first

* kick ci
@gaborbernat
Copy link
Member

I would say that we'll keep things as they are for backward compatibility. However, we'll warn if you try to define an environment with the reserved name.

@gaborbernat gaborbernat changed the title Change 'envdir' default warn if user creates an environment that would conflict with an internal directory (dist/distshare/packaging) Sep 8, 2018
@gaborbernat gaborbernat self-assigned this Sep 8, 2018
@gaborbernat gaborbernat added feature:new something does not exist yet, but should and removed feature:change something exists already but should behave differently labels Sep 8, 2018
@gaborbernat gaborbernat added this to the 3.5 milestone Sep 18, 2018
@gaborbernat gaborbernat modified the milestones: 3.5, 3.6 Oct 8, 2018
@gaborbernat gaborbernat modified the milestones: 3.6, 3.7 Dec 16, 2018
@gaborbernat gaborbernat added the help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted. label May 3, 2019
@gaborbernat gaborbernat modified the milestones: 3.7, 4.1 Jan 13, 2022
@gaborbernat gaborbernat removed this from the P-1 milestone Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:testenv-creation feature:new something does not exist yet, but should help:wanted Issues that have been acknowledged, a solution determined and a PR might likely be accepted.
Projects
None yet
Development

No branches or pull requests

5 participants