Closed craigds closed 3 months ago
That flag only exists if your platform supports copy. There must be some kind of issue on your machine that our copy detection fails. PR welcome.
Doesn't every filesystem support copy? I'm not sure what that means to be honest.
Can you point me to the code where this detection occurs?
You can only copy something if you can read it https://github.com/pypa/virtualenv/blob/main/src/virtualenv/create/via_global_ref/builtin/ref.py#L64
That makes sense at runtime where the question is "can I copy this specific file?" But it seems that virtualenv is making this decision gloablly before even adding the option to the arg parser. Any idea why that could happen?
We don't want to expose flags that cannot work. If you read the code you will see that the flag is only added if the copy is possible.
I get that. I'm confused though. Your first reply says that the copy detection is based on whether the specific file you're trying to copy can be copied.
But in fact, --copies
isn't even in the --help
info on MacOS. So, I wonder what it's actually based on?
I'm happy to spend some time on this today but I wanted to understand if you were aware of any reasons this could be.
(This is a bug one way or another - copy is possible because python -m venv --copies
works fine without issue on this same machine)
Okay some debugging points to this being caused by homebrew themselves.
> /Users/cdestigter/code/virtualenv/src/virtualenv/create/via_global_ref/api.py(24)can_copy()
-> return not self.copy_error
(Pdb) self.copy_error
'Brew disables copy creation: https://github.com/Homebrew/homebrew-core/issues/138159'
Rather frustrating; the reason I want to use copies is to prevent homebrew from breaking my virtualenvs every time they upgrade python.
I'll raise this issue there though. Thanks for your replies
You're welcome.
You probably should read https://justinmayer.com/posts/homebrew-python-is-not-for-you, I recommend using pyenv instead for Python development.
Issue
The docs specify a
--copies
option which should copy the Python interpreter when creating a virtualenv.This option is not recognised on MacOS.
The stdlib
venv
module is happy to accept the--copies
option (and it works), so this is a shortcoming of thevirtualenv
package.Environment
virtualenv 20.26.1 from /opt/homebrew/lib/python3.12/site-packages/virtualenv/__init__.py
pip list
of the host python wherevirtualenv
is installed:Output of the virtual environment creation