Skip to content

Commit

Permalink
Merge branch 'move_python_version_definition_of_development_environme…
Browse files Browse the repository at this point in the history
…nt_into_extras'
  • Loading branch information
skallfass committed Sep 28, 2019
2 parents 599c0c5 + 8c46836 commit c1c1c8b
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 23 deletions.
14 changes: 12 additions & 2 deletions README.rst
Expand Up @@ -46,6 +46,7 @@ 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``.

The steps run by cenv:

Expand All @@ -69,12 +70,14 @@ The usage of cenv reduces the conda commands to use to the following:
* ``conda remove -n ... --all`` to remove an environment
* ``cenv`` to create / update an environment


Documentation
-------------

For complete documentation see
`readthedocs <https://cenv-tool.readthedocs.io/en/latest/>`_.


Installation
------------

Expand All @@ -87,12 +90,14 @@ Install ``cenv`` using pip:
Now run ``init_cenv`` to create the relevant config-files and add the
autoactivate- and autoupdate-shell-function to your ``.bashrc`` / ``.zshrc``.


autoactivate and autoupdate
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Per default these features are deactivated, even if added to your shell by
running ``init_cenv``.


autoactivate-feature
~~~~~~~~~~~~~~~~~~~~

Expand All @@ -105,6 +110,7 @@ To activate the autoactivate-features run:
autoactivate_toggle
autoupdate-feature
~~~~~~~~~~~~~~~~~~

Expand All @@ -118,6 +124,7 @@ For the autoupdate-feature run:
autoupdate_toggle
Usage
-----

Expand Down Expand Up @@ -153,12 +160,14 @@ 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 ``meta.yaml``.
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
``env_name``.
The python version has to be defined here at ``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 ``dev_requirements``\ -section.
These requirements have to be defined in the ``dev_requirements`` -section.

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

Expand Down Expand Up @@ -200,6 +209,7 @@ A meta.yaml valid for cenv should look like the following:
extra:
env_name: example
python: 3.6
dev_requirements:
- ipython >=7.2.0
Expand Down
5 changes: 5 additions & 0 deletions cenv_tool/schemata.py
Expand Up @@ -92,6 +92,11 @@ class SNExtra(Schema):
validate=lambda x: ' ' not in x,
)

python = fields.String(
strict=True,
required=True
)

