[med-svn] [Git][med-team/python-pybedtools][master] 3 commits: d/control: re-instate using pybuild for the autopkgtests

Michael R. Crusoe (@crusoe) gitlab at salsa.debian.org
Fri Dec 27 00:33:54 GMT 2024



Michael R. Crusoe pushed to branch master at Debian Med / python-pybedtools


Commits:
cdef1829 by Michael R. Crusoe at 2024-12-26T10:23:14-08:00
d/control: re-instate using pybuild for the autopkgtests

- - - - -
89e81cf1 by Michael R. Crusoe at 2024-12-26T10:29:50-08:00
d/control: tidy build requirements, use the nodoc and nocheck build profiles

- - - - -
60ba2acd by Michael R. Crusoe at 2024-12-26T16:24:02-08:00
Modernized the build using pybuild-plugin-pyproject

- - - - -


6 changed files:

- debian/changelog
- debian/control
- + debian/patches/doc-build-no-special-path
- debian/patches/series
- + debian/patches/test-tempdir
- debian/rules


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,12 @@
+python-pybedtools (0.10.0-4) UNRELEASED; urgency=medium
+
+  * d/control: re-instate using pybuild for the autopkgtests
+  * d/control: tidy build requirements, use the nodoc and nocheck build
+    profiles
+  * Modernized the build using pybuild-plugin-pyproject
+
+ -- Michael R. Crusoe <crusoe at debian.org>  Thu, 26 Dec 2024 10:23:13 -0800
+
 python-pybedtools (0.10.0-3) unstable; urgency=medium
 
   * Team Upload.


=====================================
debian/control
=====================================
@@ -3,24 +3,24 @@ Maintainer: Debian Med Packaging Team <debian-med-packaging at lists.alioth.debian.
 Uploaders: Michael R. Crusoe <crusoe at debian.org>,
            Steffen Moeller <moeller at debian.org>
 Section: python
-Testsuite: autopkgtest-pkg-python
+Testsuite: autopkgtest-pkg-pybuild
 Priority: optional
 Build-Depends: debhelper-compat (= 13),
                dh-sequence-python3,
+               pybuild-plugin-pyproject,
                bedtools,
                cython3,
                python3-all-dev,
                python3-setuptools,
                python3-pysam,
-               python3-matplotlib,
-               python3-pytest,
+               python3-matplotlib <!nocheck>,
+               python3-pytest <!nocheck>,
                python3-numpy,
-               python3-numpydoc,
-               python3-pandas,
-               python3-psutil,
-               python3-yaml,
-               python3-tk,
-               python3-sphinx,
+               python3-numpydoc <!nodoc>,
+               python3-pandas <!nodoc> <!nocheck>,
+               python3-psutil <!nocheck>,
+               python3-yaml <!nocheck>,
+               python3-sphinx <!nodoc>,
                r-base-core,
                zlib1g-dev
 Standards-Version: 4.6.2
@@ -61,7 +61,7 @@ Multi-Arch: foreign
 Section: doc
 Depends: ${misc:Depends},
          ${sphinxdoc:Depends}
-Suggests: python3-pybedtools|python-pybedtools
+Suggests: python3-pybedtools
 Built-Using: ${sphinxdoc:Built-Using}
 Description: Documentation for pybedtools library
- Shinx-generated documentation.
+ Sphinx-generated documentation.


=====================================
debian/patches/doc-build-no-special-path
=====================================
@@ -0,0 +1,19 @@
+Author: Michael R. Crusoe <crusoe at debian.org>
+Description: pybuild puts the extensions in a different location
+Forwarded: not-needed
+--- python-pybedtools.orig/docs/source/conf.py
++++ python-pybedtools/docs/source/conf.py
+@@ -11,13 +11,6 @@
+ # All configuration values have a default; values that are commented out
+ # serve to show the default.
+ 
+-import sys, os
+-
+-# If extensions (or modules to document with autodoc) are in another directory,
+-# add these directories to sys.path here. If the directory is relative to the
+-# documentation root, use os.path.abspath to make it absolute, like shown here.
+-sys.path.insert(0, os.path.abspath('../..'))
+-
+ from pybedtools import __version__ as version
+ 
+ # -- General configuration -----------------------------------------------------


