Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove versioneer Python 3.12 compatibility #160

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/vcf_from_scratch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
# -*- coding: utf-8 -*-
"""Create VCF from scratch using vcfpy."""

import argparse
import itertools
import sys
import time

import vcfpy

Expand Down
1 change: 1 addition & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

# Fancier output for py.test and dependencies
pytest-sugar >=0.8.0
pytest-cov
termcolor >=1.1.0

# Sphinx and dependencies
Expand Down
14 changes: 0 additions & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exclude =
.tox
docs/
vcfpy/__init__.py
versioneer.py
ignore = E203, E266, E501, W503
max-line-length = 80
max-complexity = 18
Expand All @@ -21,16 +20,3 @@ pep8ignore =
examples/*.py E501
tests/*.py E501
vcfpy/*.py F401


# See the docstring in versioneer.py for instructions. Note that you must
# re-run 'versioneer.py setup' after changing this section, and commit the
# resulting files.

[versioneer]
VCS = git
style = pep440
versionfile_source = vcfpy/_version.py
versionfile_build = vcfpy/_version.py
tag_prefix = v
parentdir_prefix = vcfpy
17 changes: 10 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

from setuptools import setup

import versioneer


def parse_requirements(path):
"""Parse ``requirements.txt`` at ``path``."""
Expand Down Expand Up @@ -43,14 +41,19 @@ def parse_requirements(path):

test_requirements = parse_requirements("requirements/test.txt")

package_root = os.path.abspath(os.path.dirname(__file__))
version = {}
with open(os.path.join(package_root, "vcfpy/_version.py")) as fp:
exec(fp.read(), version)
version = version["__version__"]

setup(
name="vcfpy",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
version=version,
description=("Python 3 VCF library with good support for both reading and writing"),
long_description=readme + "\n\n" + history,
author="Manuel Holtgrewe",
author_email="manuel.holtgrewe@bihealth.de",
author_email="manuel.holtgrewe@bih-charite.de",
url="https://github.com/bihealth/vcfpy",
packages=["vcfpy"],
package_dir={"vcfpy": "vcfpy"},
Expand All @@ -65,11 +68,11 @@ def parse_requirements(path):
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
],
test_suite="tests",
tests_require=test_requirements,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_reader_fetch():


def test_writer(header_samples, tmpdir_factory):
O = vcfpy.OrderedDict
OD = vcfpy.OrderedDict
# open temporary file and setup the Writer with header
path = tmpdir_factory.mktemp("write_header").join("out.vcf")
header, _ = header_samples
Expand All @@ -98,12 +98,12 @@ def test_writer(header_samples, tmpdir_factory):
[record.Substitution(record.SNV, "T")],
None,
[],
O(),
OD(),
["GT"],
[
record.Call("NA00001", O(GT="0/1")),
record.Call("NA00002", O(GT="0/0")),
record.Call("NA00003", O(GT="1/1")),
record.Call("NA00001", OD(GT="0/1")),
record.Call("NA00002", OD(GT="0/0")),
record.Call("NA00003", OD(GT="1/1")),
],
)
# open writer
Expand Down
2 changes: 0 additions & 2 deletions tests/test_parser_helpers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
"""Test for the helper routines in the vcfpy.parser module"""

import pytest

from vcfpy import parser

__author__ = "Manuel Holtgrewe <manuel.holtgrewe@bihealth.de>"
Expand Down
2 changes: 0 additions & 2 deletions tests/test_parser_parse_header_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

import sys

import pytest

from vcfpy import header
from vcfpy import parser

Expand Down
1 change: 0 additions & 1 deletion tests/test_parser_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def test_header_checker_missing_fileformat():
lines = [header.HeaderLine("key", "value")]
hdr = header.Header(lines=lines, samples=header.SamplesInfos(["NA001"]))
# setup HeaderChecker
stream = io.StringIO()
checker = parser.HeaderChecker()
# execute
with pytest.raises(exceptions.InvalidHeaderException):
Expand Down
5 changes: 2 additions & 3 deletions tests/test_reader_nosample.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
"""Tests for reading with file without samples"""

from io import StringIO
import textwrap

import vcfpy


def test_reading_parse_nosample(tmpdir, nosample_vcf_file):
def test_reading_parse_nosample_read_only(tmpdir, nosample_vcf_file):
"""Test reading of VCF file without any samples."""
# Perform record-wise copying, saving results in records
records = []
Expand All @@ -18,7 +17,7 @@ def test_reading_parse_nosample(tmpdir, nosample_vcf_file):
assert len(records) == 5


def test_reading_parse_nosample(tmpdir, nosample_vcf_file):
def test_reading_parse_nosample_also_write(tmpdir, nosample_vcf_file):
"""Read VCF file without samples, write file with samples."""
# Perform record-wise copying, saving results in records
path_out = tmpdir.mkdir("output").join("output.vcf")
Expand Down
1 change: 1 addition & 0 deletions tests/test_vcfs_from_the_wild.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@
def test_read_vcfs_from_the_wild(filename):
path = os.path.join(os.path.dirname(__file__), "vcfs_from_the_wild", filename)
r = reader.Reader.from_path(path)
_ = r
30 changes: 15 additions & 15 deletions tests/test_write_bgzf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def check_file(path, line):


def test_write_minimal_record_writer_from_path(header_samples, tmpdir_factory):
O = vcfpy.OrderedDict
OD = vcfpy.OrderedDict
# open temporary file and setup the Writer with header
path = tmpdir_factory.mktemp("write_header").join("out.vcf.gz")
header, _ = header_samples
Expand All @@ -76,12 +76,12 @@ def test_write_minimal_record_writer_from_path(header_samples, tmpdir_factory):
[record.Substitution(record.SNV, "T")],
None,
[],
O(),
OD(),
["GT"],
[
record.Call("NA00001", O(GT="0/1")),
record.Call("NA00002", O(GT="0/0")),
record.Call("NA00003", O(GT="1/1")),
record.Call("NA00001", OD(GT="0/1")),
record.Call("NA00002", OD(GT="0/0")),
record.Call("NA00003", OD(GT="1/1")),
],
)
# write out the record, close file to ensure flushing to disk
Expand All @@ -93,7 +93,7 @@ def test_write_minimal_record_writer_from_path(header_samples, tmpdir_factory):


def test_write_minimal_record_writer_from_stream_path(header_samples, tmpdir_factory):
O = vcfpy.OrderedDict
OD = vcfpy.OrderedDict
# open temporary file and setup the Writer with header
path = tmpdir_factory.mktemp("write_header").join("out.vcf.gz")
header, _ = header_samples
Expand All @@ -108,12 +108,12 @@ def test_write_minimal_record_writer_from_stream_path(header_samples, tmpdir_fac
[record.Substitution(record.SNV, "T")],
None,
[],
O(),
OD(),
["GT"],
[
record.Call("NA00001", O(GT="0/1")),
record.Call("NA00002", O(GT="0/0")),
record.Call("NA00003", O(GT="1/1")),
record.Call("NA00001", OD(GT="0/1")),
record.Call("NA00002", OD(GT="0/0")),
record.Call("NA00003", OD(GT="1/1")),
],
)
# write out the record, close file to ensure flushing to disk
Expand All @@ -125,7 +125,7 @@ def test_write_minimal_record_writer_from_stream_path(header_samples, tmpdir_fac


def test_write_minimal_record_writer_from_stream_use_bgzf(header_samples, tmpdir_factory):
O = vcfpy.OrderedDict
OD = vcfpy.OrderedDict
# open temporary file and setup the Writer with header
path = tmpdir_factory.mktemp("write_header").join("out.vcf.gz")
header, samples = header_samples
Expand All @@ -140,12 +140,12 @@ def test_write_minimal_record_writer_from_stream_use_bgzf(header_samples, tmpdir
[record.Substitution(record.SNV, "T")],
None,
[],
O(),
OD(),
["GT"],
[
record.Call("NA00001", O(GT="0/1")),
record.Call("NA00002", O(GT="0/0")),
record.Call("NA00003", O(GT="1/1")),
record.Call("NA00001", OD(GT="0/1")),
record.Call("NA00002", OD(GT="0/0")),
record.Call("NA00003", OD(GT="1/1")),
],
)
# write out the record, close file to ensure flushing to disk
Expand Down
36 changes: 17 additions & 19 deletions tests/test_write_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def header_samples():


def test_write_minimal_record(header_samples, tmpdir_factory):
O = vcfpy.OrderedDict
OD = vcfpy.OrderedDict
# open temporary file and setup the Writer with header
path = tmpdir_factory.mktemp("write_header").join("out.vcf")
header, _ = header_samples
Expand All @@ -61,12 +61,12 @@ def test_write_minimal_record(header_samples, tmpdir_factory):
[record.Substitution(record.SNV, "T")],
None,
[],
O(),
OD(),
["GT"],
[
record.Call("NA00001", O(GT="0/1")),
record.Call("NA00002", O(GT="0/0")),
record.Call("NA00003", O(GT="1/1")),
record.Call("NA00001", OD(GT="0/1")),
record.Call("NA00002", OD(GT="0/0")),
record.Call("NA00003", OD(GT="1/1")),
],
)
# write out the record, close file to ensure flushing to disk
Expand All @@ -80,8 +80,7 @@ def test_write_minimal_record(header_samples, tmpdir_factory):


def test_write_annotated_record(header_samples, tmpdir_factory):
O = vcfpy.OrderedDict
S = record.Substitution
OD = vcfpy.OrderedDict
# open temporary file and setup the Writer with header
path = tmpdir_factory.mktemp("write_annotated_record").join("out.vcf")
header, _ = header_samples
Expand All @@ -95,12 +94,12 @@ def test_write_annotated_record(header_samples, tmpdir_factory):
[record.Substitution(record.SNV, "T"), record.Substitution(record.SNV, "G")],
50,
["PASS"],
O([("DP", 93), ("AF", [0.3, 0.2]), ("DB", True)]),
OD([("DP", 93), ("AF", [0.3, 0.2]), ("DB", True)]),
["GT", "DP", "GQ", "HQ"],
[
record.Call("NA00001", O(GT="0/1", DP=30, GQ=40, HQ=[1, 2])),
record.Call("NA00002", O(GT="0/2", DP=31, GQ=41, HQ=[3, 4])),
record.Call("NA00003", O(GT="1/2", DP=32, GQ=42, HQ=[5, 6])),
record.Call("NA00001", OD(GT="0/1", DP=30, GQ=40, HQ=[1, 2])),
record.Call("NA00002", OD(GT="0/2", DP=31, GQ=41, HQ=[3, 4])),
record.Call("NA00003", OD(GT="1/2", DP=32, GQ=42, HQ=[5, 6])),
],
)
# write out the record, close file to ensure flushing to disk
Expand All @@ -114,8 +113,7 @@ def test_write_annotated_record(header_samples, tmpdir_factory):


def test_write_record_with_escaping(header_samples, tmpdir_factory):
O = vcfpy.OrderedDict
S = record.Substitution
OD = vcfpy.OrderedDict
# open temporary file and setup the Writer with header
path = tmpdir_factory.mktemp("write_header").join("out.vcf")
header, _ = header_samples
Expand All @@ -129,12 +127,12 @@ def test_write_record_with_escaping(header_samples, tmpdir_factory):
[record.Substitution(record.SNV, "T")],
None,
[],
O([("ANNO", ["Here,are%some chars", "%25"])]),
OD([("ANNO", ["Here,are%some chars", "%25"])]),
["GT", "FT"],
[
record.Call("NA00001", O(GT="0/1", FT=["%25", "FOO"])),
record.Call("NA00002", O(GT="0/0", FT=[])),
record.Call("NA00003", O(GT="1/1", FT=[])),
record.Call("NA00001", OD(GT="0/1", FT=["%25", "FOO"])),
record.Call("NA00002", OD(GT="0/0", FT=[])),
record.Call("NA00003", OD(GT="1/1", FT=[])),
],
)
# write out the record, close file to ensure flushing to disk
Expand All @@ -151,13 +149,13 @@ def test_write_record_with_escaping(header_samples, tmpdir_factory):


def test_write_record_no_samples(tmpdir_factory):
O = vcfpy.OrderedDict
OD = vcfpy.OrderedDict
# Create header without samples
hdr = header.Header(
lines=[header.HeaderLine("fileformat", "VCFv4.0")], samples=header.SamplesInfos([])
)
# construct record to write out from scratch
r = record.Record("20", 100, [], "C", [record.Substitution(record.SNV, "T")], None, [], O())
r = record.Record("20", 100, [], "C", [record.Substitution(record.SNV, "T")], None, [], OD())
# Write out header and record
path = tmpdir_factory.mktemp("write_header").join("out.vcf")
w = writer.Writer.from_path(path, hdr)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_writer_write_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""


from vcfpy import Reader, Writer, Header, SamplesInfos, Call, UnparsedCall
from vcfpy import Reader, Writer, Header, SamplesInfos


def test_reading_and_write_subset_of_samples(
Expand Down
5 changes: 1 addition & 4 deletions vcfpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,4 @@

from .writer import Writer

from ._version import get_versions

__version__ = get_versions()["version"]
del get_versions
from ._version import __version__
Loading
Loading