Skip to content

Commit

Permalink
Add proper python packaging and command line entrypoint
Browse files Browse the repository at this point in the history
* Move code into `mcquant/` subdirectory to define the package name.
* Refactor CommandSingleCellExtraction.py into cli.py.
* Add pyproject.toml to define build tooling, dependencies, metadata, etc.
* Define command-line entrypoint `mcquant`.
* Use setuptools_scm to extract our version number directly from git tags.
* Add --version argument to cli. Fixes #45.
* Edit Dockerfile to build and install our package as a wheel rather than
  explicitly specifying all dependencies directly.
  • Loading branch information
jmuhlich committed May 31, 2024
1 parent bef2ea4 commit 45d06fd
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mcquant/_version.py
.DS_Store

# Byte-compiled / optimized / DLL files
Expand Down
11 changes: 0 additions & 11 deletions CommandSingleCellExtraction.py

This file was deleted.

7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM python:3.11

RUN pip install --no-cache-dir h5py pandas numpy pathlib 'scikit-image>=0.23.2' imagecodecs
COPY . src

COPY . /app/
RUN pip install --no-cache-dir build \
&& python -m build -w src \
&& pip install --no-cache-dir src/dist/mcquant*.whl \
&& rm -r src
2 changes: 2 additions & 0 deletions ParseInput.py → mcquant/ParseInput.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Functions for parsing command line arguments for ome ilastik prep
import argparse
from . import __version__


def ParseInputDataExtract():
Expand Down Expand Up @@ -34,6 +35,7 @@ def ParseInputDataExtract():
"""
)
#parser.add_argument('--suffix')
parser.add_argument('--version', action='version', version=f'mcquant {__version__}')
args = parser.parse_args()
#Create a dictionary object to pass to the next function
dict = {'masks': args.masks, 'image': args.image,\
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions mcquant/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
try:
from ._version import version as __version__
except ImportError:
__version__ = "unknown"
14 changes: 14 additions & 0 deletions mcquant/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#Script for parsing command line arguments and running single-cell
#data extraction functions
#Joshua Hess
from . import ParseInput
from . import SingleCellDataExtraction

def main():
#Parse the command line arguments
args = ParseInput.ParseInputDataExtract()
#Run the MultiExtractSingleCells function
SingleCellDataExtraction.MultiExtractSingleCells(**args)

if __name__ == '__main__':
main()
24 changes: 24 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm[toml]>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "mcquant"
dynamic = ["version"]
requires-python = ">=3.9"
dependencies = [
"h5py",
"pandas",
"numpy",
"scikit-image>=0.23.2",
"imagecodecs",
]

[project.scripts]
mcquant = "mcquant.cli:main"

[tool.setuptools]
packages = ["mcquant"]

[tool.setuptools_scm]
version_file = "mcquant/_version.py"

0 comments on commit 45d06fd

Please sign in to comment.