Advertisement
cooperlees

Untitled

Aug 28th, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.81 KB | None | 0 0
  1. diff --git i/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/setup.py w/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/setup.py
  2. index f206e2c..10ab074 100755
  3. --- i/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/setup.py
  4. +++ w/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/setup.py
  5. @@ -1,6 +1,7 @@
  6.  #!/usr/bin/env python3
  7.  
  8.  from setuptools import setup, find_packages
  9. +from src.bandersnatch import __version__
  10.  
  11.  # Naming these to use with tests_require - Bitbucket Pipelines will use requirements.txt for test deps
  12.  test_deps = [
  13. @@ -24,7 +25,7 @@ install_deps = [
  14.  
  15.  setup(
  16.      name='bandersnatch',
  17. -    version='2.1.2.dev0',
  18. +    version=__version__,
  19.      description='Mirroring tool that implements the client (mirror) side of PEP 381',
  20.      long_description='\n\n'.join(
  21.          [open('README').read(), open('CHANGES.txt').read()]
  22. diff --git i/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/__init__.py w/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/__init__.py
  23. index 5bb534f..5c4eedb 100644
  24. --- i/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/__init__.py
  25. +++ w/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/__init__.py
  26. @@ -1 +1,21 @@
  27.  # package
  28. +
  29. +from collections import namedtuple
  30. +
  31. +# a namedtuple like that given by sys.version_info
  32. +__version_info__ = namedtuple(
  33. +    'version_info',
  34. +    'major minor micro releaselevel serial')(
  35. +        major=2,
  36. +        minor=1,
  37. +        micro=2,
  38. +        releaselevel='dev0',
  39. +        serial=0
  40. +    )
  41. +
  42. +if __version_info__.releaselevel:
  43. +    __version__ = '{v.major}.{v.minor}.{v.micro}'.format(v=__version_info__)
  44. +else:
  45. +    __version__ = '{v.major}.{v.minor}.{v.micro}{v.releaselevel}'.format(
  46. +        v=__version_info__
  47. +    )
  48. diff --git i/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/utils.py w/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/utils.py
  49. index 39e3283..d832128 100644
  50. --- i/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/utils.py
  51. +++ w/2.1.2dev0/src/pypa-bandersnatch-0eccd9d664b7/src/bandersnatch/utils.py
  52. @@ -2,21 +2,17 @@ import contextlib
  53.  import hashlib
  54.  import os
  55.  import os.path
  56. -import pkg_resources
  57.  import sys
  58.  import tempfile
  59.  
  60. +from . import __version__
  61.  
  62.  def user_agent():
  63.      template = 'bandersnatch/{version} ({python}, {system})'
  64.      system = os.uname()
  65.      system = ' '.join([system[0], system[4]])
  66. -    version = pkg_resources.require("bandersnatch")[0].version
  67. -    # Support Python 2 + 3 - No sys.subversion in Py3
  68. -    try:
  69. -        python = sys.subversion[0]
  70. -    except AttributeError:
  71. -        python = sys.implementation.name
  72. +    version = __version__
  73. +    python = sys.implementation.name
  74.      python += ' {0}.{1}.{2}-{3}{4}'.format(*sys.version_info)
  75.      return template.format(**locals())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement