{"id":16271731,"url":"https://github.com/silvanmelchior/cme_parser","last_synced_at":"2025-07-13T03:35:00.154Z","repository":{"id":46027557,"uuid":"210827755","full_name":"silvanmelchior/cme_parser","owner":"silvanmelchior","description":"A tiny parser for more flexible conda environment files","archived":false,"fork":false,"pushed_at":"2021-11-19T06:07:44.000Z","size":23,"stargazers_count":15,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T07:51:23.671Z","etag":null,"topics":["cme-parser","conda","conda-environment","data-science","meta-environment","parser","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silvanmelchior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-25T11:26:16.000Z","updated_at":"2024-03-07T15:18:54.000Z","dependencies_parsed_at":"2022-08-26T00:14:45.485Z","dependency_job_id":null,"html_url":"https://github.com/silvanmelchior/cme_parser","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/silvanmelchior/cme_parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvanmelchior%2Fcme_parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvanmelchior%2Fcme_parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvanmelchior%2Fcme_parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvanmelchior%2Fcme_parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silvanmelchior","download_url":"https://codeload.github.com/silvanmelchior/cme_parser/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silvanmelchior%2Fcme_parser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265084149,"owners_count":23708871,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cme-parser","conda","conda-environment","data-science","meta-environment","parser","python"],"created_at":"2024-10-10T18:14:36.939Z","updated_at":"2025-07-13T03:35:00.126Z","avatar_url":"https://github.com/silvanmelchior.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Conda Meta Environment Parser\n\nThis tiny parser takes as input a meta-environment file, transforms it into an environment file and invokes conda on it.\nThe input, usually called **environment.yml.meta**, is a standard conda environment file which can be enriched with conditions for certain lines/blocks, e.g. to only include them on specific platforms or if certain flags are given.\n\n## Example\n\nThe following meta-file\n\n```\nname: demo_env\ndependencies:\n  - numpy=1.16.4\n  - tensorflow=1.14.0\n  - tensorflow-gpu=1.14.0 [use_gpu]\n  - winreg-helpers [platform == win32]\n```\n\ncan be used to set up a conda environment with\n\n`python create_env.py` (A)\n\nor\n\n`python create_env.py --flag use_gpu` (B).\n\nIn (A), the conda package *tensorflow-gpu* is not installed. In both cases, *winreg-helpers* is only installed on windows platforms.\n\n## Quickstart\n\nTo use CME Parser in your own project, create an **environment.yml.meta** file in your project folder, e.g. like this:\n\n```\nname: demo_env2\nchannels:\n  - conda-forge\n  - defaults\ndependencies:\n  - numpy=1.16.4\n  - matplotlib=3.1.0 [allow_plot and plot_tool == matplotlib]\n  - ggplot=0.11.5    [allow_plot and plot_tool == ggplot]\n  - pip=19.1.1\n  - some-linux-package=1.2.3 [platform startswith linux]\n  - pip:\n    - selenium=3.141.0\n```\n\nIf **create_env.py** gets called without an `--input` argument, it will try to find **environment.yml.meta** either in the same directory or its parent.\nThus, either directly add **create_env.py** to your project folder next to the meta-env file or add this repo as git submodule:\n\n```\n$ cd your_project_folder\n$ git rm environment.yml  # if exists\n$ echo \"environment.yml\" \u003e\u003e .gitignore\n$ git add environment.yml.meta\n$ git submodule add https://github.com/silvanmelchior/cme_parser\n$ git commit -m \"cme parser added\"\n$ git push\n```\n\nIf you now execute (in the case of using a submodule)\n\n`python cme_parser/create_env.py --flag allow_plot --variable plot_tool matplotlib`\n\nin your project folder, CME Parser will find the meta-env file and create **environment.yml**.\nIn general, if not specified differently with a `--output` argument, the parser will write the output into the same location as the input, removing *.meta* from the filename.\nIf *.meta* is not present, it will append *_out* to the filename instead.\nIn all cases, the parser will in the end invoke conda to create the environment specified by the output file. \n\n## Requirements\n\nCME Parser is written in pure Python and does only need standard library packages.\nIt can be executed e.g. in the conda default environment (called *base*) and was tested with Python 2.7 and 3.6 / 3.7.\n\n## Syntax\n\nIf a line contains `[condition]`, the parser only outputs it if the condition is met (removing the condition itself).\nIf a line contains `[[condition` and a later line `]]`, the parser outputs everything in between only if the condition is met (removing the two lines marking the block borders).\nNested blocks are allowed.\n\nA condition can either be an arbitrary name, which is then interpreted as a flag, or a triplet of an arbitrary name, some operator and a string.\nIn the latter, the name is interpreted as variable and the operator can be one of `==`, `!=`, `startswith`, `endswith`, `contains`.\nThe string does not need any special terminators (e.g. no `\"\"`).\n\nConditions can be combined by adding `and` and `or` in between them.\nFurthermore, `not` can be added in front of a condition. The precedence order is `or` (highest), `and`, `not` (lowest), so e.g. `a and not b` is evaluated as `a and (not b)`.\nBrackets to enforce another evaluation order are currently not supported.\n\nFlags are evaluated as *false* per default, except given to the parser with `-f flag_name`.\nVariables have to be given to the parser with `-v var_name var_value`, otherwise an error is risen.\nAn exception are variables of the form  `var_name%value`, which are interpreted as variable `var_name` with default value `value`.\nFurthermore, the special variable `platform` is reserved and populated with the result of `sys.platform`.\n\n## Command Line Options\n\n| Short  | Long | Description |\n| --- | --- | --- |\n| -h  | --help | show usage help message |\n| -i  | --input | specify meta environment input file |\n| -o  | --output | specify environment output file |\n| -f  | --flag | set custom flag for parsing |\n| -v  | --variable | define custom variable for parsing |\n| -q  | --quiet | quietly overwrite output if already exists |\n| -p  | --parse-only | do not invoke conda afterwards |\n| -c  | --no-comment | do not add auto-generated comment to output |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvanmelchior%2Fcme_parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilvanmelchior%2Fcme_parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilvanmelchior%2Fcme_parser/lists"}