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

virtualenv: use version 20 to support Python 3.9 #8873

Merged
merged 2 commits into from
Oct 7, 2020
Merged

virtualenv: use version 20 to support Python 3.9 #8873

merged 2 commits into from
Oct 7, 2020

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Oct 7, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?
  • Have you successfully run brew man locally and committed any changes?

See Homebrew/homebrew-core#62201 (comment) and Homebrew/discussions#31

Update the homebrew-virtualenv resource to version 20.0.33 to support virtual environments using Python 3.9. This was attempted previously in #7941.

I tested this locally and was able to build a formula using a Python 3.9 formula locally without any problems. I'm not yet sure what the consequences are to adding the four new homebrew- resources.

@gaurdro
Copy link

gaurdro commented Oct 7, 2020

I'm new to homebrew dev, so sorry if I've not found a previous discussion. Is there a reason not to use the venv python module for this? some quick searching didn't turn up formulas tha relied on python<3.6.

@Rylan12
Copy link
Member Author

Rylan12 commented Oct 7, 2020

I'm new to homebrew dev, so sorry if I've not found a previous discussion. Is there a reason not to use the venv python module for this? some quick searching didn't turn up formulas tha relied on python<3.6.

Good question. You're correct, the only Python versions we have currently are 3.7, 3.8, and 3.9. If I had to guess, the reason we aren't using it is that this code was introduced before the venv module existed.

According to the virtualenv docs one should use virtualenv instead of the venv module because venv:

  • is slower (by not having the app-data seed method),
  • is not as extendable,
  • cannot create virtual environments for arbitrarily installed python versions (and automatically discover these),
  • is not upgrade-able via pip,
  • does not have as rich programmatic API (describe virtual environments without creating them).

I don't think any of these are breaking points for us, though. Do any other maintainers have an opinion?

@fxcoudert
Copy link
Member

This looks fine to me, but I do not know that Python-related code well enough to predict if it could have unexpected downsides.

@fxcoudert fxcoudert merged commit bd8eba8 into Homebrew:master Oct 7, 2020
@Rylan12 Rylan12 deleted the homebrew-virtualenv-version-20 branch October 7, 2020 12:04
@iMichka
Copy link
Member

iMichka commented Oct 8, 2020

This might have broken virtualenv_install_with_resources on Linux for Python 3.9.

For example in the flake 8 formula, we expect this path to exist:
/home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/bin/flake8

But it does not get created.

Only /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/bin exists.

On Mac I do not see this issue. It might also be due to something else, I am still investigating.

@jonchang
Copy link
Contributor

jonchang commented Oct 8, 2020

On Linux, the formula resources are getting installed outside of the virtualenv. It seems like on Linux, brewed Python is being executed rather than the virtualenv Python.

macOS
==> /usr/local/Cellar/flake8/3.8.4_1/libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed /private/tmp/flake8-20201008-70600-sc28ie/flake8-3.8.4
Using pip 20.2.3 from /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/pip (python 3.9)
Non-user install because user site-packages disabled
Created temporary directory: /private/tmp/pip-ephem-wheel-cache-udeuskal
Created temporary directory: /private/tmp/pip-req-tracker-62azy6r7
Initialized build tracking at /private/tmp/pip-req-tracker-62azy6r7
Created build tracker: /private/tmp/pip-req-tracker-62azy6r7
Entered build tracker: /private/tmp/pip-req-tracker-62azy6r7
Created temporary directory: /private/tmp/pip-install-rqqef5ea
Processing /private/tmp/flake8-20201008-70600-sc28ie/flake8-3.8.4
  Created temporary directory: /private/tmp/pip-req-build-q788hu3e
  Added file:///private/tmp/flake8-20201008-70600-sc28ie/flake8-3.8.4 to build tracker '/private/tmp/pip-req-tracker-62azy6r7'
    Running setup.py (path:/private/tmp/pip-req-build-q788hu3e/setup.py) egg_info for package from file:///private/tmp/flake8-20201008-70600-sc28ie/flake8-3.8.4
    Created temporary directory: /private/tmp/pip-pip-egg-info-bk5zqyy3
    Running command python setup.py egg_info
    running egg_info
    creating /private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info
    writing /private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/PKG-INFO
    writing dependency_links to /private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/dependency_links.txt
    writing entry points to /private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/entry_points.txt
    writing requirements to /private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/requires.txt
    writing top-level names to /private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/top_level.txt
    writing manifest file '/private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/SOURCES.txt'
    reading manifest file '/private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    no previously-included directories found matching 'docs/build/'
    writing manifest file '/private/tmp/pip-pip-egg-info-bk5zqyy3/flake8.egg-info/SOURCES.txt'
  Source in /private/tmp/pip-req-build-q788hu3e has version 3.8.4, which satisfies requirement flake8==3.8.4 from file:///private/tmp/flake8-20201008-70600-sc28ie/flake8-3.8.4
  Removed flake8==3.8.4 from file:///private/tmp/flake8-20201008-70600-sc28ie/flake8-3.8.4 from build tracker '/private/tmp/pip-req-tracker-62azy6r7'
