Skip to content

Commit

Permalink
Drop usage of distutils
Browse files Browse the repository at this point in the history
In Python 3.10 and 3.11, distutils has been formally marked as
deprecated. Code that imports distutils will no longer work from Python
3.12.
  • Loading branch information
terceiro committed Jul 27, 2023
1 parent 4edbb5b commit b7a2a18
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ledgerautosync/ledgerwrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@


import csv
import distutils.spawn
import logging
import os
import re
import subprocess
from queue import Empty, Queue
from shutil import which as find_executable
from subprocess import PIPE, Popen
from threading import Thread

Expand Down Expand Up @@ -85,14 +85,14 @@ def __init__(self):
class Ledger(MetaLedger):
@staticmethod
def available():
return (distutils.spawn.find_executable("ledger") is not None) and (
return (find_executable("ledger") is not None) and (
Popen(
["ledger", "--version"], stdout=PIPE, universal_newlines=True
).communicate()[0]
).startswith("Ledger 3")

def __init__(self, ledger_file=None, no_pipe=True):
if distutils.spawn.find_executable("ledger") is None:
if find_executable("ledger") is None:
raise Exception("ledger was not found in $PATH")
self._item = ""

Expand Down Expand Up @@ -245,7 +245,7 @@ def get_autosync_payee(self, payee, account):
class HLedger(MetaLedger):
@staticmethod
def available():
return distutils.spawn.find_executable("hledger") is not None
return find_executable("hledger") is not None

@staticmethod
def quote(a):
Expand All @@ -257,7 +257,7 @@ def quote_str(s):
return [quote_str(s) for s in a]

def __init__(self, ledger_file=None):
if distutils.spawn.find_executable("hledger") is None:
if find_executable("hledger") is None:
raise Exception("hledger was not found in $PATH")
self.args = ["hledger"]
if ledger_file is not None:
Expand Down

0 comments on commit b7a2a18

Please sign in to comment.