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

Running tests under nox is flaxy #348

Closed
jaraco opened this issue Jan 29, 2020 · 15 comments · Fixed by #513
Closed

Running tests under nox is flaxy #348

jaraco opened this issue Jan 29, 2020 · 15 comments · Fixed by #513

Comments

@jaraco
Copy link
Member

jaraco commented Jan 29, 2020

I'm trying to run the tests. I created a virtualenv for installing nox and installed the prescribed version, but the tests fail:

pipx master $ python -m venv .nox/.nox                                                                                                                                    
pipx master $ .nox/.nox/bin/pip install --use-pep517 setuptools 'git+https://github.com/cs01/nox.git@5ea70723e9e6#egg=nox'                                                
Requirement already satisfied: setuptools in ./.nox/.nox/lib/python3.8/site-packages (41.2.0)
Collecting nox from git+https://github.com/cs01/nox.git@5ea70723e9e6#egg=nox
  Cloning https://github.com/cs01/nox.git (to revision 5ea70723e9e6) to /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-cr4qr61n/nox
  Running command git clone -q https://github.com/cs01/nox.git /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-cr4qr61n/nox
  WARNING: Did not find branch or tag '5ea70723e9e6', assuming revision or ref.
  Running command git checkout -q 5ea70723e9e6
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting virtualenv>=14.0.0 (from nox)
  Using cached https://files.pythonhosted.org/packages/05/f1/2e07e8ca50e047b9cc9ad56cf4291f4e041fa73207d000a095fe478abf84/virtualenv-16.7.9-py2.py3-none-any.whl
Collecting py<2.0.0,>=1.4.0 (from nox)
  Using cached https://files.pythonhosted.org/packages/99/8d/21e1767c009211a62a8e3067280bfce76e89c9f876180308515942304d2d/py-1.8.1-py2.py3-none-any.whl
Collecting colorlog<4.0.0,>=2.6.1 (from nox)
  Using cached https://files.pythonhosted.org/packages/d7/00/defed2a2eb8e289a0b6f29b3bcc52b42a75ce7cb14a84687c4c54d58f08e/colorlog-3.2.0-py2.py3-none-any.whl
Collecting argcomplete<2.0,>=1.9.4 (from nox)
  Using cached https://files.pythonhosted.org/packages/82/7d/455e149c28c320044cb763c23af375bd77d52baca041f611f5c2b4865cf4/argcomplete-1.11.1-py2.py3-none-any.whl
Building wheels for collected packages: nox
  Building wheel for nox (PEP 517) ... done
  Created wheel for nox: filename=nox-2019.5.30-cp38-none-any.whl size=37908 sha256=7518b21327b772a2e9897ab52147d455d7c239bf138e56817c7da43cfe444e0a
  Stored in directory: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-ephem-wheel-cache-50xn9u3j/wheels/1d/aa/ed/a061887cc0a8c9bedfe294c95ff7f75ff6771ec85834ec35cc
Successfully built nox
Installing collected packages: virtualenv, py, colorlog, argcomplete, nox
Successfully installed argcomplete-1.11.1 colorlog-3.2.0 nox-2019.5.30 py-1.8.1 virtualenv-16.7.9
WARNING: You are using pip version 19.2.3, however version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
pipx master $ .nox/.nox/bin/python -m nox --session tests-3.8                                                                                                             
nox > Running session tests-3.8
nox > Creating venv using python3.8 in .nox/tests-3-8
nox > pip install -e . pytest pytest-cov
nox > pytest --cov=pipx --cov-config .coveragerc --cov-report= tests
========================================================================== test session starts ===========================================================================
platform darwin -- Python 3.8.1, pytest-5.3.4, py-1.8.1, pluggy-0.13.1
rootdir: /Users/jaraco/code/public/pipx
plugins: cov-2.8.1
collected 75 items                                                                                                                                                       

