Bug#1041091: python3-virtualenv: re-execution of virtualenv command removes python-debian's debian directory

2023-08-05 Thread Stefano Rivera
Hi Michael (2023.07.16_01:22:37_+0300)

Forwarded that patch to https://github.com/pypa/setuptools/pull/4001
And one to apply the same behaviour to other packages building with
setuptools.

Stefano

-- 
Stefano Rivera
  http://tumbleweed.org.za/
  +1 415 683 3272



Bug#1041091: python3-virtualenv: re-execution of virtualenv command removes python-debian's debian directory

2023-07-17 Thread Michael Prokop
* Stefano Rivera [Sat Jul 15, 2023 at 10:22:37PM +]:

> This is a subtle bug. I can reproduce it from upstream sources, from
> https://github.com/pypa/virtualenv/commit/b4564569171628ee839e14853a00f296686cae6a
> to
> https://github.com/pypa/virtualenv/commit/94f3cf581bc00eae81eca8bfd545fc3bec6d4bb6
> 
> The issue is with re-installing setuptools. It seems that:
> setuptools-*.dist-info/top_level.txt contains "debian".
> 
> That started to happen around setuptools 51.3.0, with this commit:
> https://github.com/pypa/setuptools/commit/0df40810ec54590c888ae0e4073d73f731c91f4a
> And the solution is to exclude "debian*" from options.packages.find
> 
> Trivial workaround: build the virtualenv with --no-setuptools. That's
> the future, anyway.

ACK. I can confirm, that virtualenv's --no-setuptools works around
this behavior. Thanks for your fast reply and looking into this,
Stefano, appreciated.

regards
-mika-


signature.asc
Description: PGP signature


Bug#1041091: python3-virtualenv: re-execution of virtualenv command removes python-debian's debian directory

2023-07-15 Thread Stefano Rivera
Control: reassign -1 setuptools
Control: found -1 setuptools/51.3.3-1
Control: affects -1 virtualenv
Control: tag -1 + patch

Hi Michael (2023.07.14_19:18:51_+)

This is a subtle bug. I can reproduce it from upstream sources, from
https://github.com/pypa/virtualenv/commit/b4564569171628ee839e14853a00f296686cae6a
to
https://github.com/pypa/virtualenv/commit/94f3cf581bc00eae81eca8bfd545fc3bec6d4bb6

The issue is with re-installing setuptools. It seems that:
setuptools-*.dist-info/top_level.txt contains "debian".

That started to happen around setuptools 51.3.0, with this commit:
https://github.com/pypa/setuptools/commit/0df40810ec54590c888ae0e4073d73f731c91f4a
And the solution is to exclude "debian*" from options.packages.find

Trivial workaround: build the virtualenv with --no-setuptools. That's
the future, anyway.

Stefano

-- 
Stefano Rivera
  http://tumbleweed.org.za/
  +1 415 683 3272
Exclude "debian" from top_level.txt.
It gets discovered because it's a top-level directory in the source tree, but it isn't a module we install.

Author: Stefano Rivera 
Bug-Debian: https://bugs.debian.org/1041091
Forwarded: not-needed
--- a/setup.cfg
+++ b/setup.cfg
@@ -35,6 +35,7 @@
 	*.tests
 	*.tests.*
 	tools*
+	debian*
 
 [options.extras_require]
 testing = 


Bug#1041091: python3-virtualenv: re-execution of virtualenv command removes python-debian's debian directory

2023-07-14 Thread Michael Prokop
Package: python3-virtualenv
Version: 20.17.1+ds-1
Severity: important

Hi,

as funny as the subject might sound, this took a while to track
down. :) Reporting this, since this might bite other folks as well,
and I also have STR.

The behavior that was present until and incl. bullseye was as
follows (newlines between command lines added by myself to make it
easier to read/parse/follow):