Skipping wheel build for flake8, due to binaries being disabled for it.
Installing collected packages: flake8
  Created temporary directory: /private/tmp/pip-record-khny3rbp
    Running setup.py install for flake8: started
    Running command /usr/local/Cellar/flake8/3.8.4_1/libexec/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-req-build-q788hu3e/setup.py'"'"'; __file__='"'"'/private/tmp/pip-req-build-q788hu3e/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/tmp/pip-record-khny3rbp/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/Cellar/flake8/3.8.4_1/libexec/include/site/python3.9/flake8
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/flake8
    copying src/flake8/__init__.py -> build/lib/flake8
    copying src/flake8/processor.py -> build/lib/flake8
    copying src/flake8/utils.py -> build/lib/flake8
    copying src/flake8/exceptions.py -> build/lib/flake8
    copying src/flake8/defaults.py -> build/lib/flake8
    copying src/flake8/statistics.py -> build/lib/flake8
    copying src/flake8/_compat.py -> build/lib/flake8
    copying src/flake8/style_guide.py -> build/lib/flake8
    copying src/flake8/__main__.py -> build/lib/flake8
    copying src/flake8/checker.py -> build/lib/flake8
    creating build/lib/flake8/options
    copying src/flake8/options/config.py -> build/lib/flake8/options
    copying src/flake8/options/aggregator.py -> build/lib/flake8/options
    copying src/flake8/options/__init__.py -> build/lib/flake8/options
    copying src/flake8/options/manager.py -> build/lib/flake8/options
    creating build/lib/flake8/plugins
    copying src/flake8/plugins/pyflakes.py -> build/lib/flake8/plugins
    copying src/flake8/plugins/__init__.py -> build/lib/flake8/plugins
    copying src/flake8/plugins/manager.py -> build/lib/flake8/plugins
    creating build/lib/flake8/formatting
    copying src/flake8/formatting/__init__.py -> build/lib/flake8/formatting
    copying src/flake8/formatting/default.py -> build/lib/flake8/formatting
    copying src/flake8/formatting/base.py -> build/lib/flake8/formatting
    creating build/lib/flake8/api
    copying src/flake8/api/legacy.py -> build/lib/flake8/api
    copying src/flake8/api/__init__.py -> build/lib/flake8/api
    creating build/lib/flake8/main
    copying src/flake8/main/options.py -> build/lib/flake8/main
    copying src/flake8/main/git.py -> build/lib/flake8/main
    copying src/flake8/main/__init__.py -> build/lib/flake8/main
    copying src/flake8/main/mercurial.py -> build/lib/flake8/main
    copying src/flake8/main/application.py -> build/lib/flake8/main
    copying src/flake8/main/setuptools_command.py -> build/lib/flake8/main
    copying src/flake8/main/cli.py -> build/lib/flake8/main
    copying src/flake8/main/debug.py -> build/lib/flake8/main
    copying src/flake8/main/vcs.py -> build/lib/flake8/main
    running install_lib
    creating /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    creating /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options
    copying build/lib/flake8/options/config.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options
    copying build/lib/flake8/options/aggregator.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options
    copying build/lib/flake8/options/__init__.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options
    copying build/lib/flake8/options/manager.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options
    creating /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/plugins
    copying build/lib/flake8/plugins/pyflakes.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/plugins
    copying build/lib/flake8/plugins/__init__.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/plugins
    copying build/lib/flake8/plugins/manager.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/plugins
    copying build/lib/flake8/__init__.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    copying build/lib/flake8/processor.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    copying build/lib/flake8/utils.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    creating /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/formatting
    copying build/lib/flake8/formatting/__init__.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/formatting
    copying build/lib/flake8/formatting/default.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/formatting
    copying build/lib/flake8/formatting/base.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/formatting
    creating /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/api
    copying build/lib/flake8/api/legacy.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/api
    copying build/lib/flake8/api/__init__.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/api
    copying build/lib/flake8/exceptions.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    copying build/lib/flake8/defaults.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    copying build/lib/flake8/statistics.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    copying build/lib/flake8/_compat.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    copying build/lib/flake8/style_guide.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    creating /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/options.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/git.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/__init__.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/mercurial.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/application.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/setuptools_command.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/cli.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/debug.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/main/vcs.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main
    copying build/lib/flake8/__main__.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    copying build/lib/flake8/checker.py -> /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options/config.py to config.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options/aggregator.py to aggregator.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options/__init__.py to __init__.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/options/manager.py to manager.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/plugins/pyflakes.py to pyflakes.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/plugins/__init__.py to __init__.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/plugins/manager.py to manager.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/__init__.py to __init__.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/processor.py to processor.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/utils.py to utils.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/formatting/__init__.py to __init__.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/formatting/default.py to default.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/formatting/base.py to base.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/api/legacy.py to legacy.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/api/__init__.py to __init__.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/exceptions.py to exceptions.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/defaults.py to defaults.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/statistics.py to statistics.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/_compat.py to _compat.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/style_guide.py to style_guide.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/options.py to options.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/git.py to git.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/__init__.py to __init__.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/mercurial.py to mercurial.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/application.py to application.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/setuptools_command.py to setuptools_command.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/cli.py to cli.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/debug.py to debug.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/main/vcs.py to vcs.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/__main__.py to __main__.cpython-39.pyc
    byte-compiling /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8/checker.py to checker.cpython-39.pyc
    running install_egg_info
    running egg_info
    creating src/flake8.egg-info
    writing src/flake8.egg-info/PKG-INFO
    writing dependency_links to src/flake8.egg-info/dependency_links.txt
    writing entry points to src/flake8.egg-info/entry_points.txt
    writing requirements to src/flake8.egg-info/requires.txt
    writing top-level names to src/flake8.egg-info/top_level.txt
    writing manifest file 'src/flake8.egg-info/SOURCES.txt'
    reading manifest file 'src/flake8.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    no previously-included directories found matching 'docs/build/'
    writing manifest file 'src/flake8.egg-info/SOURCES.txt'
    Copying src/flake8.egg-info to /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/flake8-3.8.4-py3.9.egg-info
    running install_scripts
    Installing flake8 script to /usr/local/Cellar/flake8/3.8.4_1/libexec/bin
    writing list of installed files to '/private/tmp/pip-record-khny3rbp/install-record.txt'
    Running setup.py install for flake8: finished with status 'done'
