Example #1
0
    def test_fix_object_code_with_targets(self):
        """
        Test we handle the targets.dat hack correctly in fix_object_code.

        Some of our eggs use /PLACEHOLD in the LC_LOAD_DYLIB command (i.e.
        inside the dependency names). Those are rewritten by finding the
        dependency in the installed egg first.

        We're ensuring here that those are also rewritten correctly.
        """
        # targets.dat hack is handled in the function that expects an egg, but
        # we don't want to deal with an egg. Instead, we emulate the
        # targets.dat hack by patching object_code._targets with mock
        pyext_dependency_dir = op.join("lib", "foo-4.2")

        with mkdtemp() as d:
            installed_pyext_dependency = op.join(d, pyext_dependency_dir, op.basename(PYEXT_DEPENDENCY))
            installed_pyext_dependency_dir = op.dirname(installed_pyext_dependency)
            with mock.patch("egginst.object_code._targets", [d, installed_pyext_dependency_dir]):
                installed_pyext = op.join(d, op.basename(PYEXT_WITH_LEGACY_PLACEHOLD_DEPENDENCY))
                shutil.copy(PYEXT_WITH_LEGACY_PLACEHOLD_DEPENDENCY, installed_pyext)

                os.makedirs(installed_pyext_dependency_dir)
                shutil.copy(PYEXT_DEPENDENCY, installed_pyext_dependency_dir)

                fix_object_code(installed_pyext)
                deps = set(rewriter_factory(installed_pyext).dependencies)

                self.assertTrue(installed_pyext_dependency in deps)
Example #2
0
    def test_fix_object_code_legacy_macho(self):
        """
        Test that we handle correctly our legacy egg with the /PLACHOLD * 20 hack.
        """
        with mkdtemp() as d:
            copy = op.join(d, "foo.dylib")
            shutil.copy(LEGACY_PLACEHOLD_FILE, copy)

            with mock.patch("egginst.object_code._targets", [d]):
                fix_object_code(copy)
                rpaths = rewriter_factory(copy).rpaths

                self.assertEqual(rpaths, [d])
Example #3
0
    def test_fix_object_code_wo_legacy_macho(self):
        """
        Test that we handle correctly egg *without* the /PLACHOLD (i.e. we
        don't touch them).
        """
        r_rpaths = FILE_TO_RPATHS[NOLEGACY_RPATH_FILE]
        with mkdtemp() as d:
            copy = op.join(d, "foo.dylib")
            shutil.copy(NOLEGACY_RPATH_FILE, copy)

            with mock.patch("egginst.object_code._targets", [d]):
                fix_object_code(copy)
                rpaths = rewriter_factory(copy).rpaths

                self.assertEqual(rpaths, r_rpaths)