From 4ad848c9e655611d3caf7ce78dddda0428bafb28 Mon Sep 17 00:00:00 2001 From: Stephen Fleming Date: Thu, 10 Aug 2023 00:51:21 -0400 Subject: [PATCH 1/2] Move from setup.py to pyproject.toml Single source version in cellbender/VERSION.txt --- MANIFEST.in | 5 ++- cellbender/VERSION.txt | 1 + cellbender/__init__.py | 4 ++- cellbender/base_cli.py | 7 +--- pyproject.toml | 45 ++++++++++++++++++++++++ requirements-dev.txt | 2 ++ setup.py | 77 ------------------------------------------ 7 files changed, 56 insertions(+), 85 deletions(-) create mode 100644 cellbender/VERSION.txt create mode 100644 pyproject.toml create mode 100644 requirements-dev.txt delete mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in index 66e89a1..679690c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,7 @@ include README.rst include LICENSE include requirements.txt -include requirements-rtd.txt \ No newline at end of file +include requirements-rtd.txt +include requirements-dev.txt +include cellbender/VERSION.txt +include cellbender/remove_background/report.ipynb \ No newline at end of file diff --git a/cellbender/VERSION.txt b/cellbender/VERSION.txt new file mode 100644 index 0000000..9325c3c --- /dev/null +++ b/cellbender/VERSION.txt @@ -0,0 +1 @@ +0.3.0 \ No newline at end of file diff --git a/cellbender/__init__.py b/cellbender/__init__.py index 0404d81..9fdd33d 100644 --- a/cellbender/__init__.py +++ b/cellbender/__init__.py @@ -1 +1,3 @@ -__version__ = '0.3.0' +from .base_cli import get_version + +__version__ = get_version() diff --git a/cellbender/base_cli.py b/cellbender/base_cli.py index bf5a71b..fca8eb7 100644 --- a/cellbender/base_cli.py +++ b/cellbender/base_cli.py @@ -23,12 +23,7 @@ def read(rel_path): def get_version() -> str: - for line in read('__init__.py').splitlines(): - if line.startswith('__version__'): - delim = '"' if '"' in line else "'" - return line.split(delim)[1] - else: - raise RuntimeError("Unable to find version string.") + return read('VERSION.txt').splitlines()[0] class AbstractCLI(ABC): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6a0d36d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,45 @@ +[build-system] +requires = ["setuptools>=61.2"] +build-backend = "setuptools.build_meta" + +[project] +name = "cellbender" +authors = [{name = "Stephen Fleming"}, {name = "Mehrtash Babadi"}] +license = {text = "BSD (3-Clause)"} +description = "A software package for eliminating technical artifacts from high-throughput single-cell RNA sequencing (scRNA-seq) data" +keywords = ["scRNA-seq", "bioinformatics"] +classifiers = [ + "Development Status :: 4 - Beta", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3.7", + "Topic :: Scientific/Engineering :: Bio-Informatics", +] +dynamic = ["version", "dependencies", "optional-dependencies"] + +[project.readme] +file = "README.rst" +content-type = "text/x-rst" + +[project.urls] +Homepage = "http://github.com/broadinstitute/CellBender" +Documentation = "http://cellbender.readthedocs.io" + +[project.scripts] +cellbender = "cellbender.base_cli:main" + +[tool.setuptools] +zip-safe = false +include-package-data = true + +[tool.setuptools.packages] +find = {namespaces = false} + +[tool.setuptools.dynamic] +version = {attr = "cellbender.__version__"} +dependencies = {file = ["requirements.txt"]} +optional-dependencies.dev = {file = ["requirements-dev.txt"]} +optional-dependencies.docs = {file = ["requirements-rtd.txt"]} + +[tool.setuptools.package-data] +"*" = ["cellbender.remove_background.report.ipynb", "cellbender.VERSION.txt"] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..3257b82 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +pytest +scikit-learn diff --git a/setup.py b/setup.py deleted file mode 100644 index 106fa57..0000000 --- a/setup.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python - -import os -import setuptools -import codecs -from typing import List - - -def read(rel_path): - here = os.path.abspath(os.path.dirname(__file__)) - with codecs.open(os.path.join(here, rel_path), 'r') as fp: - return fp.read() - - -def get_version() -> str: - for line in read('cellbender/__init__.py').splitlines(): - if line.startswith('__version__'): - delim = '"' if '"' in line else "'" - return line.split(delim)[1] - else: - raise RuntimeError("Unable to find version string.") - - -def readme() -> str: - with open('README.rst') as f: - return f.read() - - -def _readlines(filename, filebase=''): - with open(os.path.join(filebase, filename)) as f: - lines = f.readlines() - return lines - - -def get_requirements() -> List[str]: - requirements = _readlines('requirements.txt') - if 'READTHEDOCS' in os.environ: - requirements.extend(get_rtd_requirements()) - return requirements - - -def get_rtd_requirements() -> List[str]: - requirements = _readlines('requirements-rtd.txt') - return requirements - - -setuptools.setup( - name='cellbender', - version=get_version(), - description='A software package for eliminating technical artifacts from ' - 'high-throughput single-cell RNA sequencing (scRNA-seq) data', - long_description=readme(), - long_description_content_type='text/x-rst', - classifiers=[ - 'Development Status :: 4 - Beta', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Programming Language :: Python :: 3.7', - 'Topic :: Scientific/Engineering :: Bio-Informatics', - ], - keywords='scRNA-seq bioinformatics', - url='http://github.com/broadinstitute/CellBender', - author='Stephen Fleming, Mehrtash Babadi', - license='BSD (3-Clause)', - packages=setuptools.find_packages(), - install_requires=get_requirements(), - extras_require={ - "dev": ["pytest", "scikit-learn"], - "docs": get_rtd_requirements(), - }, - entry_points={ - 'console_scripts': ['cellbender=cellbender.base_cli:main'], - }, - include_package_data=True, - package_data={'': ['*.ipynb']}, # include the report template - zip_safe=False -) From 1c9bb4895081f6edafbffb1204e742b24a69ebcc Mon Sep 17 00:00:00 2001 From: Stephen Fleming Date: Thu, 10 Aug 2023 01:31:44 -0400 Subject: [PATCH 2/2] Docker build tag references the new single sourced version --- build_docker_release.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_docker_release.sh b/build_docker_release.sh index ff0511f..532bffe 100755 --- a/build_docker_release.sh +++ b/build_docker_release.sh @@ -1,6 +1,6 @@ #!/bin/bash -tag=$(cat cellbender/__init__.py | sed -e 's?__version__ = ??' | sed "s/^'\(.*\)'$/\1/") +tag=$(cat cellbender/VERSION.txt) release=v${tag} docker build \