=====================================
debian/patches/series
=====================================
@@ -5,3 +5,5 @@ add_missing_shebang.patch
 yaml_safe_load.patch
 416.patch
 fix-doctest-imports.py
+doc-build-no-special-path
+test-tempdir


=====================================
debian/patches/test-tempdir
=====================================
@@ -0,0 +1,314 @@
+From: Michael R. Crusoe <crusoe at debian.org>
+Subject: make test temporary directories not in the "test" folder
+Forwarded: https://github.com/daler/pybedtools/pull/419
+
+This prevented the execution of the tests post-installation
+--- python-pybedtools.orig/pybedtools/test/test_1.py
++++ python-pybedtools/pybedtools/test/test_1.py
+@@ -1,24 +1,19 @@
+ import pybedtools
+ import os, difflib, sys
+-from pybedtools import featurefuncs
++import tempfile
++import shutil
++from pathlib import Path
++
++from pybedtools import featurefuncs, filenames
+ import pytest
+ 
+ import threading
+ import warnings
+-from .tfuncs import test_tempdir
+ 
+ unwriteable = "unwriteable"
+ 
+ 
+-def setup_module():
+-    if not os.path.exists(test_tempdir):
+-        os.system("mkdir -p %s" % test_tempdir)
+-    pybedtools.set_tempdir(test_tempdir)
+-
+-
+ def teardown_module():
+-    if os.path.exists(test_tempdir):
+-        os.system("rm -r %s" % test_tempdir)
+     pybedtools.cleanup()
+ 
+ 
+@@ -67,7 +62,8 @@
+     """
+     if os.path.exists(unwriteable):
+         os.system("rm -rf %s" % unwriteable)
+-    pybedtools.set_tempdir(test_tempdir)
++    tempfile.tempdir = None
++    pybedtools.set_tempdir(tempfile.gettempdir())
+ 
+ 
+ def test_interval_index():
+@@ -132,37 +128,24 @@
+     assert x[0]["ID"] == "gene1"
+ 
+ 
+-def test_tabix():
+-    try:
+-        a = pybedtools.example_bedtool("a.bed")
+-        t = a.tabix(force=True)
+-        assert t._tabixed()
+-        results = t.tabix_intervals("chr1:99-200")
+-        results = str(results)
+-        print(results)
+-        assert results == fix(
+-            """
+-        chr1	1	100	feature1	0	+
+-        chr1	100	200	feature2	0	+
+-        chr1	150	500	feature3	0	-"""
+-        )
+-
+-        assert str(t.tabix_intervals(a[2])) == fix(
+-            """
+-        chr1	100	200	feature2	0	+
+-        chr1	150	500	feature3	0	-"""
+-        )
+-
+-    finally:
+-        # clean up
+-        fns = [
+-            pybedtools.example_filename("a.bed.gz"),
+-            pybedtools.example_filename("a.bed.gz.tbi"),
+-        ]
+-        for fn in fns:
+-            if os.path.exists(fn):
+-                os.unlink(fn)
++def test_tabix(tmp_path: Path) -> None:
++    shutil.copy(os.path.join(filenames.data_dir(), "a.bed"), tmp_path)
++    a = pybedtools.BedTool(tmp_path / "a.bed")
++    t = a.tabix(force=True)
++    assert t._tabixed()
++    results = t.tabix_intervals("chr1:99-200")
++    results = str(results)
++    print(results)
++    assert results == fix("""
++    chr1	1	100	feature1	0	+
++    chr1	100	200	feature2	0	+
++    chr1	150	500	feature3	0	-"""
++    )
+ 
++    assert str(t.tabix_intervals(a[2])) == fix("""
++    chr1	100	200	feature2	0	+
++    chr1	150	500	feature3	0	-"""
++    )
+ 
+ def test_tabix_intervals():
+     a = pybedtools.BedTool("chr1 25 30", from_string=True).tabix()
+@@ -503,6 +486,7 @@
+     For example, the first 100 bases of a chromosome are defined as
+     chromStart=0, chromEnd=100, and span the bases numbered 0-99. """
+ 
++    test_tempdir = os.path.abspath(tempfile.gettempdir())
+     fi = os.path.join(test_tempdir, "test.fasta")
+ 
+     s = """
+--- python-pybedtools.orig/pybedtools/test/test_cbedtools.py
++++ python-pybedtools/pybedtools/test/test_cbedtools.py
+@@ -5,17 +5,8 @@
+ from pybedtools import Interval, IntervalFile
+ import pybedtools
+ import pytest
+-from .tfuncs import test_tempdir
+-
+-def setup_module():
+-    if not os.path.exists(test_tempdir):
+-        os.system("mkdir -p %s" % test_tempdir)
+-    pybedtools.set_tempdir(test_tempdir)
+-
+ 
+ def teardown_module():
+-    if os.path.exists(test_tempdir):
+-        os.system("rm -r %s" % test_tempdir)
+     pybedtools.cleanup()
+ 
+ PATH = os.path.dirname(__file__)
+--- python-pybedtools.orig/pybedtools/test/test_contrib.py
++++ python-pybedtools/pybedtools/test/test_contrib.py
+@@ -7,7 +7,7 @@
+ from pybedtools import Interval
+ 
+ # from pybedtools.contrib import Classifier
+-from .tfuncs import setup_module, teardown_module, testdir, test_tempdir, unwriteable
++from .tfuncs import teardown_module
+ 
+ # model for gdc.
+ # chr2L, starts at 1 and spacing is 10bp.
+--- python-pybedtools.orig/pybedtools/test/test_gzip_support.py
++++ python-pybedtools/pybedtools/test/test_gzip_support.py
+@@ -4,17 +4,9 @@
+ 
+ import pybedtools
+ import gzip
+-from .tfuncs import test_tempdir
+ 
+ 
+-def setup_module():
+-    if not os.path.exists(test_tempdir):
+-        os.system("mkdir -p %s" % test_tempdir)
+-    pybedtools.set_tempdir(test_tempdir)
+-
+ def teardown_module():
+-    if os.path.exists(test_tempdir):
+-        os.system("rm -r %s" % test_tempdir)
+     pybedtools.cleanup()
+ 
+ def _make_temporary_gzip(bed_filename):
+--- python-pybedtools.orig/pybedtools/test/test_helpers.py
++++ python-pybedtools/pybedtools/test/test_helpers.py
+@@ -1,7 +1,8 @@
+ import pybedtools
+ import sys
+ import os
+-from .tfuncs import testdir, test_tempdir
++import tempfile
++from .tfuncs import testdir
+ import pytest
+ from pathlib import Path
+ 
+@@ -41,6 +42,7 @@
+ 
+     # make a fake tempfile, not created during this pybedtools session
+     pybedtools.cleanup()
++    test_tempdir = os.path.abspath(tempfile.gettempdir())
+     testfn = Path(test_tempdir) / "pybedtools.TESTING.tmp"
+     testfn.parent.mkdir(parents=True, exist_ok=True)
+     testfn.touch()
+--- python-pybedtools.orig/pybedtools/test/test_issues.py
++++ python-pybedtools/pybedtools/test/test_issues.py
+@@ -1,6 +1,7 @@
+ import pybedtools
+ import gzip
+ import os
++import shutil
+ import subprocess
+ import sys
+ from textwrap import dedent
+@@ -8,21 +9,13 @@
+ import pytest
+ import psutil
+ 
++from pybedtools import filenames
+ 
+ testdir = os.path.dirname(__file__)
+-tempdir = os.path.join(os.path.abspath(testdir), "tmp")
+ unwriteable = "unwriteable"
+ 
+ 
+-def setup_module():
+-    if not os.path.exists(tempdir):
+-        os.system("mkdir -p %s" % tempdir)
+-    pybedtools.set_tempdir(tempdir)
+-
+-
+ def teardown_module():
+-    if os.path.exists(tempdir):
+-        os.system("rm -r %s" % tempdir)
+     pybedtools.cleanup()
+ 
+ 
+@@ -415,17 +408,19 @@
+     assert str(y) == expected
+ 
+ 
+-def test_issue_168():
++def test_issue_168(tmp_path: Path) -> None:
+     # Regression test:
+     # this would previously segfault in at least pysam 0.8.4
+     #
+-    x = pybedtools.example_bedtool("1000genomes-example.vcf")
++    shutil.copy(os.path.join(filenames.data_dir(), "1000genomes-example.vcf"), tmp_path)
++    x = pybedtools.BedTool(tmp_path / "1000genomes-example.vcf")
+     fn = x.bgzip(is_sorted=True, force=True)
+     y = pybedtools.BedTool(fn)
+ 
+ 
+-def test_issue_169():
+-    x = pybedtools.example_bedtool("1000genomes-example.vcf")
++def test_issue_169(tmp_path: Path) -> None:
++    shutil.copy(os.path.join(filenames.data_dir(), "1000genomes-example.vcf"), tmp_path)
++    x = pybedtools.BedTool(tmp_path / "1000genomes-example.vcf")
+     fn = x.bgzip(is_sorted=False, force=True)
+     line = gzip.open(fn, "rt").readline()
+     assert str(line).startswith("#"), line
+@@ -486,14 +481,16 @@
+         pass
+ 
+ 
+-def test_issue_180():
+-    a = pybedtools.example_bedtool("a.bed")
++def test_issue_180(tmp_path: Path) -> None:
++    shutil.copy(os.path.join(filenames.data_dir(), "a.bed"), tmp_path)
++    a = pybedtools.BedTool(tmp_path / "a.bed")
+     a = a.tabix(force=True)
+     assert a.tabix_contigs() == ["chr1"]
+ 
+ 
+-def test_issue_181():
+-    a = pybedtools.example_bedtool("a.bed")
++def test_issue_181(tmp_path: Path) -> None:
++    shutil.copy(os.path.join(filenames.data_dir(), "a.bed"), tmp_path)
++    a = pybedtools.BedTool(tmp_path / "a.bed")
+     a = a.tabix(force=True)
+     a.tabix_intervals("none:1-5")
+     with pytest.raises(ValueError):
+@@ -812,10 +809,10 @@
+     assert a == b == c == d == e
+ 
+ 
+-def test_issue_319():
++def test_issue_319(tmp_path: Path) -> None:
+     vrn_file = os.path.join(testdir, "data", "issue319.vcf.gz")
+     spliceslop = os.path.join(testdir, "data", "issue319.bed")
+-    output_bed = os.path.join(testdir, "data", "issue319.out.bed")
++    output_bed = tmp_path / "issue319.out.bed"
+     bt = pybedtools.BedTool(vrn_file).intersect(spliceslop, wa=True, header=True, v=True).saveas(output_bed)
+ 
+ 
+--- python-pybedtools.orig/pybedtools/test/test_iter.py
++++ python-pybedtools/pybedtools/test/test_iter.py
+@@ -5,17 +5,8 @@
+ import os
+ import gzip
+ import pybedtools
+-from .tfuncs import test_tempdir
+-
+-def setup_module():
+-    if not os.path.exists(test_tempdir):
+-        os.system("mkdir -p %s" % test_tempdir)
+-    pybedtools.set_tempdir(test_tempdir)
+-
+ 
+ def teardown_module():
+-    if os.path.exists(test_tempdir):
+-        os.system("rm -r %s" % test_tempdir)
+     pybedtools.cleanup()
+ 
+ yamltestdesc = ["test_cases.yaml"]
+--- python-pybedtools.orig/pybedtools/test/tfuncs.py
++++ python-pybedtools/pybedtools/test/tfuncs.py
+@@ -1,19 +1,9 @@
+-import pytest
+ import pybedtools
+ import os
+ 
+ testdir = os.path.dirname(__file__)
+-test_tempdir = os.path.join(os.path.abspath(testdir), "tmp")
+ unwriteable = os.path.join(os.path.abspath(testdir), "unwriteable")
+ 
+ 
+-def setup_module():
+-    if not os.path.exists(test_tempdir):
+-        os.system("mkdir -p %s" % test_tempdir)
+-    pybedtools.set_tempdir(test_tempdir)
+-
+-
+ def teardown_module():
+-    if os.path.exists(test_tempdir):
+-        os.system("rm -r %s" % test_tempdir)
+     pybedtools.cleanup()


=====================================
debian/rules
=====================================
@@ -9,34 +9,22 @@ export MATPLOTLIBRC=$(CURDIR)/debian/
 export PYBUILD_BEFORE_TEST=
 
 ifneq ($(PYBUILD_AUTOPKGTEST), 1)
-PYBUILD_BEFORE_TEST= cp {dir}/debian/mpl-expected.png {build_dir}/pybedtools/test/ ;
+export PYBUILD_BEFORE_TEST+= cp {dir}/debian/mpl-expected.png {build_dir}/pybedtools/test/ ;
 endif
 
-PYBUILD_BEFORE_TEST+= \
-	python3 {dir}/setup.py install --user ; \
-	export HOME=$(CURDIR)/fakehome
+export PYBUILD_TEST_ARGS=-k "not test_chromsizes" --pyargs pybedtools
 
-export PYBUILD_TEST_ARGS=-k "not test_chromsizes"
-ifeq ($(PYBUILD_AUTOPKGTEST), 1)
-PYBUILD_TEST_ARGS+={dir}/pybedtools/test/
-endif
-
-export PYBUILD_AFTER_TEST=cd {dir}/docs ; make clean doctest
+export PYBUILD_AFTER_TEST=cd {dir}/docs ; PYTHONPATH={build_dir} {interpreter} -m sphinx -b doctest -d build/doctrees   source build/doctest
 
-export HOME=$(CURDIR)/fakehome
-export PATH:=$(PATH):$(HOME)/.local/bin
+defaultpython=$(shell py3versions -dv)
 
 %:
 	dh $@ --with python3,sphinxdoc --buildsystem=pybuild
 
-override_dh_auto_build:
-	python3 setup.py cythonize
-	dh_auto_build
-	python3 setup.py develop --user
-	sphinx-build -N -b html docs/source docs/html
+execute_after_dh_auto_build:
+	cd docs ; PYTHONPATH=$(shell pybuild --pyver ${defaultpython} --print build_dir | awk '-F: ' '{print $$2}') python${defaultpython} -m sphinx -N -b html source html
 
-override_dh_install:
-	dh_install
+execute_after_dh_install:
 	rm -f debian/python3-pybedtools/usr/lib/python3*/dist-packages/pybedtools/test/prevent_open_file_regression \
 	      debian/python3-pybedtools/usr/lib/python3*/dist-packages/foo.bed \
 	      debian/python3-pybedtools/usr/lib/python3*/dist-packages/genome.txt



View it on GitLab: https://salsa.debian.org/med-team/python-pybedtools/-/compare/12be1cca9a242dd97e15deed361a67d06788e92c...60ba2acd976da0a9a68422f5fbafeb3515f8a2a4

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-pybedtools/-/compare/12be1cca9a242dd97e15deed361a67d06788e92c...60ba2acd976da0a9a68422f5fbafeb3515f8a2a4
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20241227/89fa78f6/attachment-0001.htm>


More information about the debian-med-commit mailing list