Repository: conda/conda

Issue:
Add flag to build environment.yml without build strings
https://gitter.im/conda/conda?at=59ef54ebe44c43700a70e9a4
https://twitter.com/drvinceknight/status/922837449092542464?ref_src=twsrc%5Etfw

> Due to hashes of packages being introduced in `envinronment.yml` I'm getting all sorts of issues with building envs from file. (Very new problem)


Discussion:
Actually, looks like the flag might already be there as `--no-builds`

```
kfranz@0283:~/continuum/conda *4.3.x ❯ /conda/bin/conda env export --help
usage: conda-env export [-h] [-c CHANNEL] [--override-channels]
                        [-n ENVIRONMENT | -p PATH] [-f FILE] [--no-builds]
                        [--ignore-channels] [--json] [--debug] [--verbose]

Export a given environment

Options:

optional arguments:
  -h, --help            Show this help message and exit.
  -c CHANNEL, --channel CHANNEL
                        Additional channel to include in the export
  --override-channels   Do not include .condarc channels
  -n ENVIRONMENT, --name ENVIRONMENT
                        Name of environment (in
                        /conda/envs:/Users/kfranz/.conda/envs).
  -p PATH, --prefix PATH
                        Full path to environment prefix (default: /conda).
  -f FILE, --file FILE
  --no-builds           Remove build specification from dependencies
  --ignore-channels     Do not include channel names with package names.
  --json                Report all output as json. Suitable for using conda
                        programmatically.
  --debug               Show debug output.
  --verbose, -v         Use once for info, twice for debug, three times for
                        trace.

examples:
    conda env export
    conda env export --file SOME_FILE

```
But the `--no-builds` flag appears not to work, based on a spot test.

Resolving patch:
diff --git a/conda_env/env.py b/conda_env/env.py
--- a/conda_env/env.py
+++ b/conda_env/env.py
@@ -48,9 +48,9 @@ def from_environment(name, prefix, no_builds=False, ignore_channels=False):
     pip_pkgs = sorted(installed - conda_pkgs)
 
     if no_builds:
-        dependencies = ['='.join(a.quad[0:3]) for a in sorted(conda_pkgs)]
+        dependencies = ['='.join((a.name, a.version)) for a in sorted(conda_pkgs)]
     else:
-        dependencies = ['='.join(a.quad[0:3]) for a in sorted(conda_pkgs)]
+        dependencies = ['='.join((a.name, a.version, a.build)) for a in sorted(conda_pkgs)]
     if len(pip_pkgs) > 0:
         dependencies.append({'pip': ['=='.join(a.rsplit('-', 2)[:2]) for a in pip_pkgs]})
     # conda uses ruamel_yaml which returns a ruamel_yaml.comments.CommentedSeq


Test patch:
diff --git a/tests/conda_env/test_cli.py b/tests/conda_env/test_cli.py
--- a/tests/conda_env/test_cli.py
+++ b/tests/conda_env/test_cli.py
@@ -8,6 +8,7 @@
 
 from conda_env.exceptions import SpecNotFound
 from conda_env.cli.main import create_parser
+from conda_env.yaml import load as yaml_load
 
 from conda.base.context import context
 from conda.base.constants import ROOT_ENV_NAME
@@ -243,7 +244,7 @@ def test_create_env(self):
         run_conda_command(Commands.CREATE, test_env_name_2)
         self.assertTrue(env_is_created(test_env_name_2))
 
-    def test_export(self):
+    def test_env_export(self):
         """
             Test conda env export
         """
@@ -257,11 +258,20 @@ def test_export(self):
             env_yaml.write(snowflake)
             env_yaml.flush()
             env_yaml.close()
+
             run_env_command(Commands.ENV_REMOVE, test_env_name_2)
             self.assertFalse(env_is_created(test_env_name_2))
             run_env_command(Commands.ENV_CREATE, env_yaml.name)
             self.assertTrue(env_is_created(test_env_name_2))
 
+            # regression test for #6220
+            snowflake, e, = run_env_command(Commands.ENV_EXPORT, test_env_name_2, '--no-builds')
+            assert not e.strip()
+            env_description = yaml_load(snowflake)
+            assert len(env_description['dependencies'])
+            for spec_str in env_description['dependencies']:
+                assert spec_str.count('=') == 1
+
     def test_list(self):
         """
             Test conda list -e and conda create from txt