Skip to content

Commit

Permalink
Merge pull request #416 from sunbeam-labs/415-update-sunbeamlib-setup
Browse files Browse the repository at this point in the history
Replace setup.py with pyproject.toml
  • Loading branch information
Ulthran authored Oct 11, 2023
2 parents 02c21f6 + 85d29c7 commit f7b888d
Show file tree
Hide file tree
Showing 44 changed files with 572 additions and 329 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version: 2
jobs:
build:
docker:
- image: cimg/python:3.10
- image: continuumio/miniconda3

steps:
- checkout
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/check_conda_envs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check Conda Envs

on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
inputs:
envs:
description: 'Regex for envs'
required: false
default: './,workflow/envs/'

jobs:
check_conda_envs:
name: Check Conda Envs
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Check Conda Envs
uses: Ulthran/conda_env_check@v0
with:
envs: "./,workflow/envs/"
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include sunbeamlib/data/*.yml
include sunbeamlib/data/*.yaml
include src/sunbeamlib/*.yml
include src/sunbeamlib/*.yaml
6 changes: 5 additions & 1 deletion Readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

# Sunbeam: a robust, extensible metagenomic sequencing pipeline

[![CircleCI](https://circleci.com/gh/sunbeam-labs/sunbeam/tree/main.svg?style=shield)](https://circleci.com/gh/sunbeam-labs/sunbeam/tree/main) [![Super-Linter](https://github.com/sunbeam-labs/sunbeam/actions/workflows/linter.yml/badge.svg)](https://github.com/sunbeam-labs/sunbeam/actions/workflows/linter.yml) [![Documentation Status](https://readthedocs.org/projects/sunbeam/badge/?version=stable)](https://sunbeam.readthedocs.io/en/stable/?badge=stable) [![DOI:10.1186/s40168-019-0658-x](https://img.shields.io/badge/Published%20in-Microbiome-1abc9c.svg)](https://doi.org/10.1186/s40168-019-0658-x)
[![CircleCI](https://circleci.com/gh/sunbeam-labs/sunbeam/tree/main.svg?style=shield)](https://circleci.com/gh/sunbeam-labs/sunbeam/tree/main)
[![Super-Linter](https://github.com/sunbeam-labs/sunbeam/actions/workflows/linter.yml/badge.svg)](https://github.com/sunbeam-labs/sunbeam/actions/workflows/linter.yml)
[![Conda Envs Status](https://byob.yarr.is/sunbeam-labs/sunbeam/env_check)](https://github.com/sunbeam-labs/sunbeam/actions/workflows/check_conda_envs.yml)
[![Documentation Status](https://readthedocs.org/projects/sunbeam/badge/?version=stable)](https://sunbeam.readthedocs.io/en/stable/?badge=stable)
[![DOI:10.1186/s40168-019-0658-x](https://img.shields.io/badge/Published%20in-Microbiome-1abc9c.svg)](https://doi.org/10.1186/s40168-019-0658-x)

Sunbeam is a pipeline written in [snakemake](http://snakemake.readthedocs.io)
that simplifies and automates many of the steps in metagenomic sequencing
Expand Down
2 changes: 1 addition & 1 deletion dev_scripts/reformat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ cd $SUNBEAM_DIR
snakefmt workflow/rules/
snakefmt workflow/Snakefile

black workflow/scripts/ sunbeamlib/ tests/
black workflow/scripts/ src/sunbeamlib/ tests/e2e/*.py tests/unit/rules/*.py tests/unit/sunbeamlib/*.py tests/*.py
8 changes: 0 additions & 8 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ code under the 'sunbeamlib/' directory. If you have major or incompatible
changes to make to the environment you should consider creating a new one under a
different name so that you always have a working version installed.

-m/--no_mamba
++++++++++++++++

Don't use mamba in base environment as dependency solver. It is the default
option to use mamba because it is considerably faster than conda in solving new
environments. However it can also sometimes be a pain to install, especially
with crowded 'base' environments.

-v/--verbose
+++++++++++++++

Expand Down
2 changes: 0 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ channels:
- bioconda
dependencies:
- snakemake
- ruamel.yaml
- semantic_version
- git # Ensure sunbeam extend works even with tar installation of main pipeline
- python>=3.10
29 changes: 1 addition & 28 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ read -r -d '' __usage <<-'EOF'
-s --sunbeam_dir [arg] Location of Sunbeam source code. Default: this directory
-c --conda [arg] Location of Conda installation. Default: $CONDA_PREFIX
-u --update [arg] Update sunbeam [lib]rary, conda [env], or [all].
-m --no_mamba Don't use mamba in base environment as dependency solver.
-v --verbose Show subcommand output.
-d --debug Run in debug mode.
-h --help Display this message and exit.
Expand Down Expand Up @@ -67,18 +66,13 @@ __sunbeam_dir="${arg_s:-$(readlink -f ${__dir})}"
__sunbeam_env="${arg_e:-sunbeam${__version_tag}}"
__update_lib=false
__update_env=false
__install_mamba=true
if [[ "${arg_u}" = "all" || "${arg_u}" = "env" ]]; then
__update_lib=true
__update_env=true
elif [[ "${arg_u}" = "lib" ]]; then
__update_lib=true
fi

if [[ "${arg_m:?}" = "1" ]]; then
__install_mamba=false
fi

__old_path=$PATH
PATH=$PATH:${__conda_path}/bin

Expand All @@ -94,10 +88,6 @@ function __test_conda() {
command -v conda &> /dev/null && echo true || echo false
}

function __test_mamba() {
command -v mamba &> /dev/null && echo true || echo false
}

function __detect_conda_install() {
local discovered=$(__test_conda)
if [[ $discovered = true ]]; then
Expand Down Expand Up @@ -160,12 +150,7 @@ function install_conda () {
}

function install_environment () {
if [[ $(__test_mamba) = true ]]; then
cmd=mamba
else
cmd=conda
fi
debug_capture $cmd env create --name=$__sunbeam_env \
debug_capture conda env create --name=$__sunbeam_env \
--quiet --file environment.yml
if [[ $(__test_env) != true ]]; then
installation_error "Environment creation"
Expand Down Expand Up @@ -198,8 +183,6 @@ info " Sunbeam env: '${__sunbeam_env}'"
debug "Components detected:"
__conda_installed=$(__test_conda)
debug " Conda: ${__conda_installed}"
__mamba_installed=$(__test_mamba)
debug " Mamba: ${__mamba_installed}"
__env_exists=$(__test_env)
debug " Environment: ${__env_exists}"
__sunbeam_installed=$(__test_sunbeam)
Expand All @@ -221,16 +204,6 @@ else
__env_changed=true
fi

# Install mamba
if [[ $__mamba_installed = true ]]; then
info "Mamba already installed."
else
if [[ $__install_mamba = true ]]; then
info "Installing mamba..."
conda install --yes --quiet -n base -c conda-forge mamba || (info "Mamba failed to install, this is usually because you have too many packages already installed to your base environment. Install again without mamba (--no_mamba) or try to fix conflicts in base env." && exit 1)
fi
fi

conda config --set channel_priority strict # Set channel priority on new install

# Create Conda environment for Sunbeam
Expand Down
160 changes: 160 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
[project]
# This is the name of your project. The first time you publish this
# package, this name will be registered for you. It will determine how
# users can install this project, e.g.:
#
# $ pip install sampleproject
#
# And where it will live on PyPI: https://pypi.org/project/sampleproject/
#
# There are some restrictions on what makes a valid project name
# specification here:
# https://packaging.python.org/specifications/core-metadata/#name
name = "sunbeamlib" # Required

# Versions should comply with PEP 440:
# https://www.python.org/dev/peps/pep-0440/
#
# For a discussion on single-sourcing the version, see
# https://packaging.python.org/guides/single-sourcing-package-version/
#version = "0.0.0" # Required
dynamic = ["version"]

# This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field:
# https://packaging.python.org/specifications/core-metadata/#summary
description = "A helper package for running the sunbeam pipeline" # Optional

# This is an optional longer description of your project that represents
# the body of text which users will see when they visit PyPI.
#
# Often, this is the same as your README, so you can just read it in from
# that file directly (as we have already done above)
#
# This field corresponds to the "Description" metadata field:
# https://packaging.python.org/specifications/core-metadata/#description-optional
readme = "README.md" # Optional

# Specify which Python versions you support. In contrast to the
# 'Programming Language' classifiers above, 'pip install' will check this
# and refuse to install the project if the version does not match. See
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
requires-python = ">=3.7"

# This is either text indicating the license for the distribution, or a file
# that contains the license
# https://packaging.python.org/en/latest/specifications/core-metadata/#license
# license = {file = "LICENSE.txt"}

# This field adds keywords for your project which will appear on the
# project page. What does your project relate to?
#
# Note that this is a list of additional keywords, separated
# by commas, to be used to assist searching for the distribution in a
# larger catalog.
#keywords = ["bioinformatics", "metagenomics"] # Optional

# This should be your name or the name of the organization who originally
# authored the project, and a valid email address corresponding to the name
# listed.
# authors = [
# {name = "A. Random Developer", email = "[email protected]" } # Optional
# ]

# This should be your name or the names of the organization who currently
# maintains the project, and a valid email address corresponding to the name
# listed.
maintainers = [
{name = "Charlie Bushman", email = "[email protected]" } # Optional
]

# Classifiers help users find your project by categorizing it.
#
# For a list of valid classifiers, see https://pypi.org/classifiers/
classifiers = [ # Optional
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 5 - Production/Stable",

# Indicate who your project is intended for
# "Intended Audience :: Developers",
#"Topic :: Bioinformatics",

# Pick your license as you wish
"License :: OSI Approved :: MIT License",

# Specify the Python versions you support here. In particular, ensure
# that you indicate you support Python 3. These classifiers are *not*
# checked by "pip install". See instead "python_requires" below.
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
]

# This field lists other packages that your project depends on to run.
# Any package you put here will be installed by pip when your project is
# installed, so they must be valid existing projects.
#
# For an analysis of this field vs pip's requirements files see:
# https://packaging.python.org/discussions/install-requires-vs-requirements/
dependencies = [ # Optional
"more-itertools",
"pyyaml",
]

# List additional groups of dependencies here (e.g. development
# dependencies). Users will be able to install these using the "extras"
# syntax, for example:
#
# $ pip install sampleproject[dev]
#
# Similar to `dependencies` above, these must be valid existing
# projects.
[project.optional-dependencies] # Optional
dev = ["black"]
test = ["pytest"]

# List URLs that are relevant to your project
#
# This field corresponds to the "Project-URL" and "Home-Page" metadata fields:
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
# https://packaging.python.org/specifications/core-metadata/#home-page-optional
#
# Examples listed include a pattern for specifying where the package tracks
# issues, where the source is hosted, where to say thanks to the package
# maintainers, and where to support the project financially. The key is
# what's used to render the link text on PyPI.
[project.urls] # Optional
"Homepage" = "https://github.com/sunbeam-labs/sunbeam"
"Bug Reports" = "https://github.com/sunbeam-labs/sunbeam/issues"
"Docs" = "https://sunbeam.readthedocs.io/en/stable/"
# "Funding" = "https://donate.pypi.org"
# "Say Thanks!" = "http://saythanks.io/to/example"
"Source" = "https://github.com/sunbeam-labs/sunbeam"

# The following would provide a command line executable called `sample`
# which executes the function `main` from this package when invoked.
[project.scripts] # Optional
sunbeam = "sunbeamlib.script_sunbeam:main"

# This is configuration specific to the `setuptools` build backend.
# If you are using a different build backend, you will need to change this.
[tool.setuptools]
# If there are data files included in your packages that need to be
# installed, specify them here.
#package-data = {"sunbeamlib" = ["*.yml", "*.yaml"]}

[build-system]
# These are the assumed default build requirements from pip:
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[tool.setuptools.dynamic]
version = {attr = "sunbeamlib.__version__"}
16 changes: 0 additions & 16 deletions setup.py

This file was deleted.

Loading

0 comments on commit f7b888d

Please sign in to comment.