Skip to content

Commit

Permalink
Fix missing == and add project level namespace map support
Browse files Browse the repository at this point in the history
  • Loading branch information
ceball committed Oct 2, 2018
1 parent e349ddb commit 89f971d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pyctdev/_conda.py
Expand Up @@ -48,7 +48,7 @@
yaml = None

from doit.action import CmdAction
from .util import _options_param,_options_param2, test_python, test_group, test_requires, get_tox_deps, get_tox_cmds, get_tox_python, get_env, pkg_tests, test_matrix, echo, get_buildreqs, read_pins, read_conda_packages,_all_extras_param
from .util import _options_param,_options_param2, test_python, test_group, test_requires, get_tox_deps, get_tox_cmds, get_tox_python, get_env, pkg_tests, test_matrix, echo, get_buildreqs, read_pins, read_conda_packages,_all_extras_param, read_conda_namespace_map
# TODO: for caching env on travis, what about links? option to copy?

try:
Expand Down Expand Up @@ -406,10 +406,20 @@ def _join_the_club(dep):
new = re.sub(r'\[.*?\]','',dep)
# not much point warning only here, since it happens in other places too
#if new!=dep:warnings.warn("Changed your dep from %s to %s"%(dep,new))

# should be read just once rather than for each dep!
nsmap = read_conda_namespace_map('setup.cfg')

ms = MatchSpec(new)
out = "%s"%ms.name
out = "%s"%nsmap.get(ms.name,ms.name)
if ms.version is not None:
out+= " %s"%ms.version
# why it doesn't include == already?
if '==' in new:
assert "===" not in new # sorry
out+= " =="
else:
out+= " "
out+= "%s"%ms.version
return out


Expand Down
21 changes: 21 additions & 0 deletions pyctdev/util.py
Expand Up @@ -264,3 +264,24 @@ def read_conda_packages(f,name):
return ConfigHandler._parse_list(ConfigHandler._parse_dict(packages_raw)[name])


def read_conda_namespace_map(f):
from setuptools.config import ConfigHandler
# duplicates some earlier configparser stuff (which doesn't
# support py2; need to clean up)
try:
import configparser
except ImportError:
import ConfigParser as configparser # python2 (also prevents dict-like access)
pyctdev_section = 'tool:pyctdev.conda'
config = configparser.ConfigParser()
config.read(f)

if pyctdev_section not in config.sections():
return {}

try:
namespacemap_raw = config.get(pyctdev_section,'namespace_map')
except configparser.NoOptionError:
namespacemap_raw = ''

return ConfigHandler._parse_dict(namespacemap_raw)

0 comments on commit 89f971d

Please sign in to comment.