| % podman run --pull=always --rm -i -t debian:bullseye bash
| root@9b5d718485de:/# cd
| root@9b5d718485de:~# apt update ; apt -y install python3-virtualenv
| [...]
| root@9b5d718485de:~# virtualenv --python=python3 virtualenv
| created virtual environment CPython3.9.2.final.0-64 in 162ms
|   creator CPython3Posix(dest=/root/virtualenv, clear=False, 
no_vcs_ignore=False, global=False)
|   seeder FromAppData(download=False, pip=bundle, setuptools=bundle, 
wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
| added seed packages: pip==20.3.4, pkg_resources==0.0.0, 
setuptools==44.1.1, wheel==0.34.2
|   activators 
BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
|
| root@9b5d718485de:~# . virtualenv/bin/activate
|
| (virtualenv) root@9b5d718485de:~# pip install python-debian
| Collecting python-debian
|   Downloading python_debian-0.1.49-py3-none-any.whl (132 kB)
|  || 132 kB 5.9 MB/s
| Collecting chardet
|   Downloading chardet-5.1.0-py3-none-any.whl (199 kB)
|  || 199 kB 18.4 MB/s
| Installing collected packages: chardet, python-debian
| Successfully installed chardet-5.1.0 python-debian-0.1.49
|
| (virtualenv) root@9b5d718485de:~# python3 -c "from debian import deb822"
|
| (virtualenv) root@9b5d718485de:~# virtualenv --python=python3 virtualenv
| created virtual environment CPython3.9.2.final.0-64 in 142ms
|   creator CPython3Posix(dest=/root/virtualenv, clear=False, 
no_vcs_ignore=False, global=False)
|   seeder FromAppData(download=False, pip=bundle, setuptools=bundle, 
wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
| added seed packages: chardet==5.1.0, pip==20.3.4, pkg_resources==0.0.0, 
python_debian==0.1.49, setuptools==44.1.1, wheel==0.34.2
|   activators 
BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
|
| (virtualenv) root@9b5d718485de:~# python3 -c "from debian import deb822"

So everything fine, no problems.

But on bookworm, this doesn't behave as such any longer:

| % podman run --pull=always --rm -i -t debian:bookworm bash
| root@491ed520fc26:/# cd
| root@491ed520fc26:~# apt update ; apt -y install python3-virtualenv
| [...]
| root@491ed520fc26:~# virtualenv --python=python3 virtualenv
| created virtual environment CPython3.11.2.final.0-64 in 439ms
|   creator CPython3Posix(dest=/root/virtualenv, clear=False, 
no_vcs_ignore=False, global=False)
|   seeder FromAppData(download=False, pip=bundle, setuptools=bundle, 
wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
| added seed packages: pip==23.0.1, setuptools==66.1.1, wheel==0.38.4
|   activators 
BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
|
| root@491ed520fc26:~# . virtualenv/bin/activate
|
| (virtualenv) root@491ed520fc26:~# pip install python-debian
| Collecting python-debian
|   Downloading python_debian-0.1.49-py3-none-any.whl (132 kB)
|   132.5/132.5 kB 3.7 MB/s eta 
0:00:00
| Collecting chardet
|   Downloading chardet-5.1.0-py3-none-any.whl (199 kB)
|   199.1/199.1 kB 6.5 MB/s eta 
0:00:00
| Installing collected packages: chardet, python-debian
| Successfully installed chardet-5.1.0 python-debian-0.1.49
|
| (virtualenv) root@491ed520fc26:~# python3 -c "from debian import deb822"
|
| (virtualenv) root@491ed520fc26:~# virtualenv --python=python3 virtualenv
| created virtual environment CPython3.11.2.final.0-64 in 341ms
|   creator CPython3Posix(dest=/root/virtualenv, clear=False, 
no_vcs_ignore=False, global=False)
|   seeder FromAppData(download=False, pip=bundle, setuptools=bundle, 
wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
| added seed packages: chardet==5.1.0, pip==23.0.1, python_debian==0.1.49, 
setuptools==66.1.1, wheel==0.38.4
|   activators 
BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
|
| (virtualenv) root@491ed520fc26:~# python3 -c "from debian import deb822"
| Traceback (most recent call last):
|   File "", line 1, in 
| ModuleNotFoundError: No module named 'debian'

So the re-execution of `virtualenv` for some reason removes the
debian directory of python-debian on the filesystem. :-/
To highlight this from another run:

| (virtualenv) root@b5d06fb7:~# ls 
virtualenv/lib/python3.11/site-packages/debian
| __init__.py  __pycache__  _arch_table.py  _deb822_repro  _util.py  
_version.py