Successfully installed flake8-3.8.4
Removed build tracker: '/private/tmp/pip-req-tracker-62azy6r7'
Linux
==> /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/bin/pip install -v --no-deps --no-binary :all: --ignore-installed /tmp/flake8-20201008-21124-9xix02/flake8-3.8.4
Using pip 20.2.3 from /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/pip (python 3.9)
Non-user install because user site-packages disabled
Created temporary directory: /tmp/pip-ephem-wheel-cache-g38pbvn4
Created temporary directory: /tmp/pip-req-tracker-luc147ti
Initialized build tracking at /tmp/pip-req-tracker-luc147ti
Created build tracker: /tmp/pip-req-tracker-luc147ti
Entered build tracker: /tmp/pip-req-tracker-luc147ti
Created temporary directory: /tmp/pip-install-3hz68e0m
Processing /tmp/flake8-20201008-21124-9xix02/flake8-3.8.4
  Created temporary directory: /tmp/pip-req-build-uoq3c3c1
  Added file:///tmp/flake8-20201008-21124-9xix02/flake8-3.8.4 to build tracker '/tmp/pip-req-tracker-luc147ti'
    Running setup.py (path:/tmp/pip-req-build-uoq3c3c1/setup.py) egg_info for package from file:///tmp/flake8-20201008-21124-9xix02/flake8-3.8.4
    Created temporary directory: /tmp/pip-pip-egg-info-3ln78kvq
    Running command python setup.py egg_info
    running egg_info
    creating /tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info
    writing /tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/dependency_links.txt
    writing entry points to /tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/entry_points.txt
    writing requirements to /tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/requires.txt
    writing top-level names to /tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/top_level.txt
    writing manifest file '/tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/SOURCES.txt'
    reading manifest file '/tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    no previously-included directories found matching 'docs/build/'
    writing manifest file '/tmp/pip-pip-egg-info-3ln78kvq/flake8.egg-info/SOURCES.txt'
  Source in /tmp/pip-req-build-uoq3c3c1 has version 3.8.4, which satisfies requirement flake8==3.8.4 from file:///tmp/flake8-20201008-21124-9xix02/flake8-3.8.4
  Removed flake8==3.8.4 from file:///tmp/flake8-20201008-21124-9xix02/flake8-3.8.4 from build tracker '/tmp/pip-req-tracker-luc147ti'