tests/test_animate.py ...                                                                                                                                          [  4%]
tests/test_completions.py .                                                                                                                                        [  5%]
tests/test_inject.py F.F                                                                                                                                           [  9%]
tests/test_install.py ..F...............                                                                                                                           [ 33%]
tests/test_list.py ..                                                                                                                                              [ 36%]
tests/test_main.py .......                                                                                                                                         [ 45%]
tests/test_pipx_metadata_file.py .....F                                                                                                                            [ 53%]
tests/test_reinstall_all.py .                                                                                                                                      [ 54%]
tests/test_run.py ...F......................                                                                                                                       [ 89%]
tests/test_runpip.py .                                                                                                                                             [ 90%]
tests/test_shared_libs.py ..                                                                                                                                       [ 93%]
tests/test_uninstall.py ..                                                                                                                                         [ 96%]
tests/test_uninstall_all.py .                                                                                                                                      [ 97%]
tests/test_upgrade.py .                                                                                                                                            [ 98%]
tests/test_upgrade_all.py .                                                                                                                                        [100%]Coverage.py warning: Data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.49499.016930' doesn't seem to be a coverage data file: Couldn't use data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.49499.016930': no such table: coverage_schema
Coverage.py warning: Data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.48749.385928' doesn't seem to be a coverage data file: Couldn't use data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.48749.385928': no such table: coverage_schema
Coverage.py warning: Data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.49498.790109' doesn't seem to be a coverage data file: Couldn't use data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.49498.790109': no such table: coverage_schema
Coverage.py warning: Data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.49496.557321' doesn't seem to be a coverage data file: Couldn't use data file '/Users/jaraco/code/public/pipx/.coverage.Karui-Tatchi.lan.49496.557321': no such table: coverage_schema


================================================================================ FAILURES ================================================================================
______________________________________________________________________________ test_simple _______________________________________________________________________________

pipx_temp_env = None, capsys = <_pytest.capture.CaptureFixture object at 0x108060700>

    def test_simple(pipx_temp_env, capsys):
        assert not run_pipx_cli(["install", "pycowsay"])
>       assert not run_pipx_cli(["inject", "pycowsay", "black"])
E       AssertionError: assert not 1
E        +  where 1 = run_pipx_cli(['inject', 'pycowsay', 'black'])

tests/test_inject.py:7: AssertionError
-------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------
  installed package pycowsay 0.0.0.1, Python 3.8.1
  These apps are now globally available
    - pycowsay
