Skip to content

Commit

Permalink
BUG: keep dependencies of Enthought egg when repacking.
Browse files Browse the repository at this point in the history
  • Loading branch information
cournape committed Jun 4, 2015
1 parent 38c6075 commit 6b0f166
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
16 changes: 10 additions & 6 deletions enstaller/tools/repack.py
Expand Up @@ -90,25 +90,31 @@ def _get_spec_data(source_egg_path, build_number, platform_string=None):
raise EnstallerException(msg.format(metadata.platform_tag))
egg_basename = metadata.name
version = str(metadata.version)
dependencies = []
elif _looks_like_enthought_egg(source_egg_path):
metadata = EggMetadata.from_egg(source_egg_path)
# The name as used in spec/depend and endist.dat is the so-called
# egg basename (i.e. not normalied to lower case)
egg_basename = metadata.egg_basename
version = metadata.upstream_version
dependencies = metadata.runtime_dependencies
else:
msg = "Unrecognized format: {0!r}".format(source_egg_path)
raise EnstallerException(msg)

data = {"build": build_number, "packages": [], "name": egg_basename,
"version": version}
data = {"build": build_number, "packages": dependencies,
"name": egg_basename, "version": version}

if os.path.exists(ENDIST_DAT):
data.update(_parse_endist_for_spec_depend(ENDIST_DAT))

return data, metadata


def _raw_packages_to_requirements(packages):
return tuple(Requirement.from_spec_string(s) for s in packages)


def _get_spec(source_egg_path, build_number, platform_string=None):
data, metadata = _get_spec_data(source_egg_path, build_number,
platform_string)
Expand All @@ -130,10 +136,7 @@ def _get_spec(source_egg_path, build_number, platform_string=None):
if version.upstream.is_worked_around:
raise InvalidVersion(str(version.upstream))

requirements = tuple(
Requirement.from_spec_string(s) for s in data["packages"]
)
dependencies = Dependencies(runtime=requirements)
dependencies = Dependencies(runtime=data["packages"])
pkg_info = PackageInfo.from_egg(source_egg_path)
return EggMetadata(raw_name, version, epd_platform, metadata.python_tag,
metadata.abi_tag, dependencies, pkg_info,
Expand All @@ -147,6 +150,7 @@ def _parse_endist_for_egg_content(path):

def _parse_endist_for_spec_depend(path):
data = _parse_endist(path)
data["packages"] = _raw_packages_to_requirements(data.get("packages", []))
return dict((k, data[k]) for k in data if k in ACCEPTED_ENDIST_SPEC_KEYS)


Expand Down
24 changes: 21 additions & 3 deletions enstaller/tools/tests/test_repack.py
Expand Up @@ -12,9 +12,10 @@

from egginst._compat import assertCountEqual
from egginst.eggmeta import info_from_z
from egginst.tests.common import (DUMMY_EGG, STANDARD_EGG,
STANDARD_EGG_WITH_EXT, NOSE_1_2_1,
VTK_EGG_DEFERRED_SOFTLINK)
from egginst.tests.common import (
DUMMY_EGG, STANDARD_EGG, LEGACY_EGG_INFO_EGG, STANDARD_EGG_WITH_EXT,
NOSE_1_2_1, VTK_EGG_DEFERRED_SOFTLINK
)
from egginst.vendor.six.moves import unittest
from egginst.vendor.zipfile2 import ZipFile

Expand Down Expand Up @@ -152,6 +153,23 @@ def test_simple_enthought_egg(self):
# Then
self.assertTrue(os.path.exists(target))

def test_dependencies(self):
# Given
egg = LEGACY_EGG_INFO_EGG
source = os.path.join(self.prefix, os.path.basename(egg))
shutil.copy(egg, source)
r_runtime_dependencies = EggMetadata.from_egg(egg).runtime_dependencies

target = os.path.join(self.prefix, egg)

# When
repack(source, 11, "rh5-64")

# Then
self.assertTrue(os.path.exists(target))
metadata = EggMetadata.from_egg(target)
self.assertEqual(metadata.runtime_dependencies, r_runtime_dependencies)

def test_enthought_name_upper_case(self):
# Given
source = os.path.join(self.prefix,
Expand Down

0 comments on commit 6b0f166

Please sign in to comment.