Modernize packaging, add test suite, remove shell-string system calls#42
Merged
Conversation
Step 1 - Dependencies & packaging: - Replace setup.py/setup.cfg with PEP 621 pyproject.toml (fixes distutils import removed in Python 3.12+, dedupes biopython, drops py2 universal wheel, requires-python >=3.9, pytest moved to a [test] extra) - Replace deprecated pkg_resources with importlib.metadata (bap_version helper) Step 2 - Testing: - Add pytest suite: unit tests (test_helpers.py), hermetic CLI smoke tests (test_cli_smoke.py), and auto-skipping end-to-end tests (test_integration.py) - Add GitHub Actions CI across Python 3.9-3.12 - Rewrite tests/README.md into a real testing guide Step 3 - Refactor (no shell-string system calls) in active CLIs: - Add run_cmd() subprocess wrapper; replace os.system()/os.popen()/cp with subprocess arg-lists, glob, and shutil; launch child scripts via sys.executable - Migrate ruamel.yaml dumping to the modern YAML() API - Fix latent bugs: Python-2 itertools.imap in string_hamming_distance, abs_file->abs_path, missing import subprocess, undefined macs2_genome_size/ bs_genome, and import-time PyYAML dependency Legacy v1 CLI (cli_old_dontEdit.py) and Snakefile shell pipelines are intentionally left unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors the codebase in three steps, as requested.
Step 1 — Dependencies & packaging
setup.py/setup.cfgwith a PEP 621pyproject.toml. Fixes thedistutilsimport (removed in Python 3.12+), de-duplicatesbiopython, drops the obsolete py2universalwheel, setsrequires-python >= 3.9, and movespytestto a[test]extra.pkg_resources.get_distributionwithimportlib.metadatavia a newbap_version()helper; make@click.version_option()explicit.Step 2 — Testing + documentation
test_helpers.py(pure functions +run_cmd),test_cli_smoke.py(hermeticCliRunnerchecks), andtest_integration.py(end-to-endbap2 bam, auto-skips when samtools/bedtools/R/snakemake are absent)..github/workflows/ci.yml).tests/README.mdinto a real testing guide; added a Testing section to the main README.Step 3 — Refactor (no shell-string system calls)
run_cmd()subprocess wrapper (no shell). Replaced everyos.system("..."),os.popen('ls ...'), andos.system("cp ...")in the active CLIs withrun_cmd([...]),glob.glob, andshutil.copyfile; child scripts launch viasys.executable.ruamel.yamlRoundTripDumperAPI to the modernYAML()API.itertools.imapinstring_hamming_distance,abs_file→abs_path, missingimport subprocess, undefinedmacs2_genome_size/bs_genome, and import-time PyYAML dependency.Out of scope (intentionally unchanged): the deprecated v1
bapcommand (cli_old_dontEdit.py) and the genuine shell pipelines inside the Snakemakerun:blocks.Verification
pip install -e .[test]succeeds on modern Python; all console scripts report their version.pytest→ 41 passed, 1 skipped (integration auto-skip).os.system/os.popenremain only in the legacy v1 CLI.🤖 Generated with Claude Code