Skipping wheel build for flake8, due to binaries being disabled for it.
Installing collected packages: flake8
  Created temporary directory: /tmp/pip-record-7imdnlkw
    Running setup.py install for flake8: started
    Running command /home/linuxbrew/.linuxbrew/opt/python@3.9/bin/python3.9 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-uoq3c3c1/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-uoq3c3c1/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-7imdnlkw/install-record.txt --single-version-externally-managed --compile --install-headers /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/include/site/python3.9/flake8
    running install
    running build
    running build_py
    creating build
    creating build/lib
    creating build/lib/flake8
    copying src/flake8/checker.py -> build/lib/flake8
    copying src/flake8/_compat.py -> build/lib/flake8
    copying src/flake8/style_guide.py -> build/lib/flake8
    copying src/flake8/utils.py -> build/lib/flake8
    copying src/flake8/defaults.py -> build/lib/flake8
    copying src/flake8/processor.py -> build/lib/flake8
    copying src/flake8/__main__.py -> build/lib/flake8
    copying src/flake8/exceptions.py -> build/lib/flake8
    copying src/flake8/__init__.py -> build/lib/flake8
    copying src/flake8/statistics.py -> build/lib/flake8
    creating build/lib/flake8/options
    copying src/flake8/options/aggregator.py -> build/lib/flake8/options
    copying src/flake8/options/config.py -> build/lib/flake8/options
    copying src/flake8/options/manager.py -> build/lib/flake8/options
    copying src/flake8/options/__init__.py -> build/lib/flake8/options
    creating build/lib/flake8/api
    copying src/flake8/api/legacy.py -> build/lib/flake8/api
    copying src/flake8/api/__init__.py -> build/lib/flake8/api
    creating build/lib/flake8/plugins
    copying src/flake8/plugins/manager.py -> build/lib/flake8/plugins
    copying src/flake8/plugins/pyflakes.py -> build/lib/flake8/plugins
    copying src/flake8/plugins/__init__.py -> build/lib/flake8/plugins
    creating build/lib/flake8/formatting
    copying src/flake8/formatting/default.py -> build/lib/flake8/formatting
    copying src/flake8/formatting/__init__.py -> build/lib/flake8/formatting
    copying src/flake8/formatting/base.py -> build/lib/flake8/formatting
    creating build/lib/flake8/main
    copying src/flake8/main/mercurial.py -> build/lib/flake8/main
    copying src/flake8/main/setuptools_command.py -> build/lib/flake8/main
    copying src/flake8/main/options.py -> build/lib/flake8/main
    copying src/flake8/main/git.py -> build/lib/flake8/main
    copying src/flake8/main/vcs.py -> build/lib/flake8/main
    copying src/flake8/main/cli.py -> build/lib/flake8/main
    copying src/flake8/main/__init__.py -> build/lib/flake8/main
    copying src/flake8/main/debug.py -> build/lib/flake8/main
    copying src/flake8/main/application.py -> build/lib/flake8/main
    running install_lib
    running install_egg_info
    running egg_info
    creating src/flake8.egg-info
    writing src/flake8.egg-info/PKG-INFO
    writing dependency_links to src/flake8.egg-info/dependency_links.txt
    writing entry points to src/flake8.egg-info/entry_points.txt
    writing requirements to src/flake8.egg-info/requires.txt
    writing top-level names to src/flake8.egg-info/top_level.txt
    writing manifest file 'src/flake8.egg-info/SOURCES.txt'
    reading manifest file 'src/flake8.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*.pyc' found anywhere in distribution
    no previously-included directories found matching 'docs/build/'
    writing manifest file 'src/flake8.egg-info/SOURCES.txt'
    removing '/home/linuxbrew/.linuxbrew/lib/python3.9/site-packages/flake8-3.8.4-py3.9.egg-info' (and everything under it)
    Copying src/flake8.egg-info to /home/linuxbrew/.linuxbrew/lib/python3.9/site-packages/flake8-3.8.4-py3.9.egg-info
    running install_scripts
    Installing flake8 script to /home/linuxbrew/.linuxbrew/bin
    writing list of installed files to '/tmp/pip-record-7imdnlkw/install-record.txt'
    Running setup.py install for flake8: finished with status 'done'
