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

build: Use importlib.metadata for versioning #195

Merged
merged 2 commits into from
Apr 5, 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
156 changes: 150 additions & 6 deletions bioframe/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,150 @@
from ._version import __version__
from .core import *
from .io import *
from .ops import *
from .extras import *
from .vis import *
try:
from importlib.metadata import PackageNotFoundError, version
except ImportError:
from importlib_metadata import PackageNotFoundError, version

try:
__version__ = version("bioframe")
except PackageNotFoundError:
__version__ = "unknown"

__all__ = [
"arrops",
"from_any",
"from_dict",
"from_list",
"from_series",
"is_bedframe",
"is_cataloged",
"is_chrom_dtype",
"is_complete_ucsc_string",
"is_contained",
"is_covering",
"is_overlapping",
"is_sorted",
"is_tiling",
"is_viewframe",
"make_viewframe",
"parse_region",
"parse_region_string",
"sanitize_bedframe",
"to_ucsc_string",
"update_default_colnames",
"binnify",
"digest",
"frac_gc",
"frac_gene_coverage",
"frac_mapped",
"make_chromarms",
"pair_by_distance",
"seq_gc",
"SCHEMAS",
"UCSCClient",
"assemblies_available",
"assembly_info",
"fetch_centromeres",
"fetch_chromsizes",
"load_fasta",
"read_bam",
"read_bigbed",
"read_bigwig",
"read_chromsizes",
"read_pairix",
"read_tabix",
"read_table",
"to_bigbed",
"to_bigwig",
"assign_view",
"closest",
"cluster",
"complement",
"count_overlaps",
"coverage",
"expand",
"merge",
"overlap",
"select",
"select_indices",
"select_labels",
"select_mask",
"setdiff",
"sort_bedframe",
"subtract",
"trim",
"plot_intervals",
"to_ucsc_colorstring",
]

from .core import (
arrops,
from_any,
from_dict,
from_list,
from_series,
is_bedframe,
is_cataloged,
is_chrom_dtype,
is_complete_ucsc_string,
is_contained,
is_covering,
is_overlapping,
is_sorted,
is_tiling,
is_viewframe,
make_viewframe,
parse_region,
parse_region_string,
sanitize_bedframe,
to_ucsc_string,
update_default_colnames,
)
from .extras import (
binnify,
digest,
frac_gc,
frac_gene_coverage,
frac_mapped,
make_chromarms,
pair_by_distance,
seq_gc,
)
from .io import (
SCHEMAS,
UCSCClient,
assemblies_available,
assembly_info,
fetch_centromeres,
fetch_chromsizes,
load_fasta,
read_bam,
read_bigbed,
read_bigwig,
read_chromsizes,
read_pairix,
read_tabix,
read_table,
to_bigbed,
to_bigwig,
)
from .ops import (
assign_view,
closest,
cluster,
complement,
count_overlaps,
coverage,
expand,
merge,
overlap,
select,
select_indices,
select_labels,
select_mask,
setdiff,
sort_bedframe,
subtract,
trim,
)
from .vis import plot_intervals, to_ucsc_colorstring

del version, PackageNotFoundError
1 change: 0 additions & 1 deletion bioframe/_version.py

This file was deleted.

61 changes: 45 additions & 16 deletions bioframe/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
from . import arrops

from . import specs
from .specs import *

from . import stringops
from .stringops import *

from . import checks
from .checks import *

from . import construction
from .construction import *
from .checks import (
is_bedframe,
is_cataloged,
is_contained,
is_covering,
is_overlapping,
is_sorted,
is_tiling,
is_viewframe,
)
from .construction import (
from_any,
from_dict,
from_list,
from_series,
make_viewframe,
sanitize_bedframe,
)
from .specs import is_chrom_dtype, update_default_colnames
from .stringops import (
is_complete_ucsc_string,
parse_region,
parse_region_string,
to_ucsc_string,
)

__all__ = [
"arrops",
*specs.__all__,
*stringops.__all__,
*checks.__all__,
*construction.__all__,
"is_bedframe",
"is_cataloged",
"is_contained",
"is_covering",
"is_overlapping",
"is_sorted",
"is_tiling",
"is_viewframe",
"from_any",
"from_dict",
"from_list",
"from_series",
"make_viewframe",
"sanitize_bedframe",
"is_chrom_dtype",
"update_default_colnames",
"is_complete_ucsc_string",
"parse_region",
"parse_region_string",
"to_ucsc_string",
]
41 changes: 29 additions & 12 deletions bioframe/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
from .assembly import assemblies_available, assembly_info
from .fileops import (
load_fasta,
read_bam,
read_bigbed,
read_bigwig,
read_chromsizes,
read_pairix,
read_tabix,
read_table,
to_bigbed,
to_bigwig,
)
from .resources import UCSCClient, fetch_centromeres, fetch_chromsizes
from .schemas import SCHEMAS

from . import fileops
from .fileops import *

from . import resources
from .resources import *

from . import assembly
from .assembly import *

__all__ = [
"assemblies_available",
"assembly_info",
"read_table",
"read_chromsizes",
"read_tabix",
"read_pairix",
"read_bam",
"load_fasta",
"read_bigwig",
"to_bigwig",
"read_bigbed",
"to_bigbed",
"UCSCClient",
"fetch_centromeres",
"fetch_chromsizes",
"SCHEMAS",
*fileops.__all__,
*resources.__all__,
*assembly.__all__,
]
50 changes: 12 additions & 38 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,25 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# 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.
#
import os
import sys

sys.path.insert(0, os.path.abspath("../"))

# import sys
from datetime import datetime
from importlib.metadata import metadata
from pathlib import Path
# autodoc_mock_imports = ["numpy", "pandas", "matplotlib", "requests"]


# -- Project information -----------------------------------------------------

project = "bioframe"
copyright = "2020, Open2C"
# NOTE: If you installed your project in editable mode, this might be stale.
# If this is the case, reinstall it to refresh the metadata
info = metadata("bioframe")
project_name = info["Name"]
author = "Open2C"

copyright = f"{datetime.now():%Y}, {author}."
version = info["Version"]
urls = dict(pu.split(", ") for pu in info.get_all("Project-URL"))

# The full version, including alpha/beta/rc tags
def _read(*parts, **kwargs):
import os

filepath = os.path.join(os.path.dirname(__file__), *parts)
encoding = kwargs.pop("encoding", "utf-8")
with open(filepath, encoding=encoding) as fh:
text = fh.read()
return text


def get_version():
import re

version = re.search(
r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]',
_read("..", "bioframe", "_version.py"),
re.MULTILINE,
).group(1)
return version


version = get_version()
# The full version, including alpha/beta/rc tags.
release = version
release = info["Version"]

# -- General configuration ---------------------------------------------------

Expand Down
Loading
Loading