* debian/patches/avoid_distutils_spawn.patch: New patch, implements
find_executable() method and drops import of distutils.spawn. * debian/control (patroni/Depends): Removed python3-distutils.
This commit is contained in:
parent
0ddaf39598
commit
aa406aea32
5
debian/changelog
vendored
5
debian/changelog
vendored
|
@ -1,6 +1,9 @@
|
|||
patroni (1.6.0-4) UNRELEASED; urgency=medium
|
||||
|
||||
*
|
||||
[ Michael Banck ]
|
||||
* debian/patches/avoid_distutils_spawn.patch: New patch, implements
|
||||
find_executable() method and drops import of distutils.spawn.
|
||||
* debian/control (patroni/Depends): Removed python3-distutils.
|
||||
|
||||
-- Debian PostgreSQL Maintainers <team+postgresql@tracker.debian.org> Mon, 07 Oct 2019 20:41:43 +0200
|
||||
|
||||
|
|
3
debian/control
vendored
3
debian/control
vendored
|
@ -46,8 +46,7 @@ Homepage: https://github.com/zalando/patroni
|
|||
Package: patroni
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, ${python3:Depends}, lsb-base (>= 3.0-6), python3-psycopg2,
|
||||
python3-etcd (>= 0.4.3) | python3-consul (>= 0.7.0) | python3-kazoo | python3-kubernetes,
|
||||
python3-distutils
|
||||
python3-etcd (>= 0.4.3) | python3-consul (>= 0.7.0) | python3-kazoo | python3-kubernetes
|
||||
Recommends: iproute2
|
||||
Suggests: postgresql, etcd-server | consul | zookeeperd, haproxy, patroni-doc
|
||||
Description: PostgreSQL High Availability with ZooKeeper, etcd, Consul, or Kubernetes
|
||||
|
|
71
debian/patches/avoid_distutils_spawn.patch
vendored
Normal file
71
debian/patches/avoid_distutils_spawn.patch
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
commit 0a1d9b0a251b70df7eb4b4004c86e169cddd8ed1
|
||||
Author: Alexander Kukushkin <cyberdemn@gmail.com>
|
||||
Date: Mon Aug 26 09:38:47 2019 +0200
|
||||
|
||||
Get rid from distutils module dependency (#1146)
|
||||
|
||||
We are using only one function from there, `find_executable()` and it is better to implement a similar function in Patroni rather than add `distutils` module into requirements.txt
|
||||
|
||||
Index: patroni/patroni/ctl.py
|
||||
===================================================================
|
||||
--- patroni.orig/patroni/ctl.py
|
||||
+++ patroni/patroni/ctl.py
|
||||
@@ -25,7 +25,6 @@ import yaml
|
||||
|
||||
from click import ClickException
|
||||
from contextlib import contextmanager
|
||||
-from distutils.spawn import find_executable
|
||||
from patroni.config import Config
|
||||
from patroni.dcs import get_dcs as _get_dcs
|
||||
from patroni.exceptions import PatroniException
|
||||
@@ -1106,6 +1105,24 @@ def apply_yaml_file(data, filename):
|
||||
return format_config_for_editing(changed_data), changed_data
|
||||
|
||||
|
||||
+def find_executable(executable, path=None):
|
||||
+ _, ext = os.path.splitext(executable)
|
||||
+
|
||||
+ if (sys.platform == 'win32') and (ext != '.exe'):
|
||||
+ executable = executable + '.exe'
|
||||
+
|
||||
+ if os.path.isfile(executable):
|
||||
+ return executable
|
||||
+
|
||||
+ if path is None:
|
||||
+ path = os.environ.get('PATH', os.defpath)
|
||||
+
|
||||
+ for p in path.split(os.pathsep):
|
||||
+ f = os.path.join(p, executable)
|
||||
+ if os.path.isfile(f):
|
||||
+ return f
|
||||
+
|
||||
+
|
||||
def invoke_editor(before_editing, cluster_name):
|
||||
"""Starts editor command to edit configuration in human readable format
|
||||
|
||||
Index: patroni/tests/test_ctl.py
|
||||
===================================================================
|
||||
--- patroni.orig/tests/test_ctl.py
|
||||
+++ patroni/tests/test_ctl.py
|
||||
@@ -9,7 +9,7 @@ from datetime import datetime, timedelta
|
||||
from mock import patch, Mock
|
||||
from patroni.ctl import ctl, store_config, load_config, output_members, request_patroni, get_dcs, parse_dcs, \
|
||||
get_all_members, get_any_member, get_cursor, query_member, configure, PatroniCtlException, apply_config_changes, \
|
||||
- format_config_for_editing, show_diff, invoke_editor, format_pg_version
|
||||
+ format_config_for_editing, show_diff, invoke_editor, format_pg_version, find_executable
|
||||
from patroni.dcs.etcd import Client, Failover
|
||||
from patroni.utils import tzutc
|
||||
from psycopg2 import OperationalError
|
||||
@@ -587,3 +587,12 @@ class TestCtl(unittest.TestCase):
|
||||
def test_format_pg_version(self):
|
||||
self.assertEqual(format_pg_version(100001), '10.1')
|
||||
self.assertEqual(format_pg_version(90605), '9.6.5')
|
||||
+
|
||||
+ @patch('sys.platform', 'win32')
|
||||
+ def test_find_executable(self):
|
||||
+ with patch('os.path.isfile', Mock(return_value=True)):
|
||||
+ self.assertEqual(find_executable('vim'), 'vim.exe')
|
||||
+ with patch('os.path.isfile', Mock(return_value=False)):
|
||||
+ self.assertIsNone(find_executable('vim'))
|
||||
+ with patch('os.path.isfile', Mock(side_effect=[False, True])):
|
||||
+ self.assertEqual(find_executable('vim', '/'), '/vim.exe')
|
1
debian/patches/series
vendored
1
debian/patches/series
vendored
|
@ -4,3 +4,4 @@ check_postmaster.patch
|
|||
acceptance_tests_system_patroni.patch
|
||||
disable_postgresql.conf_chmod.patch
|
||||
acceptance_tests_timeouts.patch
|
||||
avoid_distutils_spawn.patch
|
||||
|
|
Loading…
Reference in a new issue