Successfully installed flake8
Removed build tracker: '/tmp/pip-req-tracker-luc147ti'

@jonchang
Copy link
Contributor

jonchang commented Oct 8, 2020

We can observe the defective behavior by running the virtualenv pip and checking the value of sys.executable.

macOS:

% /usr/local/opt/flake8/libexec/bin/pip debug
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
pip version: pip 20.2.3 from /usr/local/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/pip (python 3.9)
sys.version: 3.9.0 (default, Oct  6 2020, 04:17:54) 
[Clang 12.0.0 (clang-1200.0.32.2)]
sys.executable: /usr/local/Cellar/flake8/3.8.4_1/libexec/bin/python

Linux:

# /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/bin/pip debug
WARNING: This command is only meant for debugging. Do not use this with automation for parsing and getting these details, since the output and options of this command may change without notice.
pip version: pip 20.2.3 from /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/pip (python 3.9)
sys.version: 3.9.0 (default, Oct  7 2020, 09:11:45) 
[GCC 5.4.0 20160609]
sys.executable: /home/linuxbrew/.linuxbrew/opt/python@3.9/bin/python3.9

Applying this patch makes the install work correctly, but this is a horrible hack and I'd rather figure out why this is happening in the first place.

diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb
index b5523b4ed..e42100e2e 100644
--- a/Library/Homebrew/language/python.rb
+++ b/Library/Homebrew/language/python.rb
@@ -317,9 +317,11 @@ module Language
 
         def do_install(targets)
           targets = Array(targets)
-          @formula.system @venv_root/"bin/pip", "install",
-                          "-v", "--no-deps", "--no-binary", ":all:",
-                          "--ignore-installed", *targets
+          with_env("PYTHONEXECUTABLE" => @venv_root/"bin/python") do
+            @formula.system @venv_root/"bin/pip", "install",
+                            "-v", "--no-deps", "--no-binary", ":all:",
+                            "--ignore-installed", *targets
+          end
         end
       end
     end

@Rylan12
Copy link
Member Author

Rylan12 commented Oct 8, 2020

I don't have any experience with linux so it's hard for me to try to help.

Is this broken for all formulae that use a virtualenv or just Python 3.9 formulae?

@dawidd6
Copy link
Member

dawidd6 commented Oct 8, 2020

Seems to be broken for python3.8 formulae as well.

@MikeMcQuaid
Copy link
Member

Applying this patch makes the install work correctly, but this is a horrible hack and I'd rather figure out why this is happening in the first place.

Shall we apply the horrible hack for now and then iterate on a better solution? Bonus points if we add a test to brew tests to reproduce this so we don't get bitten in future.

@iMichka
Copy link
Member

iMichka commented Oct 8, 2020

 /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/bin/python
