From 8365f9fe3ac0d7e6c9ee7f92a633228a92d4084d Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Sun, 20 Mar 2011 14:14:57 +0000 Subject: [PATCH] Added a special-case so we always find an implementation of Python If we can't find a distribution package for Python, add the version of Python currently interpreting 0install as a candidate. This is a temporary hack so that programs can state their dependency on Python explicitly without breaking on platforms where we don't support the native package manager. Many feeds currently assume that Python must be installed, since 0install itself depends on it, and use a #! line to run it. However, this doesn't work on Windows or on Linux systems where "python" is now Python 3. --- tests/testdistro.py | 6 ++++++ zeroinstall/injector/distro.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/tests/testdistro.py b/tests/testdistro.py index 05f6a7e..7fcbebd 100755 --- a/tests/testdistro.py +++ b/tests/testdistro.py @@ -70,6 +70,12 @@ class TestDistro(BaseTest): host.get_package_info('gimp', factory) self.assertEquals(self.feed.implementations, {}) + # Special case: we can always find a version of Python + master_feed = model.ZeroInstallFeed(None) + master_feed.url = 'http://repo.roscidus.com/python/python' + feed = host.get_feed(master_feed) + self.assertEquals(1, len(feed.implementations)) + def testDebian(self): dpkgdir = os.path.join(os.path.dirname(__file__), 'dpkg') host = distro.DebianDistribution( diff --git a/zeroinstall/injector/distro.py b/zeroinstall/injector/distro.py index 63abfe2..a3480c3 100644 --- a/zeroinstall/injector/distro.py +++ b/zeroinstall/injector/distro.py @@ -201,6 +201,21 @@ class Distribution(object): return impl self.get_package_info(package, factory) + + if master_feed.url == 'http://repo.roscidus.com/python/python' and all(not impl.installed for impl in feed.implementations.values()): + # Hack: we can support Python on platforms with unsupported package managers + # by adding the implementation of Python running us now to the list. + python_version = '.'.join([str(v) for v in sys.version_info if isinstance(v, int)]) + impl_id = 'package:host:python:' + python_version + assert impl_id not in feed.implementations + impl = model.DistributionImplementation(feed, impl_id, self) + impl.installed = True + impl.version = model.parse_version(python_version) + impl.main = sys.executable + impl.upstream_stability = model.packaged + impl.machine = host_machine # (hopefully) + feed.implementations[impl_id] = impl + return feed def fetch_candidates(self, master_feed): -- 2.11.4.GIT