diff --git a/README.md b/README.md
index 28dd721..df1539e 100644
--- a/README.md
+++ b/README.md
@@ -66,8 +66,8 @@ We push a pre-built image to Docker Hub as `dtrx-py/dtrx:latest`, so you can
pull that image and run the tests like so:
```bash
-docker run --rm -it --mount $(pwd)/workspace dtrx-py/dtrx:latest \
- bash -c "cd /workspace && uv run -- tests/compare.py"
+docker run --rm -it --volume $(pwd):/workspace ghcr.io/dtrx-py/dtrx:latest \
+ bash -c "cp -r /workspace ~/scratch && cd ~/scratch && uv run -- tests/compare.py"
```
### Releases
@@ -78,8 +78,9 @@ for maintainers is the below steps:
1. update the version specifier:
```bash
- # update the VERSION value in dtrx/dtrx.py, then:
- ❯ git add dtrx/dtrx.py
+ # update the version appropriately
+ ❯ uv version X.Y.Z
+ ❯ git add pyproject.toml uv.lock
❯ git commit # fill in the commit message
```
diff --git a/dtrx/dtrx.py b/dtrx/dtrx.py
index 00d73b2..bf4bf05 100755
--- a/dtrx/dtrx.py
+++ b/dtrx/dtrx.py
@@ -19,12 +19,11 @@
# You should have received a copy of the GNU General Public License along
# with this program; if not, see .
-# Python 2.3 string methods: 'rfind', 'rindex', 'rjust', 'rstrip'
-
from __future__ import absolute_import, print_function
import errno
import fcntl
+import importlib.metadata
import itertools
import logging
import mimetypes
@@ -35,38 +34,24 @@
import signal
import stat
import struct
+import subprocess
import sys
import tempfile
import termios
import textwrap
import traceback
+import urllib.parse as urlparse
from functools import cmp_to_key, total_ordering
-# Python 3 compatibility hacks commence
-try:
- import urlparse
-except ImportError:
- import urllib.parse as urlparse
-try:
- import subprocess32 as subprocess
-except ImportError:
- import subprocess
-if sys.version_info[0] >= 3:
- get_input = input
+def cmp(a, b):
+ return (a > b) - (a < b)
- def cmp(a, b):
- return (a > b) - (a < b)
-
-else:
- get_input = raw_input # noqa: F821
try:
- set
-except NameError:
- from sets import Set as set
-
-VERSION = "8.6.0"
+ VERSION = importlib.metadata.version("dtrx")
+except importlib.metadata.PackageNotFoundError:
+ VERSION = "DEVELOPMENT"
VERSION_BANNER = """dtrx version %s
Copyright © 2006-2011 Brett Smith
Copyright © 2008 Peter Kelemen
@@ -82,11 +67,6 @@ def cmp(a, b):
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
Public License for more details.""" % (VERSION,)
-# Python3.6 optparse has a hard time parsing this, so ascii transform it
-if sys.version_info[:2] == (3, 6):
- VERSION_BANNER = VERSION_BANNER.encode("ascii", errors="ignore").decode("ascii")
-
-
MATCHING_DIRECTORY = 1
ONE_ENTRY_KNOWN = 2
BOMB = 3
@@ -172,27 +152,9 @@ def __init__(self, iostream):
flags = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK)
- def python_2_readlines(self):
- # XXX: There seems to be a bug in Python 2 where readline() returns
- # "IOError: [Errno 11] Resource temporarily unavailable" on a
- # non-blocking read from a pipe where the output lacks a newline.
- # It doesn't happen in Python 3, so this hack can be deleted once we
- # no longer care about Python 2.
- out = ""
- try:
- while True:
- # read a single byte at a time until we hit IOError
- out += self.iostream.read(1).decode("ascii", "ignore")
- except IOError:
- pass
- return out.splitlines(True)
-
def readlines(self):
- if sys.version_info[0] >= 3:
- out = self.iostream.readlines()
- return [line.decode("ascii", "ignore") for line in out]
- else:
- return self.python_2_readlines()
+ out = self.iostream.readlines()
+ return [line.decode("ascii", "ignore") for line in out]
class ExtractorError(Exception):
@@ -1057,7 +1019,7 @@ def ask_question(self, question):
while True:
print("\n".join(question))
try:
- answer = get_input(self.prompt)
+ answer = input(self.prompt)
except EOFError:
return self.answers[""]
try: