code: def parse_requirements(fname='requirements.txt'):
      
      from os.path import dirname, join, exists
      import re
      require_fpath = join(dirname(__file__), fname)
  
      def parse_line(line):
          """
          Parse information from a line in a requirements text file
          """
          info = {}
          if line.startswith('-e '):
              info['package'] = line.split('#egg=')[1]
          else:
              # Remove versioning from the package
              pat = '(' + '|'.join(['>=', '==', '>']) + ')'
              parts = re.split(pat, line, maxsplit=1)
              parts = [p.strip() for p in parts]
  
              info['package'] = parts[0]
              if len(parts) > 1:
                  op, rest = parts[1:]
                  if ';' in rest:
                      # Handle platform specific dependencies
                      # http://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-platform-specific-dependencies
                      version, platform_deps = map(str.strip, rest.split(';'))
                      info['platform_deps'] = platform_deps
                  else:
                      version = rest  # NOQA
                  info['version'] = (op, version)
          return info
  
      # This breaks on pip install, so check that it exists.
      if exists(require_fpath):
          with open(require_fpath, 'r') as f:
              packages = []
              for line in f.readlines():
                  line = line.strip()
                  if line and not line.startswith('#'):
                      info = parse_line(line)
                      package = info['package']
                      if not sys.version.startswith('3.4'):
                          # apparently package_deps are broken in 3.4
                          platform_deps = info.get('platform_deps')
                          if platform_deps is not None:
                              package += ';' + platform_deps
                      packages.append(package)
              return packages
      return []
docs: Parse the package dependencies listed in a requirements file but strips
      specific versioning information.
  
      TODO:
          perhaps use https://github.com/davidfischer/requirements-parser instead
  
      CommandLine:
          python -c "import setup; print(setup.parse_requirements())"