Dear maintainer,

I've prepared an NMU for dh-virtualenv (versioned as 1.2.2-1.7). The diff
is attached to this message.

Regards.

diff -Nru dh-virtualenv-1.2.2/debian/changelog 
dh-virtualenv-1.2.2/debian/changelog
--- dh-virtualenv-1.2.2/debian/changelog        2024-07-14 16:57:26.000000000 
+0200
+++ dh-virtualenv-1.2.2/debian/changelog        2025-05-04 20:04:57.000000000 
+0200
@@ -1,3 +1,10 @@
+dh-virtualenv (1.2.2-1.7) unstable; urgency=medium
+
+  * Non-maintainer upload.
+  * Cherry-pick upstream patch fixing venv options (Closes: #1104696)
+
+ -- Ferenc Wágner <[email protected]>  Sun, 04 May 2025 20:04:57 +0200
+
 dh-virtualenv (1.2.2-1.6) unstable; urgency=medium
 
   * Non-maintainer upload
diff -Nru dh-virtualenv-1.2.2/debian/patches/0002-fix-virtualenv-options.patch 
dh-virtualenv-1.2.2/debian/patches/0002-fix-virtualenv-options.patch
--- dh-virtualenv-1.2.2/debian/patches/0002-fix-virtualenv-options.patch        
1970-01-01 01:00:00.000000000 +0100
+++ dh-virtualenv-1.2.2/debian/patches/0002-fix-virtualenv-options.patch        
2025-05-04 20:04:29.000000000 +0200
@@ -0,0 +1,168 @@
+From 02dbaa46ef2c75c5863628cc8f77d37a18d2c051 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Arnold=20Cz=C3=A9m=C3=A1n?= <[email protected]>
+Date: Thu, 22 Oct 2020 14:26:56 +0200
+Subject: [PATCH] dh_virtualenv/deployment.py: fix virtualenv options
+
+The built-in python3 venv has neither '--setuptools',
+nor '--verbose' switch.
+---
+ dh_virtualenv/cmdline.py    | 30 ++++++++++++++++++++++++++++--
+ dh_virtualenv/deployment.py |  8 ++++----
+ doc/changes.rst             |  5 +++++
+ doc/usage.rst               |  1 +
+ test/test_cmdline.py        | 16 ++++++++++++++++
+ test/test_deployment.py     | 14 ++++++++++++++
+ 6 files changed, 68 insertions(+), 6 deletions(-)
+
+Index: dh-virtualenv-1.2.2/dh_virtualenv/cmdline.py
+===================================================================
+--- dh-virtualenv-1.2.2.orig/dh_virtualenv/cmdline.py  2025-05-04 
20:04:23.607140286 +0200
++++ dh-virtualenv-1.2.2/dh_virtualenv/cmdline.py       2025-05-04 
20:04:23.599140410 +0200
+@@ -77,6 +77,28 @@
+         setattr(parser.values, '_test_flag_seen', True)
+ 
+ 
++def _set_builtin_venv(
++    option, opt_str, value, parser, *args, **kwargs
++):
++    if parser.values.setuptools:
++        raise OptionValueError(
++            '--setuptools flag is not supported by builtin venv module'
++        )
++    else:
++        parser.values.builtin_venv = True
++
++
++def _set_setuptools(
++    option, opt_str, value, parser, *args, **kwargs
++):
++    if parser.values.builtin_venv:
++        raise OptionValueError(
++            '--setuptools flag is not supported by builtin venv module'
++        )
++    else:
++        parser.values.setuptools = True
++
++
+ def get_default_parser():
+     usage = '%prog [options]'
+     parser = DebhelperOptionParser(usage, version='%prog ' + version)
+@@ -86,7 +108,9 @@
+                       help='Do not act on the specified package(s)')
+     parser.add_option('-v', '--verbose', action='store_true',
+                       default=False, help='Turn on verbose mode')
+-    parser.add_option('-s', '--setuptools', action='store_true',
++    parser.add_option('-s', '--setuptools', action='callback',
++                      dest='setuptools',
++                      callback=_set_setuptools,
+                       default=False, help='Use Setuptools instead of 
Distribute')
+     parser.add_option('--extra-index-url', action='append', metavar='URL',
+                       help='Extra index URL(s) to pass to pip.',
+@@ -124,7 +148,9 @@
+                       callback=_check_for_deprecated_options)
+     parser.add_option('--python', metavar='EXECUTABLE',
+                       help='The Python command to use')
+-    parser.add_option('--builtin-venv', action='store_true',
++    parser.add_option('--builtin-venv', action='callback',
++                      dest='builtin_venv',
++                      callback=_set_builtin_venv,
+                       help='Use the built-in venv module. Only works on '
+                       'Python 3.4 and later.')
+     parser.add_option('-D', '--sourcedirectory', dest='sourcedirectory',
+Index: dh-virtualenv-1.2.2/dh_virtualenv/deployment.py
+===================================================================
+--- dh-virtualenv-1.2.2.orig/dh_virtualenv/deployment.py       2025-05-04 
20:04:23.607140286 +0200
++++ dh-virtualenv-1.2.2/dh_virtualenv/deployment.py    2025-05-04 
20:04:23.599140410 +0200
+@@ -150,11 +150,11 @@
+             if self.python:
+                 virtualenv.extend(('--python', self.python))
+ 
+-        if self.setuptools:
+-            virtualenv.append('--setuptools')
++            if self.setuptools:
++                virtualenv.append('--setuptools')
+ 
+-        if self.verbose:
+-            virtualenv.append('--verbose')
++            if self.verbose:
++                virtualenv.append('--verbose')
+ 
+         # Add in any user supplied virtualenv args
+         if self.extra_virtualenv_arg:
+Index: dh-virtualenv-1.2.2/doc/changes.rst
+===================================================================
+--- dh-virtualenv-1.2.2.orig/doc/changes.rst   2025-05-04 20:04:23.607140286 
+0200
++++ dh-virtualenv-1.2.2/doc/changes.rst        2025-05-04 20:04:23.603140347 
+0200
+@@ -8,6 +8,11 @@
+ .. _`git history`: https://github.com/spotify/dh-virtualenv/commits/master
+ 
+ 
++Unreleased
++==========
++
++* Fix --verbose and --setuptools command line argument usage together with 
--builtin-venv
++
+ 1.2.2
+ =====
+ 
+Index: dh-virtualenv-1.2.2/doc/usage.rst
+===================================================================
+--- dh-virtualenv-1.2.2.orig/doc/usage.rst     2025-05-04 20:04:23.607140286 
+0200
++++ dh-virtualenv-1.2.2/doc/usage.rst  2025-05-04 20:04:23.603140347 +0200
+@@ -189,6 +189,7 @@
+ .. option:: --setuptools
+ 
+    Use setuptools instead of distribute in the virtualenv.
++   Not supported when using builtin `venv` module with 
:option:`--builtin-venv`.
+ 
+ .. option:: --setuptools-test
+ 
+Index: dh-virtualenv-1.2.2/test/test_cmdline.py
+===================================================================
+--- dh-virtualenv-1.2.2.orig/test/test_cmdline.py      2025-05-04 
20:04:23.607140286 +0200
++++ dh-virtualenv-1.2.2/test/test_cmdline.py   2025-05-04 20:04:23.603140347 
+0200
+@@ -170,3 +170,19 @@
+     parser = cmdline.get_default_parser()
+     opts, args = parser.parse_args(['--use-system-packages'])
+     eq_(True, opts.use_system_packages)
++
++
++def test_builtin_venv_and_setuptools_conflict():
++    error_message = '--setuptools flag is not supported by builtin venv 
module'
++    args_list = [
++        ['--builtin-venv', '--setuptools'],
++        ['--setuptools', '--builtin-venv'],
++    ]
++
++    for args in args_list:
++        f = get_mocked_stderr()
++        with patch('sys.stderr', f), patch('sys.exit') as sysexit:
++            parser = cmdline.get_default_parser()
++            parser.parse_args(args)
++            ok_(error_message in f.getvalue())
++            sysexit.assert_called_once_with(2)
+Index: dh-virtualenv-1.2.2/test/test_deployment.py
+===================================================================
+--- dh-virtualenv-1.2.2.orig/test/test_deployment.py   2025-05-04 
20:04:23.607140286 +0200
++++ dh-virtualenv-1.2.2/test/test_deployment.py        2025-05-04 
20:04:23.603140347 +0200
+@@ -355,6 +355,20 @@
+ 
+ @patch('tempfile.NamedTemporaryFile', FakeTemporaryFile)
+ @patch('subprocess.check_call')
++def test_create_builtin_venv_with_unsupported_options(callmock):
++    d = Deployment(
++        'test', python='python_interpreter',
++        builtin_venv=True, setuptools=True, verbose=True
++    )
++    d.create_virtualenv()
++    eq_(TEST_VENV_PATH, d.package_dir)
++    callmock.assert_called_with(
++        ['python_interpreter', '-m', 'venv', TEST_VENV_PATH]
++    )
++
++
++@patch('tempfile.NamedTemporaryFile', FakeTemporaryFile)
++@patch('subprocess.check_call')
+ def test_install_package(callmock):
+     d = Deployment('test')
+     d.bin_dir = 'derp'
diff -Nru dh-virtualenv-1.2.2/debian/patches/series 
dh-virtualenv-1.2.2/debian/patches/series
--- dh-virtualenv-1.2.2/debian/patches/series   2023-02-02 19:58:02.000000000 
+0100
+++ dh-virtualenv-1.2.2/debian/patches/series   2025-05-04 20:04:20.000000000 
+0200
@@ -1 +1,2 @@
 0001-Replace-usage-of-inspect.getargspec-with-inspect.get.patch
+0002-fix-virtualenv-options.patch

Reply via email to