Commits

Daniel Holth  committed 542429e Draft

initial commit

  • Participants

Comments (0)

Files changed (7)

+Daniel Holth
+Michele Lacchia
+Paul Moore
+0.0.0
+=====
+- Initial version
+"pep425tags" copyright (c) 2012 Daniel Holth <dholth@fastmail.fm> and
+contributors (see AUTHORS.txt)
+
+The MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+pep425
+======
+
+Reference implementation for PEP 425 "Compatibility tags for built distributions."
+

File pep425tags.py

+"""Generate and work with PEP 425 Compatibility Tags."""
+
+import sys
+
+try:
+    import sysconfig
+except ImportError:  # pragma nocover
+    # Python < 2.7
+    import distutils.sysconfig as sysconfig
+import distutils.util
+
+
+def get_abbr_impl():
+    """Return abbreviated implementation name."""
+    if hasattr(sys, 'pypy_version_info'):
+        pyimpl = 'pp'
+    elif sys.platform.startswith('java'):
+        pyimpl = 'jy'
+    elif sys.platform == 'cli':
+        pyimpl = 'ip'
+    else:
+        pyimpl = 'cp'
+    return pyimpl
+
+
+def get_impl_ver():
+    """Return implementation version."""
+    impl_ver = sysconfig.get_config_var("py_version_nodot")
+    if not impl_ver:
+        impl_ver = ''.join(map(str, sys.version_info[:2]))
+    return impl_ver
+
+
+def get_platform():
+    """Return our platform name 'win32', 'linux_x86_64'"""
+    # XXX remove distutils dependency
+    return distutils.util.get_platform().replace('.', '_').replace('-', '_')
+
+
+def get_supported(versions=None):
+    """Return a list of supported tags for each version specified in
+    `versions`.
+
+    :param versions: a list of string versions, of the form ["33", "32"], 
+        or None. The first version will be assumed to support our ABI.
+    """
+    supported = []
+    
+    # Versions must be given with respect to the preference
+    if versions is None:
+        versions = []
+        major = sys.version_info[0]
+        # Support all previous minor Python versions.
+        for minor in range(sys.version_info[1], -1, -1):
+            versions.append(''.join(map(str, (major, minor))))
+            
+    impl = get_abbr_impl()
+    
+    abis = []
+
+    soabi = sysconfig.get_config_var('SOABI')
+    if soabi and soabi.startswith('cpython-'):
+        abis[0:0] = ['cp' + soabi.split('-', 1)[-1]]
+ 
+    abi3s = set()
+    import imp
+    for suffix in imp.get_suffixes():
+        if suffix[0].startswith('.abi'):
+            abi3s.add(suffix[0].split('.', 2)[1])
+
+    abis.extend(sorted(list(abi3s)))
+
+    abis.append('none')
+
+    arch = get_platform()
+    
+    # Current version, current API (built specifically for our Python):
+    for abi in abis:
+        supported.append(('%s%s' % (impl, versions[0]), abi, arch))
+            
+    # No abi / arch, but requires our implementation:
+    for i, version in enumerate(versions):
+        supported.append(('%s%s' % (impl, version), 'none', 'any'))
+        if i == 0:
+            # Tagged specifically as being cross-version compatible 
+            # (with just the major version specified)
+            supported.append(('%s%s' % (impl, versions[0][0]), 'none', 'any')) 
+            
+    # No abi / arch, generic Python
+    for i, version in enumerate(versions):
+        supported.append(('py%s' % (version,), 'none', 'any'))
+        if i == 0:
+            supported.append(('py%s' % (version[0]), 'none', 'any'))
+        
+    return supported
+
+
+[nosetests]
+where=.
+cover-package=pep425tags
+nocapture=1
+with-coverage=1
+cover-erase=1
+with-doctest=1
+
+[wheel]
+universal=1 # use py2.py3 tag for pure-python dist
+import os, sys, codecs
+
+from setuptools import setup
+
+here = os.path.abspath(os.path.dirname(__file__))
+README = codecs.open(os.path.join(here, 'README.txt'), encoding='utf8').read()
+CHANGES = codecs.open(os.path.join(here, 'CHANGES.txt'), encoding='utf8').read()
+
+setup(name='pep425tags',
+      version='0.0.0',
+      description='Reference implementation of PEP 425 compatibility tags.',
+      long_description=README + '\n\n' +  CHANGES,
+      classifiers=[
+        "Development Status :: 3 - Alpha",
+        "Intended Audience :: Developers",
+        "Programming Language :: Python",
+        "Programming Language :: Python :: 2",
+        "Programming Language :: Python :: 2.6",
+        "Programming Language :: Python :: 2.7",
+        "Programming Language :: Python :: 3",
+        "Programming Language :: Python :: 3.2",
+        "Programming Language :: Python :: 3.3",
+        ],
+      author='Daniel Holth',
+      author_email='dholth@fastmail.fm',
+      url='http://bitbucket.org/dholth/pep425/',
+      keywords='packaging',
+      license='MIT',
+      py_modules=['pep425tags'],
+      include_package_data=True,
+      zip_safe=False,
+      )
+