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

conda_install should automatically escape args when they contain version constraints #311

Closed
smarie opened this issue Apr 20, 2020 · 0 comments · Fixed by #312
Closed

conda_install should automatically escape args when they contain version constraints #311

smarie opened this issue Apr 20, 2020 · 0 comments · Fixed by #312

Comments

@smarie
Copy link
Contributor

smarie commented Apr 20, 2020

In Session.conda_install one reads this example:

session.conda_install('--channel=conda-forge', 'dask==2.1.0')

Now consider that we tweak it very lightly:

session.conda_install('--channel=conda-forge', 'dask>2.0.0')

Running it, at least on windows, will

  • not take into account the constraint ">2.0.0"
  • write a nice but completely useless file named "2.0.0" in the working dir, containing the installation log.

Even worse: reverting the sign ('dask<2.0.0') yields an error:

Command conda install --yes --prefix C:\......\.nox\tests-2-7 --channel=conda-forge dask<2.0.0 failed with exit code 1:
The system cannot find the file specified.
Traceback (most recent call last):
  ...
  File "C:\_dev\python_ws\_Libs_OpenSource\nox\nox\sessions.py", line 293, in conda_install
    **kwargs
  File "C:\_dev\python_ws\_Libs_OpenSource\nox\nox\sessions.py", line 246, in _run
    return nox.command.run(args, env=env, paths=self.bin_paths, **kwargs)
  File "C:\_dev\python_ws\_Libs_OpenSource\nox\nox\command.py", line 125, in run
    raise CommandFailed("Returned code {}".format(return_code))
nox.command.CommandFailed: Returned code 1

This is of course because the > and < operators are handled by the shell and should be escaped. I'll try to propose some fix.

smarie pushed a commit to smarie/nox that referenced this issue Apr 20, 2020
theacodes pushed a commit that referenced this issue Jun 24, 2020
…d when needed. (#312)

* `conda_install` and `install` args are now automatically double-quoted when they contain a `<` or a `>`. Fixes #311

* Added a test for the double-quoting fix

* Black-ened

* Improving coverage: added some tests and improved error checking in _dblquote_pkg_install_arg

* Blackened

* Fixed mypy error

* Fixed test

* Now double-quoting arguments only for `conda_install`, not `install`. Apparently, `pip` does not need it.

* Fixed mock error in test

* blackened

* Fixed lint error and code review related mod of comments

Co-authored-by: Sylvain MARIE <sylvain.marie@se.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant