Skip to content

Commit afc3c25

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

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

repo_helper/configuration/__init__.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@
5252
testing,
5353
travis
5454
)
55-
from repo_helper.configuration.conda_anaconda import conda_channels, conda_description, conda_extras, enable_conda
55+
from repo_helper.configuration.conda_anaconda import (
56+
conda_channels,
57+
conda_description,
58+
conda_extras,
59+
enable_conda,
60+
primary_conda_channel
61+
)
5662
from repo_helper.configuration.documentation import (
5763
docs_dir,
5864
docs_url,
@@ -154,6 +160,7 @@
154160
"author",
155161
"classifiers",
156162
"conda_channels",
163+
"primary_conda_channel",
157164
"conda_extras",
158165
"conda_description",
159166
"console_scripts",
@@ -346,6 +353,11 @@ def custom_parsing(
346353
url = f"https://{parsed_config_vars['repo_name'].lower()}.readthedocs.io/en/latest"
347354
parsed_config_vars["docs_url"] = url
348355

356+
parsed_config_vars["conda_channels"] = sorted({
357+
*parsed_config_vars["conda_channels"],
358+
parsed_config_vars["primary_conda_channel"],
359+
})
360+
349361
return parsed_config_vars
350362

351363

repo_helper/configuration/conda_anaconda.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
# this package
3333
from repo_helper.configuration import metadata
3434

35-
__all__ = ["enable_conda", "conda_channels", "conda_description", "conda_extras"]
35+
__all__ = ["enable_conda", "conda_channels", "conda_description", "conda_extras", "primary_conda_channel"]
3636

3737

3838
class enable_conda(ConfigVar): # noqa
@@ -127,3 +127,26 @@ class conda_description(ConfigVar): # noqa
127127
dtype = str
128128
default = metadata.short_desc
129129
category: str = "conda & anaconda"
130+
131+
132+
class primary_conda_channel(ConfigVar): # noqa
133+
"""
134+
The Conda channel the package can be downloaded from.
135+
136+
This is automatically added to :conf:`conda_channels`.
137+
138+
Defaults to :conf:`username` if unset.
139+
140+
Example:
141+
142+
.. code-block:: yaml
143+
144+
username: repo-helper
145+
primary_conda_channel: domdfcoding
146+
147+
.. versionadded:: 2020.12.17
148+
"""
149+
150+
dtype = str
151+
default = metadata.username
152+
category: str = "metadata"

repo_helper/repo_helper_schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@
263263
],
264264
"description": "Whether custom documentation theme styling in ``_static/style.css`` and ``_templates/layout.html`` should be preserved."
265265
},
266+
"primary_conda_channel": {
267+
"type": "string",
268+
"description": "The Conda channel the package can be downloaded from."
269+
},
266270
"pure_python": {
267271
"type": [
268272
"boolean",

tests/test_cli/test_conda_recipe_/test_conda_recipe.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ about:
5959
description: "Update multiple configuration files, build scripts etc. from a single location.
6060
6161
62-
Before installing please ensure you have added the following channels: domdfcoding, conda-forge
62+
Before installing please ensure you have added the following channels: conda-forge, domdfcoding
6363
"
6464
doc_url: https://repo_helper_demo.readthedocs.io
6565
dev_url: https://github.com/domdfcoding/repo_helper_demo

tests/test_cli/test_conda_recipe_/test_conda_recipe_specifiers.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ about:
3737
description: "Update multiple configuration files, build scripts etc. from a single location.
3838
3939
40-
Before installing please ensure you have added the following channels: domdfcoding, conda-forge
40+
Before installing please ensure you have added the following channels: conda-forge, domdfcoding
4141
"
4242
doc_url: https://repo_helper_demo.readthedocs.io
4343
dev_url: https://github.com/domdfcoding/repo_helper_demo

tests/test_configuration_/test_parse_yaml.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ classifiers:
1717
- 'Programming Language :: Python :: Implementation :: CPython'
1818
- 'Topic :: Utilities'
1919
conda_channels:
20-
- domdfcoding
2120
- conda-forge
21+
- domdfcoding
2222
conda_description: Update multiple configuration files, build scripts etc. from a
2323
single location.
2424
conda_extras:
@@ -80,6 +80,7 @@ platforms:
8080
- Linux
8181
pre_commit_exclude: ^$
8282
preserve_custom_theme: true
83+
primary_conda_channel: domdfcoding
8384
pure_python: true
8485
py_modules: []
8586
pypi_name: repo_helper_demo

0 commit comments

Comments
 (0)