-------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------
  ERROR: Command errored out with exit status 1:
   command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_simple0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-wheel-jsaoxduv
       cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.8
  creating build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  running build_ext
  building 'regex._regex' extension
  creating build/temp.macosx-10.9-x86_64-3.8
  creating build/temp.macosx-10.9-x86_64-3.8/regex_3
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_simple0/subdir/pipxhome/venvs/pycowsay/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
  In file included from regex_3/_regex.c:48:
  /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for regex
    ERROR: Command errored out with exit status 1:
     command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_simple0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-g90akhho/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_simple0/subdir/pipxhome/venvs/pycowsay/include/site/python3.8/regex
         cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/
    Complete output (21 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.8
    creating build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    running build_ext
    building 'regex._regex' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/regex_3
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_simple0/subdir/pipxhome/venvs/pycowsay/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
    In file included from regex_3/_regex.c:48:
    /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
    #include <stdio.h>
             ^~~~~~~~~
    1 error generated.
    error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_simple0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-9jo471ao/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-g90akhho/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_simple0/subdir/pipxhome/venvs/pycowsay/include/site/python3.8/regex Check the logs for full command output.
done! ✨ 🌟 ✨
Error installing black.
___________________________________________________________________________ test_include_apps ____________________________________________________________________________

pipx_temp_env = None, capsys = <_pytest.capture.CaptureFixture object at 0x10808ac10>

    def test_include_apps(pipx_temp_env, capsys):
        assert not run_pipx_cli(["install", "pycowsay"])
        assert run_pipx_cli(["inject", "pycowsay", "black", "--include-deps"])
>       assert not run_pipx_cli(
            ["inject", "pycowsay", "black", "--include-deps", "--include-apps"]
        )
E       AssertionError: assert not 1
E        +  where 1 = run_pipx_cli(['inject', 'pycowsay', 'black', '--include-deps', '--include-apps'])

tests/test_inject.py:18: AssertionError
-------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------
  installed package pycowsay 0.0.0.1, Python 3.8.1
  These apps are now globally available
    - pycowsay
-------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------
  ERROR: Command errored out with exit status 1:
   command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_include_apps0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-wheel-923xaxm4
       cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.8
  creating build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  running build_ext
  building 'regex._regex' extension
  creating build/temp.macosx-10.9-x86_64-3.8
  creating build/temp.macosx-10.9-x86_64-3.8/regex_3
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_include_apps0/subdir/pipxhome/venvs/pycowsay/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
  In file included from regex_3/_regex.c:48:
  /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for regex
    ERROR: Command errored out with exit status 1:
     command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_include_apps0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-9k4opfzx/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_include_apps0/subdir/pipxhome/venvs/pycowsay/include/site/python3.8/regex
         cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/
    Complete output (21 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.8
    creating build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    running build_ext
    building 'regex._regex' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/regex_3
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_include_apps0/subdir/pipxhome/venvs/pycowsay/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
    In file included from regex_3/_regex.c:48:
    /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
    #include <stdio.h>
             ^~~~~~~~~
    1 error generated.
    error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_include_apps0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-izbn30m3/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-9k4opfzx/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_include_apps0/subdir/pipxhome/venvs/pycowsay/include/site/python3.8/regex Check the logs for full command output.
done! ✨ 🌟 ✨
Cannot pass --include-deps if --include-apps is not passed as well
Error installing black.
___________________________________________________________________ test_install_easy_packages[black] ____________________________________________________________________

capsys = <_pytest.capture.CaptureFixture object at 0x1082551c0>, pipx_temp_env = None, caplog = <_pytest.logging.LogCaptureFixture object at 0x1082758b0>
package = 'black'

    @pytest.mark.parametrize("package", ["pycowsay", "black"])
    def test_install_easy_packages(capsys, pipx_temp_env, caplog, package):
>       install_package(capsys, pipx_temp_env, caplog, package)

tests/test_install.py:48: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

capsys = <_pytest.capture.CaptureFixture object at 0x1082551c0>, pipx_temp_env = None, caplog = <_pytest.logging.LogCaptureFixture object at 0x1082758b0>
package = 'black', package_name = 'black'

    def install_package(capsys, pipx_temp_env, caplog, package, package_name=""):
        if not package_name:
            package_name = package
    
        run_pipx_cli(["install", package, "--verbose"])
        captured = capsys.readouterr()
>       assert f"installed package {package_name}" in captured.out
E       AssertionError: assert 'installed package black' in '\n'
E        +  where '\n' = CaptureResult(out='\n', err='Error installing black.\n').out

tests/test_install.py:34: AssertionError
-------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------
Collecting black
  Using cached black-19.10b0-py36-none-any.whl (97 kB)
Collecting appdirs
  Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Collecting pathspec<1,>=0.6
  Using cached pathspec-0.7.0-py2.py3-none-any.whl (25 kB)
Collecting click>=6.5
  Using cached Click-7.0-py2.py3-none-any.whl (81 kB)
Collecting attrs>=18.1.0
  Using cached attrs-19.3.0-py2.py3-none-any.whl (39 kB)
Collecting toml>=0.9.4
  Using cached toml-0.10.0-py2.py3-none-any.whl (25 kB)
Collecting regex
  Using cached regex-2020.1.8.tar.gz (681 kB)
Collecting typed-ast>=1.4.0
  Using cached typed_ast-1.4.1-cp38-cp38-macosx_10_15_x86_64.whl (224 kB)
Building wheels for collected packages: regex
  Building wheel for regex (setup.py): started
  Building wheel for regex (setup.py): finished with status 'error'
  Running setup.py clean for regex
Failed to build regex
Installing collected packages: appdirs, pathspec, click, attrs, toml, regex, typed-ast, black
    Running setup.py install for regex: started
    Running setup.py install for regex: finished with status 'error'
-------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------
  ERROR: Command errored out with exit status 1:
   command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_install_easy_packages_bla0/subdir/pipxhome/venvs/black/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-wheel-w1byycdn
       cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.8
  creating build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  running build_ext
  building 'regex._regex' extension
  creating build/temp.macosx-10.9-x86_64-3.8
  creating build/temp.macosx-10.9-x86_64-3.8/regex_3
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_install_easy_packages_bla0/subdir/pipxhome/venvs/black/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
  In file included from regex_3/_regex.c:48:
  /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for regex
    ERROR: Command errored out with exit status 1:
     command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_install_easy_packages_bla0/subdir/pipxhome/venvs/black/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-uu1ef87n/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_install_easy_packages_bla0/subdir/pipxhome/venvs/black/include/site/python3.8/regex
         cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/
    Complete output (21 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.8
    creating build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    running build_ext
    building 'regex._regex' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/regex_3
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_install_easy_packages_bla0/subdir/pipxhome/venvs/black/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
    In file included from regex_3/_regex.c:48:
    /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
    #include <stdio.h>
             ^~~~~~~~~
    1 error generated.
    error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_install_easy_packages_bla0/subdir/pipxhome/venvs/black/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-2yspkg39/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-uu1ef87n/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_install_easy_packages_bla0/subdir/pipxhome/venvs/black/include/site/python3.8/regex Check the logs for full command output.
__________________________________________________________________________ test_package_inject ___________________________________________________________________________

monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x108342fd0>
tmp_path = PosixPath('/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0'), pipx_temp_env = None

    def test_package_inject(monkeypatch, tmp_path, pipx_temp_env):
        pipx_venvs_dir = pipx.constants.PIPX_HOME / "venvs"
    
        run_pipx_cli(["install", "pycowsay"])
        run_pipx_cli(["inject", "pycowsay", "black"])
        assert (pipx_venvs_dir / "pycowsay" / "pipx_metadata.json").is_file()
    
        pipx_metadata = PipxMetadata(pipx_venvs_dir / "pycowsay")
    
>       assert pipx_metadata.injected_packages.keys() == {"black"}
E       AssertionError: assert dict_keys([]) == {'black'}
E         Use -v to get the full diff

tests/test_pipx_metadata_file.py:157: AssertionError
-------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------
  installed package pycowsay 0.0.0.1, Python 3.8.1
  These apps are now globally available
    - pycowsay
-------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------
done! ✨ 🌟 ✨
  ERROR: Command errored out with exit status 1:
   command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-wheel-y9nllr3g
       cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.8
  creating build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  running build_ext
  building 'regex._regex' extension
  creating build/temp.macosx-10.9-x86_64-3.8
  creating build/temp.macosx-10.9-x86_64-3.8/regex_3
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0/subdir/pipxhome/venvs/pycowsay/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
  In file included from regex_3/_regex.c:48:
  /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for regex
    ERROR: Command errored out with exit status 1:
     command: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-dxqtxbe3/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0/subdir/pipxhome/venvs/pycowsay/include/site/python3.8/regex
         cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/
    Complete output (21 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.8
    creating build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
    running build_ext
    building 'regex._regex' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/regex_3
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0/subdir/pipxhome/venvs/pycowsay/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
    In file included from regex_3/_regex.c:48:
    /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
    #include <stdio.h>
             ^~~~~~~~~
    1 error generated.
    error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0/subdir/pipxhome/venvs/pycowsay/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-alpx7q3b/regex/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-record-dxqtxbe3/install-record.txt --single-version-externally-managed --compile --install-headers /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pytest-of-jaraco/pytest-17/test_package_inject0/subdir/pipxhome/venvs/pycowsay/include/site/python3.8/regex Check the logs for full command output.
Error installing black.
_____________________________________________________________________ test_run_script_from_internet ______________________________________________________________________

pipx_temp_env = None, capsys = <_pytest.capture.CaptureFixture object at 0x1082b1040>

    def test_run_script_from_internet(pipx_temp_env, capsys):
>       assert not run_pipx_cli(
            [
                "run",
                "https://gist.githubusercontent.com/cs01/"
                "fa721a17a326e551ede048c5088f9e0f/raw/"
                "6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py",
            ]
        )
E       AssertionError: assert not 1
E        +  where 1 = run_pipx_cli(['run', 'https://gist.githubusercontent.com/cs01/fa721a17a326e551ede048c5088f9e0f/raw/6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py'])

tests/test_run.py:42: AssertionError
-------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>


================================================================ 5 failed, 70 passed in 202.51s (0:03:22) ================================================================
nox > Command pytest --cov=pipx --cov-config .coveragerc --cov-report= tests failed with exit code 1
nox > Session tests-3.8 failed.
@itsayellow
Copy link
Contributor

See https://pipxproject.github.io/pipx/contributing/
We use a special version of nox that allows use of native python3 venvs

python -m pip install --user git+https://github.com/cs01/nox.git@5ea70723e9e6 nox

@jaraco
Copy link
Member Author

jaraco commented Jan 30, 2020

Sorry for the wall of noise, but I did want to show the whole command output; in both cases, I installed cs01/nox@5ea70723e9e6. Ex: .nox/.nox/bin/pip install --use-pep517 setuptools 'git+https://github.com/cs01/nox.git@5ea70723e9e6#egg=nox'

@cs01
Copy link
Member

cs01 commented Jan 30, 2020

It looks strange that you are installing nox from within nox. You can see command in the travis file. Unless something broke upstream, it should work since the travis tests work. https://github.com/pipxproject/pipx/blob/master/.travis.yml#L28.
After you install nox, all you need to do is run nox -s $SESSION. Maybe using pip-run to run nox is messing things up, not sure.

@itsayellow
Copy link
Contributor

itsayellow commented Jan 30, 2020

Another thing: it looks like you are having trouble with black, which was a problem for us (even in TravisCI) in the past. One of the deps of black (regex) had no wheels and would break during the install, because all the proper compile paths were not in the path.

We haven't had a problem with it in a while though, so I had assumed that that problem is fixed. It may or may not be related to your test issues.

#266
We used to add /usr/bin to the PATH in the test environment, but stopped doing it when test isolation suffered and caused other problems

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

It looks strange that you are installing nox from within nox.

I'm using python -m venv .nox/.nox to create an environment from which to run nox (similar to what tox does when it the version required isn't satisfied by the running version). I don't want a custom build of nox in my global environment (as I don't know what the implications of that would be).

Maybe using pip-run is messing things up

I've removed that from the OP to avoid that concern.

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

Another thing: it looks like you are having trouble with black, which was a problem for us (even in TravisCI) in the past. One of the deps of black (regex) had no wheels and would break during the install, because all the proper compile paths were not in the path.

Yes, that does seem to be the issue. Maybe regex released some wheels, but then released a newer version without wheels. Or maybe regex doesn't release wheels for macOS, which is my platform. Yes, that seems to be the case, at least for recent releases of regex.

But here's the thing - I can build/install regex from source in my environment:

~ $ pip-run --use-pep517 regex                                                                                                                                            
Collecting regex
  Using cached regex-2020.1.8.tar.gz (681 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: regex
  Building wheel for regex (PEP 517) ... done
  Created wheel for regex: filename=regex-2020.1.8-cp38-cp38-macosx_10_9_x86_64.whl size=292691 sha256=29fb764bac08b376cec039c22d33b905722bf23d56ad42b215bc7748ffe95f19
  Stored in directory: /Users/jaraco/Library/Caches/pip/wheels/da/a9/f8/6b8db52b07a83640f1d7711d9f93945cfc1853cb08fce8e0b8
Successfully built regex
Installing collected packages: regex
Successfully installed regex-2020.1.8
Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D

Or without pep517 (supplying the implicit setuptools dependency):

~ $ pip-run setuptools -- -m pip-run --no-cache-dir regex                                                                                                                 
Collecting setuptools
  Using cached setuptools-45.1.0-py3-none-any.whl (583 kB)
Installing collected packages: setuptools
Successfully installed setuptools-45.1.0
Collecting regex
  Downloading regex-2020.1.8.tar.gz (681 kB)
     |████████████████████████████████| 681 kB 1.4 MB/s 
Installing collected packages: regex
    Running setup.py install for regex ... done
Successfully installed regex-2020.1.8
Python 3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D

So the environment is able to build regex. It seems there's something about how nox or pipx is preparing the environment that it's not able to build regex. Perhaps some subprocess invocation is removing environment variables that allow extension modules to be compiled.

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

Reading up on #266, that issue seemed only to be concerned with running with gcc on Linux, but this issue seems to reveal that the failure is more widespread, and that issues exist when any package needs extensions compiled from source, and the issue only affects macOS users because currently regex doesn't supply wheels for that platform.

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

It looks like the way nox works, it removes all environment variables from the session when invoking commands (env=None). That's probably why compilation is failing.

To test my hypothesis, I created this nox environment:

$ cat > noxfile.py
import nox


@nox.session()
def test(session):
    session.install('--no-cache-dir', 'regex')

Then ran nox on it:

draft $ pip-run -q setuptools nox -- -m nox                                                                                                                               
nox > Running session test
nox > Creating virtual environment (virtualenv) using python in .nox/test
nox > pip install --no-cache-dir regex
nox > Session test was successful.

As you can see, it didn't fail. Aaah - because env=None means (inherit environment).

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

Since the issue doesn't appear to be with how nox configures its environment, I started looking into the test suite, and I found the pipx_temp_env fixture, which is explicitly monkey-patching the environment in which packages are installed. I guess it's no big surprise if the test suite is removing all binaries from PATH that a compiler will fail to execute.

Indeed, I'm able to replicate the failure mode by simply spamming path before attempting to install regex:

pipx master $ env PATH='/does-not-exist' /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -m pip install --use-pep517 --no-cache-dir regex                   
Collecting regex
  Downloading regex-2020.1.8.tar.gz (681 kB)
     |████████████████████████████████| 681 kB 1.4 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: regex
  Building wheel for regex (PEP 517) ... error
Failed to build regex
  ERROR: Command errored out with exit status 1:
   command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py build_wheel /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/tmpq7xizudo
       cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-install-eu_udmuq/regex
  Complete output (21 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.9-x86_64-3.8
  creating build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/_regex_core.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  copying regex_3/test_regex.py -> build/lib.macosx-10.9-x86_64-3.8/regex
  running build_ext
  building 'regex._regex' extension
  creating build/temp.macosx-10.9-x86_64-3.8
  creating build/temp.macosx-10.9-x86_64-3.8/regex_3
  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c regex_3/_regex.c -o build/temp.macosx-10.9-x86_64-3.8/regex_3/_regex.o
  In file included from regex_3/_regex.c:48:
  /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/Python.h:25:10: fatal error: 'stdio.h' file not found
  #include <stdio.h>
           ^~~~~~~~~
  1 error generated.
  error: command '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for regex
ERROR: Could not build wheels for regex which use PEP 517 and cannot be installed directly

My guess is there's something about the compiler that requires other tools on the path to be present for the include directories to be resolved correctly.

Is it reasonable for the pipx tests to clobber the path?

@itsayellow
Copy link
Contributor

We used to add /usr/bin to the PATH in the test environment, but stopped doing it when test isolation suffered and caused other problems
See #298

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

In 5fa0243, I found that by not clobbering the path, the tests stop failing... but some new tests start failing because I have black installed elsewhere, so triggers warnings (and assertions) about that:

___________________________________________ test_install_package_specs[black-https://github.com/ambv/black/archive/18.9b0.zip] ___________________________________________

capsys = <_pytest.capture.CaptureFixture object at 0x10c5ab670>, pipx_temp_env = None, caplog = <_pytest.logging.LogCaptureFixture object at 0x10c60ea90>
package_name = 'black', package_spec = 'https://github.com/ambv/black/archive/18.9b0.zip'

    @pytest.mark.parametrize(
        "package_name,package_spec",
        [
            # ("nox", "git+https://github.com/cs01/nox.git@5ea70723e9e6"),
            ("pylint", "pylint==2.3.1"),
            ("black", "https://github.com/ambv/black/archive/18.9b0.zip"),
        ],
    )
    def test_install_package_specs(
        capsys, pipx_temp_env, caplog, package_name, package_spec
    ):
>       install_package(capsys, pipx_temp_env, caplog, package_spec, package_name)

tests/test_install.py:75: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

capsys = <_pytest.capture.CaptureFixture object at 0x10c5ab670>, pipx_temp_env = None, caplog = <_pytest.logging.LogCaptureFixture object at 0x10c60ea90>
package = 'https://github.com/ambv/black/archive/18.9b0.zip', package_name = 'black'

    def install_package(capsys, pipx_temp_env, caplog, package, package_name=""):
        if not package_name:
            package_name = package
    
        run_pipx_cli(["install", package, "--verbose"])
        captured = capsys.readouterr()
        assert f"installed package {package_name}" in captured.out
        if not sys.platform.startswith("win"):
            # TODO assert on windows too
            # https://github.com/pipxproject/pipx/issues/217
            assert "symlink missing or pointing to unexpected location" not in captured.out
        assert "not modifying" not in captured.out
        assert "is not on your PATH environment variable" not in captured.out
        for record in caplog.records:
>           assert "⚠️" not in record.message
E           AssertionError: assert '⚠️' not in '⚠️  Note: b...al/bin/black'
E             '⚠️' is contained here:
E               ⚠️  Note: black was already on your PATH at /Users/jaraco/.local/bin/black
E             ? ++

tests/test_install.py:42: AssertionError
-------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------
Collecting https://github.com/ambv/black/archive/18.9b0.zip
  Using cached https://github.com/ambv/black/archive/18.9b0.zip
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Building wheels for collected packages: black
  Building wheel for black (PEP 517): started
  Building wheel for black (PEP 517): finished with status 'done'
  Created wheel for black: filename=black-18.9b0-py36-none-any.whl size=88091 sha256=08f98cb8798aa832e85f128e52f4f43d6e3134a955dd03a607f87a88ca674db1
  Stored in directory: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-ephem-wheel-cache-6xbmwu0o/wheels/c2/6a/a3/93788da15f8a518472c6a36fa9fd1d5ae3f686c81c0a4d90b1
Successfully built black
Installing collected packages: black
Successfully installed black-18.9b0
Collecting https://github.com/ambv/black/archive/18.9b0.zip
  Using cached https://github.com/ambv/black/archive/18.9b0.zip
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
Collecting attrs>=17.4.0
  Using cached attrs-19.3.0-py2.py3-none-any.whl (39 kB)
Collecting appdirs
  Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Collecting click>=6.5
  Using cached Click-7.0-py2.py3-none-any.whl (81 kB)
Collecting toml>=0.9.4
  Using cached toml-0.10.0-py2.py3-none-any.whl (25 kB)
Building wheels for collected packages: black
  Building wheel for black (PEP 517): started
  Building wheel for black (PEP 517): finished with status 'done'
  Created wheel for black: filename=black-18.9b0-py36-none-any.whl size=88091 sha256=bf8ebce5889820f4a0673add55736793e5817378fec2d7bcbc6ab57719176ac7
  Stored in directory: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-ephem-wheel-cache-qdgjatb0/wheels/c2/6a/a3/93788da15f8a518472c6a36fa9fd1d5ae3f686c81c0a4d90b1
Successfully built black
Installing collected packages: attrs, appdirs, click, toml, black
Successfully installed appdirs-1.4.3 attrs-19.3.0 black-18.9b0 click-7.0 toml-0.10.0
--------------------------------------------------------------------------- Captured log call ----------------------------------------------------------------------------
WARNING  root:common.py:79 ⚠️  Note: black was already on your PATH at /Users/jaraco/.local/bin/black
WARNING  root:common.py:79 ⚠️  Note: blackd was already on your PATH at /Users/jaraco/.local/bin/blackd

And an error about certificate verification failing (probably another clobbered environment setting for those certificates):

_____________________________________________________________________ test_run_script_from_internet ______________________________________________________________________

pipx_temp_env = None, capsys = <_pytest.capture.CaptureFixture object at 0x10c5e2ee0>

    def test_run_script_from_internet(pipx_temp_env, capsys):
>       assert not run_pipx_cli(
            [
                "run",
                "https://gist.githubusercontent.com/cs01/"
                "fa721a17a326e551ede048c5088f9e0f/raw/"
                "6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py",
            ]
        )
E       AssertionError: assert not 1
E        +  where 1 = run_pipx_cli(['run', 'https://gist.githubusercontent.com/cs01/fa721a17a326e551ede048c5088f9e0f/raw/6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py'])

tests/test_run.py:42: AssertionError
-------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------
<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)>

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

Gah, so pipx tests will fail if black exists on the path, but also fail if compiler tools are needed and not on path, and it's conceivable that black and these compiler tools are both on the same path, so it's not possible in the general case to address this issue.

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

In master, the issue with regex failing to compile has gone away. In this comment, I explain why I think the issue went away. I'm pretty sure by running pip-run regex outside of the test environment caused a wheel to be cached locally and worked around the issue of the compiler being broken inside of pipx tests.

The CERTIFICATE_VERIFY_FAILED error persists.

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

I can more simply elicit the error message by applying this patch:

diff --git a/tests/test_run.py b/tests/test_run.py
index 1601a3f..0bbff4a 100644
--- a/tests/test_run.py
+++ b/tests/test_run.py
@@ -39,12 +39,17 @@ def test_cache(pipx_temp_env, monkeypatch, capsys, caplog):
 
 
 def test_run_script_from_internet(pipx_temp_env, capsys):
+    run = sys.modules['pipx.commands.run']
+    url = (
+        "https://gist.githubusercontent.com/cs01/"
+        "fa721a17a326e551ede048c5088f9e0f/raw/"
+        "6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py"
+    )
+    run._http_get_request(url)
     assert not run_pipx_cli(
         [
             "run",
-            "https://gist.githubusercontent.com/cs01/"
-            "fa721a17a326e551ede048c5088f9e0f/raw/"
-            "6bdfbb6e9c1132b1c38fdd2f195d4a24c540c324/pipx-demo.py",
+            url,
         ]
     )

And then running nox --session tests-3.8 -- -k run_script_from_internet.

@jaraco
Copy link
Member Author

jaraco commented Jan 31, 2020

Okay, I've traced the CERTIFICATE_VERIFY_FAILED to my development environment having lost its certificates file. After installing certifi and symlinking the certificates, that issue goes away.

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

Successfully merging a pull request may close this issue.

3 participants