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

Document how to contribute to nox with conda (from Windows) #234

Closed
tswast opened this issue Aug 6, 2019 · 7 comments
Closed

Document how to contribute to nox with conda (from Windows) #234

tswast opened this issue Aug 6, 2019 · 7 comments

Comments

@tswast
Copy link
Contributor

tswast commented Aug 6, 2019

How would this feature be useful?

From the discussion at #224 (comment), it can be confusing how run the test suite from Windows when conda is the only available Python executable.

Describe the solution you'd like

Document the steps to setup a conda environment suitable for nox development.

  • Install Miniconda3.
  • Add conda-forge channel. https://conda-forge.org/
  • Create a conda environment.
  • Activate a conda environment.
  • Install dependencies that are available via conda with conda install --file requirements-conda-test.txt
  • Install contexter with pip and --no-deps.
  • Install nox in edit mode and --no-deps.

Describe alternatives you've considered

Encourage people to use python.org binaries on Windows, instead.

@tswast
Copy link
Contributor Author

tswast commented Aug 6, 2019

There are also some known issues when using conda. For example, I couldn't have spaces in of the directories used in the path where I'm running nox. https://stackoverflow.com/a/44310342/101923

@tswast
Copy link
Contributor Author

tswast commented Aug 6, 2019

@schuderer Let's continue the conda discussion here. I was able to get the tests sessions to pass locally on my conda instance, though I'm also having problems with the conda_tests sessions. Mine seem to do with multiple Python binaries on the PATH environment variable.

@schuderer
Copy link
Contributor

Thanks Tim! Wanted to let you know that I'm not ignoring you. I will have a chance to retest on Windows about a week or so from now. I will post the console output then, as well as checking whether I also have multiple binaries in the PATH.

@schuderer
Copy link
Contributor

schuderer commented Aug 21, 2019

Here's some input/feedback on the proposed instructions.

I tested the setup steps listed in the first post:

(Skipped installing miniconda, already have Anaconda installed. (conda --version = conda 4.7.11))

$ git clone https://github.com/theacodes/nox.git
$ cd nox
$ conda create -n nox conda
$ conda activate nox
(nox) $ python --version
Python 3.7.3
(nox) $ conda config --add channels conda-forge
(nox) $ conda config --set channel_priority strict
(nox) $ conda install --file requirements-conda-test.txt
(nox) $ pip install contexter --no-deps
(nox) $ pip install -e . --no-deps
Successfully installed nox
(nox) $ nox
pkg_resources.DistributionNotFound: The 'argcomplete<2.0,>=1.9.4' distribution was not found and is required by nox

To get the missing packages, I then tried:

(nox) $ pip install -r requirements-test.txt
(nox) $ nox
pkg_resources.DistributionNotFound: The 'argcomplete<2.0,>=1.9.4' distribution was not found and is required by nox

Installing nox in editable mode without the --no-deps option appears to fix the missing requirement:

(nox) $ pip uninstall nox
(nox) $ pip install -e .
Successfully installed argcomplete-1.10.0 nox
(nox) $ nox

Only now the conda tests can't find argcomplete:

_____________________________________ ERROR collecting tests/test__option_set.py ______________________________________
ImportError while importing test module 'C:\dev\code\git\nox\tests\test__option_set.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests\test__option_set.py:20: in <module>
    from nox import _option_set
nox\__init__.py:15: in <module>
    from nox._options import noxfile_options as options
nox\_options.py:20: in <module>
    from nox import _option_set
nox\_option_set.py:24: in <module>
    import argcomplete  # type: ignore
E   ModuleNotFoundError: No module named 'argcomplete'

I thought the missing argcomplete was just an omission in requirements-conda-test.txt, but the following also fails with the same error:

(nox) $ pip uninstall argcomplete
(nox) $ conda install argcomplete
(nox) $ nox -s conda_tests-3.6

For what it's worth, trying to re-run conda_tests-3.7 fails now:

(nox) C:\dev\code\git\nox>nox -s conda_tests-3.7
nox > Running session conda_tests-3.7
nox > Session conda_tests-3.7 raised exception PermissionError(13, 'Access is denied')
Traceback (most recent call last):
  File "c:\dev\code\git\nox\nox\sessions.py", line 405, in execute
    self._create_venv()
  File "c:\dev\code\git\nox\nox\sessions.py", line 392, in _create_venv
    self.venv.create()
  File "c:\dev\code\git\nox\nox\virtualenv.py", line 180, in create
    if not self._clean_location():
  File "c:\dev\code\git\nox\nox\virtualenv.py", line 133, in _clean_location
    shutil.rmtree(self.location)
  File "C:\Users\myuser\.conda\envs\nox\lib\shutil.py", line 513, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Users\myuser\.conda\envs\nox\lib\shutil.py", line 392, in _rmtree_unsafe
    _rmtree_unsafe(fullname, onerror)
  File "C:\Users\myuser\.conda\envs\nox\lib\shutil.py", line 397, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\Users\myuser\.conda\envs\nox\lib\shutil.py", line 395, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 5] Access is denied: 'C:\\dev\\code\\git\\nox\\.nox\\conda_tests-3-7\\DLLs\\pyexpat.pyd'
nox > Session conda_tests-3.7 failed.

I do have only one interpreter in the PATH:

(nox) C:\dev\code\git\nox>where python
C:\Users\myuser\.conda\envs\nox\python.exe

I'm unfortunately out of time for now, but still hope this input helps.

@tswast
Copy link
Contributor Author

tswast commented Aug 21, 2019

Thanks. argcomplete is a new dependency, added in #228. This is also a problem for the conda-forge nox-feedstock. conda-forge/nox-feedstock#3

There is a package for argcomplete in conda-forge: https://github.com/conda-forge/argcomplete-feedstock. We'll want to add argcomplete to requirements-conda-test.txt to fix the issue you are encountering.

Installing nox in editable mode without the --no-deps option appears to fix the missing requirement.

Warning: that command installs dependencies via pip instead of conda, which can break your conda installation if any packages with C/C++ extensions are installed via pip.

@tswast
Copy link
Contributor Author

tswast commented Aug 21, 2019

PermissionError: [WinError 5] Access is denied: 'C:\\dev\\code\\git\\nox\\.nox\\conda_tests-3-7\\DLLs\\pyexpat.pyd' nox > Session conda_tests-3.7 failed.

This appears to be a common Windows error.

  • *.pyd files are DLLs.
  • Windows raises an error if you try to modify a DLL file that is currently in use.

I don't know why that file would currently be in use. It appears as though a reboot is usually required to remove / modify DLLs, but there are some steps we could take, instead: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-updates

Perhaps on Windows nox needs to move old session environments to the recycle bin instead of trying to remove them?

@theacodes
Copy link
Collaborator

This issue has gone stale, so I'm going to close it for now. If it's still something someone is interested in, feel free to comment and we can re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants