Skip to content

Commit

Permalink
chore(deps): allow xopen major version 2 (#1532)
Browse files Browse the repository at this point in the history
See xopen changelog: https://github.com/pycompression/xopen/blob/main/README.rst#v200-2024-03-26

Maintain compatibility with v1 and v2, deprecate v1 with period of 4 months and requiring major version bump

---------

Co-authored-by: Victor Lin <[email protected]>
  • Loading branch information
corneliusroemer and victorlin authored Jul 11, 2024
1 parent 81badd2 commit 920cb9f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## __NEXT__

### Features

* Support xopen major version 2. Deprecate v1. Schedule for removal around November 2024. [#1532][] (@corneliusroemer)

[#1532]: https://github.com/nextstrain/augur/pull/1532

## 25.0.0 (10 July 2024)

Expand Down
4 changes: 4 additions & 0 deletions DEPRECATED.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ These features are deprecated, which means they are no longer maintained and
will go away in a future major version of Augur. They are currently still
available for backwards compatibility, but should not be used in new code.

## `xopen` major version 1

*Deprecated in version __NEXT__ (July 2024). Planned for removal at the earliest with major version 26 not before November 2024*

## `augur parse` preference of `name` over `strain` as the sequence ID field

*Deprecated in February 2024. Planned to be reordered June 2024 or after.*
Expand Down
14 changes: 13 additions & 1 deletion augur/io/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@
from contextlib import contextmanager
from io import IOBase
from textwrap import dedent
from xopen import PipedCompressionReader, PipedCompressionWriter, xopen
from xopen import xopen
from augur.errors import AugurError

# Workaround to maintain compatibility with both xopen v1 and v2
# Around November 2024, we shall drop support for xopen v1
# by removing the try-except block and using
# _PipedCompressionProgram directly
try:
from xopen import _PipedCompressionProgram as PipedCompressionReader
from xopen import _PipedCompressionProgram as PipedCompressionWriter
except ImportError:
from xopen import ( # type: ignore[attr-defined, no-redef]
PipedCompressionReader,
PipedCompressionWriter,
)

ENCODING = "utf-8"

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"phylo-treetime >=0.11.2, <0.12",
"pyfastx >=1.0.0, <3.0",
"scipy ==1.*",
"xopen[zstd] >=1.7.0, ==1.*"
"xopen[zstd] >=1.7.0, <3" # TODO: Deprecated, remove v1 support around November 2024
],
extras_require = {
'dev': [
Expand Down

0 comments on commit 920cb9f

Please sign in to comment.