Skip to content

Commit

Permalink
Correctly handle conda_extras for mkrecipe
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Apr 1, 2021
1 parent 26b7716 commit e275cee
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 19 deletions.
12 changes: 8 additions & 4 deletions repo_helper/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@ def load_config(self) -> Dict[str, Any]:
config["description"] = config["short_desc"]
config["authors"] = [{"name": config["author"]}]
config["maintainers"] = []
config["extras"] = config["conda_extras"]
config["conda-channels"] = config["conda_channels"]
config["optional-dependencies"] = config["extras_require"]
config["dependencies"] = sorted(read_requirements(self.project_dir / "requirements.txt")[0])

config["requires"] = ["setuptools", "wheel"]

if config["conda_extras"] in (["none"], ["all"]):
config["extras"] = config["conda_extras"][0]
else:
config["extras"] = config["conda_extras"]

if config["use_experimental_backend"]:
config["requires"].append("repo-helper")
elif config["use_whey"]:
Expand Down Expand Up @@ -136,8 +139,9 @@ def make_conda_description(summary: str, conda_channels: Iterable[str] = ()) ->
def get_conda_requirements(repo_dir: PathPlus, config: Dict[str, Any]) -> List[str]:
extras = []

for extra in config["conda_extras"]:
extras.extend(config["extras_require"].get(extra, ()))
if config["conda_extras"] != ["none"]:
for extra in config["conda_extras"]:
extras.extend(config["extras_require"].get(extra, ()))

all_requirements = validate_requirements(
compile_requirements(repo_dir, extras),
Expand Down
6 changes: 5 additions & 1 deletion repo_helper/files/packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,13 @@ def make_pyproject(repo_path: pathlib.Path, templates: jinja2.Environment) -> Li
data.set_default("tool", {})

data["tool"].setdefault("mkrecipe", {})
data["tool"]["mkrecipe"]["extras"] = templates.globals["conda_extras"]
data["tool"]["mkrecipe"]["conda-channels"] = templates.globals["conda_channels"]

if templates.globals["conda_extras"] in (["none"], ["all"]):
data["tool"]["mkrecipe"]["extras"] = templates.globals["conda_extras"][0]
else:
data["tool"]["mkrecipe"]["extras"] = templates.globals["conda_extras"]

if templates.globals["use_whey"]:
data["tool"].setdefault("whey", {})

Expand Down
2 changes: 0 additions & 2 deletions tests/test_cli/test_conda_recipe_/test_conda_recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ requirements:
- email-validator==1.1.1
- isort>=5.0.0
- jinja2>=2.11.2
- lxml
- packaging>=20.4
- pre-commit>=2.7.1
- ruamel.yaml>=0.16.12
Expand All @@ -43,7 +42,6 @@ requirements:
- email-validator==1.1.1
- isort>=5.0.0
- jinja2>=2.11.2
- lxml
- packaging>=20.4
- pre-commit>=2.7.1
- ruamel.yaml>=0.16.12
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@ requirements:
- python
- apeye>=0.3.0
- attrs>=20.2.0
- lxml
- setuptools
- wheel
run:
- python
- apeye>=0.3.0
- attrs>=20.2.0
- lxml

test:
imports:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_files/test_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_make_pyproject(
demo_environment.globals["enable_tests"] = enable_tests
demo_environment.globals["entry_points"] = {}
demo_environment.globals["extras_require"] = {}
demo_environment.globals["conda_extras"] = "none"
demo_environment.globals["conda_extras"] = ["none"]
demo_environment.globals["conda_channels"] = []
demo_environment.globals["tox_build_requirements"] = []

Expand Down Expand Up @@ -177,7 +177,7 @@ def test_make_pyproject_whey_extras(
demo_environment.globals["use_experimental_backend"] = False
demo_environment.globals["enable_docs"] = True
demo_environment.globals["enable_tests"] = enable_tests
demo_environment.globals["conda_extras"] = "none"
demo_environment.globals["conda_extras"] = ["none"]
demo_environment.globals["conda_channels"] = ["domdfcoding", "conda-forge", "bioconda"]
demo_environment.globals["extras_require"] = {
"foo": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Homepage = "https://github.com/octocat/hello-world"
Documentation = "https://hello-world.readthedocs.io/en/latest"

[tool.mkrecipe]
extras = "none"
conda-channels = []
extras = "none"
license-key = "MIT"
package = "hello_world"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Homepage = "https://github.com/octocat/hello-world"
Documentation = "https://hello-world.readthedocs.io/en/latest"

[tool.mkrecipe]
extras = "none"
conda-channels = []
extras = "none"
license-key = "MIT"
package = "hello_world"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Homepage = "https://github.com/octocat/hello-world"
Documentation = "https://hello-world.readthedocs.io/en/latest"

[tool.mkrecipe]
extras = "none"
conda-channels = []
extras = "none"

[tool.whey]
base-classifiers = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Homepage = "https://github.com/octocat/hello-world"
Documentation = "https://hello-world.readthedocs.io/en/latest"

[tool.mkrecipe]
extras = "none"
conda-channels = []
extras = "none"
license-key = "MIT"
package = "hello_world"
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Homepage = "https://github.com/octocat/hello-world"
Documentation = "https://hello-world.readthedocs.io/en/latest"

[tool.mkrecipe]
extras = "none"
conda-channels = []
extras = "none"
license-key = "MIT"
package = "hello_world"
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Homepage = "https://github.com/octocat/hello-world"
Documentation = "https://hello-world.readthedocs.io/en/latest"

[tool.mkrecipe]
extras = "none"
conda-channels = []
extras = "none"

[tool.whey]
base-classifiers = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Documentation = "https://hello-world.readthedocs.io/en/latest"
foo = [ "apeye>=0.4.0", "attrs>=20.2.0", "click==7.1.2", "configconfig>=0.5.0", "consolekit>=1.0.0",]

[tool.mkrecipe]
extras = "none"
conda-channels = [ "domdfcoding", "conda-forge", "bioconda",]
extras = "none"

[tool.whey]
base-classifiers = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ Documentation = "https://hello-world.readthedocs.io/en/latest"
foo = [ "apeye>=0.4.0", "attrs>=20.2.0", "click==7.1.2", "configconfig>=0.5.0", "consolekit>=1.0.0",]

[tool.mkrecipe]
extras = "none"
conda-channels = [ "domdfcoding", "conda-forge", "bioconda",]
extras = "none"

[tool.whey]
base-classifiers = []
Expand Down

0 comments on commit e275cee

Please sign in to comment.