Python 3.9.0 (default, Oct  8 2020, 06:33:10)
[GCC 5.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/home/linuxbrew/.linuxbrew/opt/python@3.9/bin/python3.9'
/usr/local/Cellar/flake8/3.8.4_1/libexec/bin/python
Python 3.9.0 (default, Oct  6 2020, 04:17:54)
[Clang 12.0.0 (clang-1200.0.32.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/local/Cellar/flake8/3.8.4_1/libexec/bin/python'
>>>

@iMichka
Copy link
Member

iMichka commented Oct 8, 2020

Here is the content of the sitecustomize.py file on Linux:

cat /home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.0/lib/python3.9/site-packages/sitecustomize.py
# This file is created by Homebrew and is executed on each python startup.
# Don't print from here, or else python command line scripts may fail!
# <https://docs.brew.sh/Homebrew-and-Python>
import re
import os
import sys
if sys.version_info[0] != 3:
    # This can only happen if the user has set the PYTHONPATH for 3.x and run Python 2.x or vice versa.
    # Every Python looks at the PYTHONPATH variable and we can't fix it here in sitecustomize.py,
    # because the PYTHONPATH is evaluated after the sitecustomize.py. Many modules (e.g. PyQt4) are
    # built only for a specific version of Python and will fail with cryptic error messages.
    # In the end this means: Don't set the PYTHONPATH permanently if you use different Python versions.
    exit('Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python ' +
         str(sys.version_info[0]) + '.x!\n     PYTHONPATH is currently: "' + str(os.environ['PYTHONPATH']) + '"\n' +
         '     You should `unset PYTHONPATH` to fix this.')
# Only do this for a brewed python:
if os.path.realpath(sys.executable).startswith('/home/linuxbrew/.linuxbrew/Cellar/python@3.9'):
    # Shuffle /Library site-packages to the end of sys.path
    library_site = '/Library/Python/3.9/site-packages'
    library_packages = [p for p in sys.path if p.startswith(library_site)]
    sys.path = [p for p in sys.path if not p.startswith(library_site)]
    # .pth files have already been processed so don't use addsitedir
    sys.path.extend(library_packages)
    # the Cellar site-packages is a symlink to the HOMEBREW_PREFIX
    # site_packages; prefer the shorter paths
    long_prefix = re.compile(r'/home/linuxbrew/.linuxbrew/Cellar/python@3.9/[0-9._abrc]+/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages')
    sys.path = [long_prefix.sub('/home/linuxbrew/.linuxbrew/lib/python3.9/site-packages', p) for p in sys.path]
    # Set the sys.executable to use the opt_prefix, unless explicitly set
    # with PYTHONEXECUTABLE:
    if 'PYTHONEXECUTABLE' not in os.environ:
        sys.executable = '/home/linuxbrew/.linuxbrew/opt/python@3.9/bin/python3.9'

Commenting out the 2 last lines does fix the issue, so that's a first hint in the direction we have to look.

@iMichka
Copy link
Member

iMichka commented Oct 8, 2020

The difference is that:
/usr/local/Cellar/python@3.9/3.9.0/bin/python3 reads sitecustomize.py
/usr/local/Cellar/flake8/3.8.4_1/libexec/bin/python does not read it

/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.0/bin/python3 reads sitecustomize.py
/home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/bin/python reads sitecustomize.py

On Linux the second case should not read the sitecustomize.py file

@iMichka
Copy link
Member

iMichka commented Oct 8, 2020

There is a /home/linuxbrew/.linuxbrew/Cellar/flake8/3.8.4_1/libexec/lib/python3.9/site-packages/homebrew_deps.pth file which brings in the main site-package on Linux. This file does not exist on Mac.

iMichka added a commit to iMichka/brew that referenced this pull request Oct 8, 2020
If added, this makes the virtualenv read the main site-package from brewed Python,
and especially makes it read our sitecustomize.py file, which will
modify the sys.executable path.

See the full discussion at:
Homebrew#8873

I also took the opportunity to not include test deps, as these will
be not be installed, so the .pth file should not contains references
to site-packages from test deps.

Previous packages on Linux did already contain the wrong lines in the pth file,
for example:
cat /home/linuxbrew/.linuxbrew/Cellar/aws-google-auth/0.0.36_1/libexec/lib/python3.8/site-packages/homebrew_deps.pth
import site; site.addsitedir('/home/linuxbrew/.linuxbrew/opt/python@3.8/lib/python3.8/site-packages')
import site; site.addsitedir('/home/linuxbrew/.linuxbrew/opt/libxml2/lib/python3.8/site-packages')

This might have caused subtle bugs for some packages but not for others.
@iMichka
Copy link
Member

iMichka commented Oct 8, 2020

I have a patch for this: #8880

@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 3, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants