Skip to content

Commit df48bdf

Browse files
committed
Add support for conda channel being different from username.
1 parent afc3c25 commit df48bdf

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

repo_helper/blocks/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ class ShieldsBlock:
311311
:param platforms: List of supported platforms.
312312
:param pre_commit: Whether to show a shield for pre-commit
313313
:param on_pypi:
314+
:param primary_conda_channel: The Conda channel the package can be downloaded from.
314315
315316
.. versionadded:: 2020.12.11
316317
"""
@@ -363,6 +364,7 @@ def __init__(
363364
platforms: Optional[Iterable[str]] = None,
364365
pre_commit: bool = False,
365366
on_pypi: bool = True,
367+
primary_conda_channel: Optional[str] = None,
366368
):
367369

368370
if unique_name and not unique_name.startswith('_'):
@@ -382,6 +384,7 @@ def __init__(
382384
self.platforms: Iterable[str] = set(platforms or ())
383385
self.pre_commit: bool = pre_commit
384386
self.on_pypi: bool = on_pypi
387+
self.primary_conda_channel: str = primary_conda_channel or self.username
385388

386389
self.set_readme_mode()
387390

@@ -536,8 +539,10 @@ def make(self) -> str:
536539

537540
if self.conda:
538541
sections["Anaconda"] = ["conda-version", "conda-platform"]
539-
substitutions["conda-version"] = self.make_conda_version_shield(pypi_name, username)
540-
substitutions["conda-platform"] = self.make_conda_platform_shield(pypi_name, username)
542+
substitutions["conda-version"] = self.make_conda_version_shield(pypi_name, self.primary_conda_channel)
543+
substitutions["conda-platform"] = self.make_conda_platform_shield(
544+
pypi_name, self.primary_conda_channel
545+
)
541546

542547
if self.docker_shields:
543548
docker_name = self.docker_name

repo_helper/files/docs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,7 @@ def rewrite_docs_index(repo_path: pathlib.Path, templates: jinja2.Environment) -
699699
platforms=templates.globals["platforms"],
700700
pre_commit=templates.globals["enable_pre_commit"],
701701
on_pypi=templates.globals["on_pypi"],
702+
primary_conda_channel=templates.globals["primary_conda_channel"],
702703
)
703704
sb.set_docs_mode()
704705
shields_block = sb.make()

repo_helper/files/readme.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def rewrite_readme(repo_path: pathlib.Path, templates: jinja2.Environment) -> Li
7171
pre_commit=templates.globals["enable_pre_commit"],
7272
on_pypi=templates.globals["on_pypi"],
7373
docs_url=templates.globals["docs_url"],
74+
primary_conda_channel=templates.globals["primary_conda_channel"],
7475
).make()
7576

7677
if templates.globals["on_pypi"]:

0 commit comments

Comments
 (0)