Skip to content

Commit

Permalink
Merge pull request #333 from pywbem/fix_331_use-gitpython-205
Browse files Browse the repository at this point in the history
Use GitPython 2.0.5 and improve Python installer
  • Loading branch information
andy-maier committed Jun 8, 2016
2 parents d61e34b + 3e9189f commit fc4e67a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 26 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,13 @@ install:
- pip list
- make develop
- pip list
- python -c "import setuptools,os; print('Version of GitPython package:'); sp=os.path.dirname(os.path.dirname(setuptools.__file__)); print(open(sp+'/git/__init__.py','r').read())"

# TODO 2016-05 AM: Remove displaying of GitPython version, once GitPython 2.0.4 is released.

# commands to run builds & tests
script:
- make check
- make build
- if [[ $(python -c "import sys; print('%s.%s'%sys.version_info[0:2])") != 2.6 ]]; then make builddoc; fi
- if [[ $(python -c "import sys; print('%s.%s'%sys.version_info[0:2])") != 2.6 ]]; then make builddoc; else echo "make builddoc is disabled on Python 2.6 until GitPython runs again (see its issue 457)"; fi
- make test

# TODO 2016-05 AM: Remove disabling of "make builddoc" for Python 2.6, once GitPython 2.0.4 is released.
# TODO 2016-05 AM: Remove disabling of "make builddoc" for Python 2.6, once GitPython runs on Python 2.6.

38 changes: 18 additions & 20 deletions os_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ def install_swig(installer, dry_run, verbose):
string_types = basestring, # pylint: disable=invalid-name
text_type = unicode # pylint: disable=invalid-name
binary_type = str # pylint: disable=invalid-name
from xmlrpclib import ServerProxy as xmlrpc_ServerProxy
else:
string_types = str, # pylint: disable=invalid-name
text_type = str # pylint: disable=invalid-name
binary_type = bytes # pylint: disable=invalid-name
from xmlrpc.client import ServerProxy as xmlrpc_ServerProxy


class OsDistribution(Distribution):
Expand Down Expand Up @@ -871,26 +873,22 @@ def is_available(self, pkg_name, version_reqs=None):
For a description of the parameters, return value and exceptions, see
`BaseInstaller.is_available()`.
"""
# We use the internal functions of the pip module, because the pip
# command line does not return version information from Pypi.
# TODO: This is not supported on older pip versions (e.g. 1.4).
search_command = pip.commands.search.SearchCommand()
options, _ = search_command.parse_args([pkg_name])
pypi_hits = search_command.search(pkg_name, options)
hits = pip.commands.search.transform_hits(pypi_hits)
for hit in hits:
if hit['name'] == pkg_name:
if not version_reqs:
versions = hit['versions']
else:
versions = []
for _version in hit['versions']:
if self.version_matches_req(_version, version_reqs):
versions.append(_version)
version_sufficient = len(versions) > 0
return (True, version_sufficient, versions)

return (False, False, None)
# We use the XML-RPC API of the new Pypi warehouse site at https://pypi.io/pypi.
# The pip.commands.search.SearchCommand() API used before uses the
# old https://pypi.python.org/pypi site which has quite bogus search behaviour.
pypi_url = 'https://pypi.io/pypi'
pypi_rpc = xmlrpc_ServerProxy(pypi_url)
info_dicts = pypi_rpc.search(dict(name=pkg_name)) # Empty list, if not found.
versions = [d['version'] for d in info_dicts]
available = False
sufficient = False
for version in versions:
available = True
if self.version_matches_req(version, version_reqs) \
if version_reqs else True:
sufficient = True
break
return (available, sufficient, versions)

def ensure_installed(self, pkg_name, version_reqs=None, dry_run=False,
verbose=True, ignore=False):
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ def run(self):
"Sphinx>=1.3",
# The ordereddict package is a backport of collections.OrderedDict
# to Python 2.6. OrderedDict is needed by the GitPython package
# since its 2.0.3 version. GitPython is needed by sphinx-git.
# since its 2.0.3 version (but only its 2.0.5 version uses it
# correctly). GitPython is needed by sphinx-git.
"ordereddict" if sys.version_info[0:2] == (2, 6) else None,
"GitPython>=2.0.5",
"sphinx-git",
"httpretty",
"lxml",
Expand Down

0 comments on commit fc4e67a

Please sign in to comment.