Skip to content

Commit

Permalink
cenv-settings for project are extracted now from "extra:cenv"-section.
Browse files Browse the repository at this point in the history
  • Loading branch information
skallfass committed Nov 24, 2019
1 parent 3554df4 commit 4846fc8
Show file tree
Hide file tree
Showing 12 changed files with 522 additions and 120 deletions.
15 changes: 8 additions & 7 deletions README.rst
Expand Up @@ -45,8 +45,8 @@ for the conda-environment during development and for production), ``cenv``
the only relevant file and to create and update conda-environment from the
definition inside this ``meta.yaml``.
The name of the conda-environment to create / update is defined in the section
``extra`` and the variable ``env_name`` inside the ``meta.yaml``.
The python version must be defined in ``extra`` inside the key ``python``.
``extra:cenv`` and the variable ``env_name`` inside the ``meta.yaml``.
The python version must be defined in ``extra:cenv`` inside the key ``python``.

The steps run by cenv:

Expand Down Expand Up @@ -160,7 +160,7 @@ The required information about the projects conda environment are extracted
from the meta.yaml.
This meta.yaml should be located inside the project folder at
``./conda-build/meta.yaml``.
The project-configuration is defined in the ``extra`` section of the
The project-configuration is defined in the ``extra:cenv`` section of the
``meta.yaml``.
There you can define the name of the projects conda-environment at
``env_name``.
Expand Down Expand Up @@ -208,10 +208,11 @@ A meta.yaml valid for cenv should look like the following:
- example_package
extra:
env_name: example
python: 3.6
dev_requirements:
- ipython >=7.2.0
cenv:
env_name: example
python: 3.6
dev_requirements:
- ipython >=7.2.0
**ATTENTION**\ :

Expand Down
2 changes: 1 addition & 1 deletion cenv_tool/project.py
Expand Up @@ -68,7 +68,7 @@ def __attrs_post_init__(self):
except FileNotFoundError:
message(text='project has no meta.yaml!', color='red')
exit(1)
settings = meta_yaml['extra']
settings = meta_yaml['extra']['cenv']
dependencies = extract_dependencies_from_meta_yaml(meta_yaml)

config = read_config()
Expand Down
19 changes: 11 additions & 8 deletions cenv_tool/schemata.py
Expand Up @@ -88,14 +88,7 @@ class SNTest(Schema):
)


class SNExtra(Schema):
"""Contain the ``extra``-section inside a ``meta.yaml``.
The ``extra``-section has to contains the information where to find the
conda-folder, the name of the conda environment to use for the current
project and the cenv-version used when the ``meta.yaml`` file was created.
"""

class SNCenv(Schema):
env_name = fields.String(
strict=True,
required=True,
Expand All @@ -119,6 +112,16 @@ class SNExtra(Schema):
)


class SNExtra(Schema):
"""Contain the ``extra``-section inside a ``meta.yaml``.
The ``extra``-section has to contains the information where to find the
conda-folder, the name of the conda environment to use for the current
project and the cenv-version used when the ``meta.yaml`` file was created.
"""
cenv = fields.Nested(SNCenv, strict=True, required=True)


class SMetaYaml(Schema):
"""Contain the representable of a complete ``meta.yaml`` file.
Expand Down
6 changes: 3 additions & 3 deletions cenv_tool/utils.py
Expand Up @@ -138,11 +138,11 @@ def extract_dependencies_from_meta_yaml(meta_yaml_content: dict) -> List[str]:
meta_yaml_content['requirements']['run_constrained']
)

if meta_yaml_content['extra'].get('dev_requirements'):
dependencies.extend(meta_yaml_content['extra']['dev_requirements'])
if meta_yaml_content['extra']['cenv'].get('dev_requirements'):
dependencies.extend(meta_yaml_content['extra']['cenv']['dev_requirements'])

# append the python version to use in the conda environment
dependencies.append(f'python {meta_yaml_content["extra"]["python"]}')
dependencies.append(f'python {meta_yaml_content["extra"]["cenv"]["python"]}')
return dependencies


Expand Down
4 changes: 2 additions & 2 deletions docs/_static/coverage.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/index.rst
Expand Up @@ -25,9 +25,9 @@ for the conda-environment during development and for production), ``cenv``
the only relevant file and to create and update conda-environment from the
definition inside this ``meta.yaml``.
The name of the conda-environment to create / update is defined in the section
``extra`` and the variable ``env_name`` inside the ``meta.yaml`` (at
``extra:cenv`` and the variable ``env_name`` inside the ``meta.yaml`` (at
``conda-build/meta.yaml``).
The python version must be defined in ``extra`` inside the key ``python``.
The python version must be defined in ``extra:cenv`` inside the key ``python``.

The steps run by cenv:

Expand Down
17 changes: 9 additions & 8 deletions docs/usage.rst
Expand Up @@ -48,12 +48,12 @@ This meta.yaml should be located inside the project folder at
The project-configuration is defined in the ``extra`` section of the
``meta.yaml``.
There you can define the name of the projects conda-environment at
``extra:env_name``.
The python version has to be defined here at ``extra:python``, too.
``extra:cenv:env_name``.
The python version has to be defined here at ``extra:cenv:python``, too.
Also you can define requirements only needed during development but not to be
included into the resulting conda package.
These requirements have to be defined in the
``extra:dev_requirements``-section.
``extra:cenv:dev_requirements``-section.

All other parts of the ``meta.yaml`` have to be defined as default.

Expand Down Expand Up @@ -94,10 +94,11 @@ A meta.yaml valid for cenv should look like the following:
- example_package

extra:
env_name: example
python: 3.6.8
dev_requirements:
- ipython >=7
cenv:
env_name: example
python: 3.6.8
dev_requirements:
- ipython >=7


.. attention::
Expand All @@ -108,7 +109,7 @@ A meta.yaml valid for cenv should look like the following:
- package >=0.1
The same is required for the ``extra:dev_requirements``-section.
The same is required for the ``extra:cenv:dev_requirements``-section.
If the section ``requirements:run_constrained`` is defined, too, these
dependency information is extracted for dependency collection, too.
Not defining a version will not create or update a conda-environment,
Expand Down

0 comments on commit 4846fc8

Please sign in to comment.