You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OSX + homebrew [email protected]: pybuilder/_vendor/virtualenv.py change_prefix does not consider symlinks, raises invalid AssertionError #771
python3 is a symlink /usr/local/bin/python3 -> ../Cellar/[email protected]/3.9.4/bin/python3. pip3 is a symlink /usr/local/bin/pip3 -> ../Cellar/[email protected]/3.9.4/bin/pip3.
$ head -1 $(which pip3)
#!/usr/local/opt/[email protected]/bin/python3.9
I used pip3 install --user pybuilder to install pybuilder:
$ which pyb
/Users/username/Library/Python/3.9/bin/pyb
$ head -1 $(which pyb)
#!/usr/local/opt/[email protected]/bin/python3.9
$ pyb
PyBuilder version 0.12.10
Build started at 2021-04-28 10:36:15
------------------------------------------------------------
------------------------------------------------------------
BUILD FAILED - AssertionError: Filename /usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py does not start with any of these prefixes: ['/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/Extras/lib/python', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9', '/Users/username/Library/Python/3.9/lib/python/site-packages', '/Users/username/.local/lib/python/3.9/site-packages', '/Users/username/Library/Python/3.9/site-packages', '/Library/Python/3.9/site-packages'] (pybuilder/_vendor/virtualenv.py:1272)
------------------------------------------------------------
Build finished at 2021-04-28 10:36:15
Build took 0 seconds (64 ms)
I would highly recommend using PyEnv with Brew regardless as Brew Python contains the following warning:
Important: Python may be upgraded to a newer version at any time. Consider using a version manager such as pyenv if you require stability of minor or patch versions for virtual environments.
+ pyb -vX
[DEBUG] Registered Python environment 'system': CPython version 3.9.4.final.0 on darwin in ['/Users/username/XXX/vebuild/bin/python3.9']
PyBuilder version 0.12.10
Build started at 2021-05-04 08:48:51
------------------------------------------------------------
[DEBUG] Loading project module from ./build.py
[DEBUG] Setting up plugins VEnv at '/Users/username/XXX/.pybuilder/plugins/cpython-3.9.4.final.0'
Traceback (most recent call last):
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/cli.py", line 461, in main
reactor.prepare_build(property_overrides=options.property_overrides,
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/reactor.py", line 203, in prepare_build
self._setup_plugin_directory(reset_plugins, no_venvs)
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/reactor.py", line 517, in _setup_plugin_directory
plugin_env = per["pybuilder"] = PythonEnv(plugin_dir, self).create_venv(with_pip=True,
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/python_env.py", line 209, in create_venv
create_venv(self._env_dir,
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/python_env.py", line 429, in create_venv
virtualenv.create_environment(
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/_vendor/virtualenv.py", line 1161, in create_environment
install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages=site_packages, clear=clear, symlink=symlink)
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/_vendor/virtualenv.py", line 1450, in install_python
copy_required_modules(home_dir, symlink)
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/_vendor/virtualenv.py", line 1340, in copy_required_modules
dst_filename = change_prefix(filename, dst_prefix)
File "/Users/username/XXX/vebuild/lib/python3.9/site-packages/pybuilder/_vendor/virtualenv.py", line 1272, in change_prefix
raise AssertionError("Filename {} does not start with any of these prefixes: {}".format(filename, prefixes))
AssertionError: Filename /usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py does not start with any of these prefixes: ['/Users/username/XXX/vebuild/Extras/lib/python', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9', '/Users/username/Library/Python/3.9/lib/python/site-packages', '/Users/username/XXX/vebuild', '/Users/username/.local/lib/python/3.9/site-packages', '/Users/username/Library/Python/3.9/site-packages', '/Library/Python/3.9/site-packages']
------------------------------------------------------------
BUILD FAILED - AssertionError: Filename /usr/local/Cellar/[email protected]/3.9.4/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py does not start with any of these prefixes: ['/Users/username/XXX/vebuild/Extras/lib/python', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9', '/Users/username/Library/Python/3.9/lib/python/site-packages', '/Users/username/XXX/vebuild', '/Users/username/.local/lib/python/3.9/site-packages', '/Users/username/Library/Python/3.9/site-packages', '/Library/Python/3.9/site-packages'] (pybuilder/_vendor/virtualenv.py:1272)
------------------------------------------------------------
Build finished at 2021-05-04 08:48:51
Build took 0 seconds (64 ms)
So change_prefix function is comparing /usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py to sys.prefix, that points to symlink-containing /usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9 on Homebrew python.
@arcivanov: wouldn't this be fixed by simply changing:
$ pyb
PyBuilder version 0.12.10
Build started at 2021-09-06 08:48:40
------------------------------------------------------------
------------------------------------------------------------
BUILD FAILED - AssertionError: Filename /usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py does not start with any of these prefixes: ['/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9/Extras/lib/python', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9', '/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9', '/Users/username/Library/Python/3.9/lib/python/site-packages', '/Users/username/.local/lib/python/3.9/site-packages', '/Users/username/Library/Python/3.9/site-packages', '/Library/Python/3.9/site-packages'] (pybuilder/_vendor/virtualenv.py:1272)
------------------------------------------------------------
Build finished at 2021-09-06 08:48:40
Build took 0 seconds (68 ms)
Then test with --pre:
$ pip3 install --user --pre --upgrade pybuilder
<clip>
Successfully installed pybuilder-0.13.0.dev20210905004524
$ pyb
PyBuilder version 0.13.0.dev20210905004524
Build started at 2021-09-06 08:50:08
------------------------------------------------------------
------------------------------------------------------------
BUILD FAILED - StopIteration: (virtualenv/run/plugin/discovery.py:22)
------------------------------------------------------------
Build finished at 2021-09-06 08:50:08
Build took 0 seconds (153 ms)
A different error, I call it progress :)
$ pyb -vX
[DEBUG] Registered Python environment 'system': CPython version 3.9.6.final.0 on darwin in ['/usr/local/opt/[email protected]/bin/python3.9']
PyBuilder version 0.13.0.dev20210905004524
Build started at 2021-09-06 08:54:14
------------------------------------------------------------
[DEBUG] Loading project module from ./build.py
[DEBUG] Setting up plugins VEnv at '/Users/username/XXX/.pybuilder/plugins/cpython-3.9.6.final.0'
Traceback (most recent call last):
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/cli.py", line 461, in main
reactor.prepare_build(property_overrides=options.property_overrides,
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/reactor.py", line 203, in prepare_build
self._setup_plugin_directory(reset_plugins, no_venvs)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/reactor.py", line 517, in _setup_plugin_directory
plugin_env = per["pybuilder"] = PythonEnv(plugin_dir, self).create_venv(with_pip=True,
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/python_env.py", line 214, in create_venv
create_venv(self._env_dir,
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/python_env.py", line 453, in create_venv
virtualenv.cli_run(args, setup_logging=False)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/_vendor/virtualenv/run/__init__.py", line 30, in cli_run
of_session = session_via_cli(args, options, setup_logging, env)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/_vendor/virtualenv/run/__init__.py", line 48, in session_via_cli
parser, elements = build_parser(args, options, setup_logging, env)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/_vendor/virtualenv/run/__init__.py", line 69, in build_parser
discover = get_discover(parser, args)
File "/Users/username/Library/Python/3.9/lib/python/site-packages/pybuilder/_vendor/virtualenv/run/plugin/discovery.py", line 22, in get_discover
default=next(iter(choices)),
StopIteration
------------------------------------------------------------
BUILD FAILED - StopIteration: (virtualenv/run/plugin/discovery.py:22)
------------------------------------------------------------
Build finished at 2021-09-06 08:54:14
Build took 0 seconds (129 ms)
Working on other projects, but a quick test with --prePyBuilder version 0.13.0.dev20210917052200 & Python 3.9.7 seems to indicate that this issue is fixed! Awesome, good job!
Activity
dindurthy commentedon May 3, 2021
Are there any workarounds? We're completely blocked.
arcivanov commentedon May 4, 2021
Hello, unfortunately I'm completely swamped right now with work.
We don't test with Brew Python, but we do test with PyEnv Python on Mac and it works: https://travis-ci.com/github/pybuilder/pybuilder/jobs/502734233
I would highly recommend using PyEnv with Brew regardless as Brew Python contains the following warning:
https://docs.brew.sh/Homebrew-and-Python
arcivanov commentedon May 4, 2021
I see why this is happening and it's brew-specific, unfortunately.
arcivanov commentedon May 4, 2021
@hoxu could you please run the build with
pyb -vXso that the full exception will be printed out?hoxu commentedon May 4, 2021
@dindurthy you could use OSX-shipped
python3forpybuilderexecution by prepending/usr/bintoPATH. Here is an example withwhich:hoxu commentedon May 4, 2021
@arcivanov:
dindurthy commentedon May 4, 2021
Changing PATH won't work without breaking too many other things, unfortunately. I think the only workaround is to not use brew python.
hoxu commentedon Aug 25, 2021
So
change_prefixfunction is comparing/usr/local/Cellar/[email protected]/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.pytosys.prefix, that points to symlink-containing/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.9on Homebrew python.@arcivanov: wouldn't this be fixed by simply changing:
If so, would you accept PR with the above change?
arcivanov commentedon Sep 5, 2021
If you could could you please retest with latest
--preand let me know?hoxu commentedon Sep 6, 2021
First reproduction with 0.12.10:
Then test with
--pre:A different error, I call it progress :)
Is this a regression?
arcivanov commentedon Sep 6, 2021
Yes and no. 😄 This is apparently a bug in virtualenv, which is bundled in PyB. Let me see if VEnv can fix it on their end.
arcivanov commentedon Sep 6, 2021
@hoxu
Would you kindly please:
pip3 install --user virtualenvinto your homebrewed Python environment.virtualenv -vvv --with-traceback ~/testvenvhoxu commentedon Sep 6, 2021
So nope, doesn't fail. Let me know if you need the full output regardless.
arcivanov commentedon Sep 6, 2021
Could you please post the shebang of the virtualenv file (first line)?
And yes please post the whole output.
hoxu commentedon Sep 7, 2021
15 remaining items
hoxu commentedon Sep 14, 2021
I run pybuilder mostly with a custom build script in a virtualenv like this:
But I get the same
AssertionErroroutside virtualenv with pybuilder installed withpip3 install --user pybuilder==0.12.10.Apologies for not having enough time to dig properly into this.
Maybe @dindurthy could take a look at the GitHub Actions workflow logs and see if there are any differences to local execution?
hoxu commentedon Sep 14, 2021
Same exception with pybuilder installed with
pip3 install pybuilderas well.hoxu commentedon Sep 14, 2021
Here is a diff from mine to GHA:
arcivanov commentedon Sep 15, 2021
Rejoice! I was able to reproduce this issue on Linux :) At least the
StopIterationpart that is.hoxu commentedon Sep 15, 2021
@arcivanov let me know when
--prewith #794 is available, so that I can try to reproduce this with theStopIterationfix. Good job fixing it :)arcivanov commentedon Sep 15, 2021
@hoxu go ahead please with
--pretesting. :)arcivanov commentedon Sep 16, 2021
@hoxu did you have a chance to try it out?
hoxu commentedon Sep 17, 2021
Working on other projects, but a quick test with
--prePyBuilder version 0.13.0.dev20210917052200&Python 3.9.7seems to indicate that this issue is fixed! Awesome, good job!I think this can be closed after a release.
arcivanov commentedon Sep 17, 2021
Glad to hear! The release is a bit away, as an issue in virtualenv has been discovered as well.
Prepare 0.13.0
Prepare 0.13.0
Prepare 0.13.0
Prepare 0.13.0