dev_requirements = fields.List(
fields.String(
strict=True,
Expand Down
13 changes: 13 additions & 0 deletions cenv_tool/utils.py
Expand Up @@ -123,8 +123,21 @@ def extract_dependencies_from_meta_yaml(meta_yaml_content: dict) -> List[str]:
"""
# extract the dependencies defined the the requirements-run-section
dependencies = meta_yaml_content['requirements']['run']

# remove the python version definition. The version will be extracted
# from the extra-python section
dependencies = list(
filter(
lambda x: x.split(' ')[0] != 'python',
dependencies
)
)

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

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


Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Expand Up @@ -27,6 +27,7 @@ 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
``conda-build/meta.yaml``).
The python version must be defined in ``extra`` inside the key ``python``.

The steps run by cenv:

Expand Down
2 changes: 2 additions & 0 deletions docs/usage.rst
Expand Up @@ -49,6 +49,7 @@ 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.
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
Expand Down Expand Up @@ -92,6 +93,7 @@ A meta.yaml valid for cenv should look like the following:

extra:
env_name: example
python: 3.6
dev_requirements:
- ipython >=7

Expand Down
11 changes: 6 additions & 5 deletions pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cenv_tool"
version = "1.1.2"
version = "2.0.0"
description = "conda environment creation and update from meta.yaml"
license = "MIT"
authors = ["Simon Kallfass <skallfass@ouroboros.info>"]
Expand Down Expand Up @@ -28,13 +28,13 @@ marshmallow = ">=2.19,<3"
coverage = ">=4"
coverage-badge = ">=1"
ipython = ">=7"
pylint = "==2.*,<2.4"
pylint = "<2.4,==2.*"
pytest = "==5.*,>=5.0.0"
pytest-cov = ">=2"
pytest-datafiles = ">=2"
yapf = ">=0"
sphinx = "==2.*,>=2.0.0"
sphinx-autodoc-typehints = "==1.*,<1.8.0"
sphinx-autodoc-typehints = "<1.8.0,==1.*"
sphinx_rtd_theme = ">=0"


Expand All @@ -44,8 +44,9 @@ init_cenv = "cenv_tool.init_cenv:main"


[tool.poetry.extras]
docs = ["sphinx", "sphinx-autodoc-typehints", "sphinx_rtd_theme"]
tests = ["pytest", "pytest-cov", "pytest-datafiles", "coverage-badge", "coverage"]
docs = ["sphinx", "sphinx-autodoc-typehints", "sphinx-rtd-theme"]
tests = ["coverage", "coverage-badge", "pytest", "pytest-cov", "pytest-datafiles"]



[tool.dephell.main]
Expand Down
28 changes: 13 additions & 15 deletions setup.py
Expand Up @@ -21,9 +21,9 @@
setup(
long_description=readme,
name='cenv_tool',
version='1.1.2',
version='2.0.0',
description='conda environment creation and update from meta.yaml',
python_requires='==3.*,>=3.7.0',
python_requires='==3.*,>=3.7',
project_urls={
'homepage': 'https://www.cenv.ouroboros.info',
'repository': 'https://github.com/skallfass/cenv_tool'
Expand All @@ -45,23 +45,21 @@
packages=['cenv_tool'],
package_data={'cenv_tool': ['*.sh', '*.yml']},
install_requires=[
'attrs==19.*,>=19.0.0', 'jinja2>=2', 'marshmallow<3,>=2.19',
'attrs==19.*,>=19.0', 'jinja2>=2', 'marshmallow<3,>=2.19',
'pyyaml==5.*,>=5.0.0', 'six>=1.12'
],
extras_require={
'dev': [
'coverage-badge==1.*,>=1.0.0', 'ipython>=7', 'monkeytype>=19',
'pylint>=2', 'pytest==5.*,>=5.0.0', 'pytest-cov==2.*,>=2.0.0',
'pytest-datafiles==2.*,>=2.0.0', 'sphinx==2.*,>=2.0.0',
'sphinx-autodoc-typehints==1.*,>=1.0.0',
'sphinx-rtd-theme==0.*,>=0.0.0', 'yapf>=0'
],
'tests': [
'pytest==5.*,>=5.0.0', 'pytest-cov==2.*,>=2.0.0',
'pytest-datafiles==2.*,>=2.0.0'
'coverage>=4', 'coverage-badge>=1', 'pytest==5.*,>=5.0.0',
'pytest-cov>=2', 'pytest-datafiles>=2'
],
'docs': [
'sphinx==2.*,>=2.0.0', 'sphinx-autodoc-typehints==1.*,>=1.0.0'
]
'dev': [
'coverage>=4', 'coverage-badge>=1', 'ipython>=7',
'pylint<2.4,==2.*', 'pytest==5.*,>=5.0.0', 'pytest-cov>=2',
'pytest-datafiles>=2', 'sphinx==2.*,>=2.0.0',
'sphinx-autodoc-typehints<1.8.0,==1.*', 'sphinx-rtd-theme>=0',
'yapf>=0'
],
'docs': ['sphinx==2.*,>=2.0.0', 'sphinx-autodoc-typehints<1.8.0,==1.*']
},
)
1 change: 1 addition & 0 deletions tests/testproject/conda-build/meta.yaml
Expand Up @@ -35,5 +35,6 @@ test:

extra:
env_name: "cenv_testing_project0001"
python: 3.7.3
dev_requirements:
- pylint >=2.2.2
3 changes: 2 additions & 1 deletion tests/utils_test.py
Expand Up @@ -30,6 +30,7 @@
},
'extra': {
'dev_requirements': ['pylint >=2.2.2'],
'python': '3.7.3',
'env_name': 'cenv_testing_project0001',
},
'source': {
Expand Down Expand Up @@ -90,7 +91,7 @@ def test_extract_dependencies_from_meta_yaml(
"""Test if the read_meta_yaml function works as expected."""
meta_yaml_content = read_meta_yaml(path=meta_yaml_path)
dependencies = extract_dependencies_from_meta_yaml(meta_yaml_content)
assert expected_dependencies == dependencies
assert list(sorted(expected_dependencies)) == list(sorted(dependencies))



Expand Down

0 comments on commit c1c1c8b

Please sign in to comment.