diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e5d6f6b7..f920134f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ * Added `nf-core schema docs` command to output pipline parameter documentation in Markdown format for inclusion in GitHub and other documentation systems ([#741](https://github.com/nf-core/tools/issues/741)) * Allow conditional process execution from the configuration file ([#1393](https://github.com/nf-core/tools/pull/1393)) * Add linting for when condition([#1397](https://github.com/nf-core/tools/pull/1397)) +* Added `--conda-package-version` flag for specifying version of conda package in `nf-core modules create`. ([#1238](https://github.com/nf-core/tools/issues/1238)) ## [v2.2 - Lead Liger](https://github.com/nf-core/tools/releases/tag/2.2) - [2021-12-14] diff --git a/nf_core/__main__.py b/nf_core/__main__.py index a666748f4..7999cb368 100755 --- a/nf_core/__main__.py +++ b/nf_core/__main__.py @@ -520,8 +520,9 @@ def remove(ctx, dir, tool): @click.option("-n", "--no-meta", is_flag=True, default=False, help="Don't use meta map for sample information") @click.option("-f", "--force", is_flag=True, default=False, help="Overwrite any files if they already exist") @click.option("-c", "--conda-name", type=str, default=None, help="Name of the conda package to use") +@click.option("-p", "--conda-package-version", type=str, default=None, help="Version of conda package to use") @click.option("-r", "--repo-type", type=click.Choice(["pipeline", "modules"]), default=None, help="Type of repository") -def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_name, repo_type): +def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_name, conda_package_version, repo_type): """ Create a new DSL2 module from the nf-core template. @@ -542,7 +543,9 @@ def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_nam # Run function try: - module_create = nf_core.modules.ModuleCreate(dir, tool, author, label, has_meta, force, conda_name, repo_type) + module_create = nf_core.modules.ModuleCreate( + dir, tool, author, label, has_meta, force, conda_name, conda_package_version, repo_type + ) module_create.create() except UserWarning as e: log.critical(e) diff --git a/nf_core/modules/create.py b/nf_core/modules/create.py index c4371853e..b904d18d1 100644 --- a/nf_core/modules/create.py +++ b/nf_core/modules/create.py @@ -34,6 +34,7 @@ def __init__( has_meta=None, force=False, conda_name=None, + conda_version=None, repo_type=None, ): self.directory = directory @@ -44,6 +45,7 @@ def __init__( self.force_overwrite = force self.subtool = None self.tool_conda_name = conda_name + self.tool_conda_version = conda_version self.tool_licence = None self.repo_type = repo_type self.tool_licence = "" @@ -143,9 +145,14 @@ def create(self): anaconda_response = nf_core.utils.anaconda_package(self.tool_conda_name, ["bioconda"]) else: anaconda_response = nf_core.utils.anaconda_package(self.tool, ["bioconda"]) - version = anaconda_response.get("latest_version") - if not version: - version = str(max([parse_version(v) for v in anaconda_response["versions"]])) + + if not self.tool_conda_version: + version = anaconda_response.get("latest_version") + if not version: + version = str(max([parse_version(v) for v in anaconda_response["versions"]])) + else: + version = self.tool_conda_version + self.tool_licence = nf_core.utils.parse_anaconda_licence(anaconda_response, version) self.tool_description = anaconda_response.get("summary", "") self.tool_doc_url = anaconda_response.get("doc_url", "")