Loading CHANGELOG.md +7 −0 Changes for CHANGELOG.md: 7 added lines, 0 removed lines. Original line number Diff line number Diff line # Change Log [Unreleased] ### Fixed - Fixed built wheels not getting information from the virtualenv. [0.6.2] - 2018-03-19 ### Changed Loading poetry/masonry/builders/sdist.py +1 −1 Changes for poetry/masonry/builders/sdist.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ from pprint import pformat from typing import List from poetry.packages import Dependency from poetry.version.helpers import format_python_constraint from ..utils.helpers import normalize_file_permissions Loading @@ -19,6 +18,7 @@ from .builder import Builder SETUP = """\ # -*- coding: utf-8 -*- from distutils.core import setup {before} Loading poetry/masonry/builders/wheel.py +3 −3 Changes for poetry/masonry/builders/wheel.py: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -203,10 +203,10 @@ class WheelBuilder(Builder): def tag(self): if self._package.build: platform = get_platform().replace('.', '_').replace('-', '_') impl_name = get_abbr_impl() impl_ver = get_impl_ver() impl_name = get_abbr_impl(self._venv) impl_ver = get_impl_ver(self._venv) impl = impl_name + impl_ver abi_tag = str(get_abi_tag()).lower() abi_tag = str(get_abi_tag(self._venv)).lower() tag = (impl, abi_tag, platform) else: platform = 'any' Loading poetry/masonry/utils/tags.py +30 −36 Changes for poetry/masonry/utils/tags.py: 30 added lines, 36 removed lines. Original line number Diff line number Diff line """Generate and work with PEP 425 Compatibility Tags.""" import distutils.util import platform import sys import sysconfig import warnings def get_config_var(var): try: return sysconfig.get_config_var(var) except IOError as e: warnings.warn("{0}".format(e), RuntimeWarning) return None def get_abbr_impl(): def get_abbr_impl(venv): """Return abbreviated implementation name.""" impl = platform.python_implementation() impl = venv.python_implementation if impl == 'PyPy': return 'pp' elif impl == 'Jython': Loading @@ -30,29 +21,29 @@ def get_abbr_impl(): raise LookupError('Unknown Python implementation: ' + impl) def get_impl_ver(): def get_impl_ver(venv): """Return implementation version.""" impl_ver = get_config_var("py_version_nodot") if not impl_ver or get_abbr_impl() == 'pp': impl_ver = ''.join(map(str, get_impl_version_info())) impl_ver = venv.config_var("py_version_nodot") if not impl_ver or get_abbr_impl(venv) == 'pp': impl_ver = ''.join(map(str, get_impl_version_info(venv))) return impl_ver def get_impl_version_info(): def get_impl_version_info(venv): """Return sys.version_info-like tuple for use in decrementing the minor version.""" if get_abbr_impl() == 'pp': if get_abbr_impl(venv) == 'pp': # as per https://github.com/pypa/pip/issues/2882 return (sys.version_info[0], sys.pypy_version_info.major, sys.pypy_version_info.minor) return venv.version_info[:3] else: return sys.version_info[0], sys.version_info[1] return venv.version_info[:2] def get_flag(var, fallback, expected=True, warn=True): def get_flag(venv, var, fallback, expected=True, warn=True): """Use a fallback method for determining SOABI flags if the needed config var is unset or unavailable.""" val = get_config_var(var) val = venv.config_var(var) if val is None: if warn: warnings.warn("Config variable '{0}' is unset, Python ABI tag may " Loading @@ -61,31 +52,34 @@ def get_flag(var, fallback, expected=True, warn=True): return val == expected def get_abi_tag(): def get_abi_tag(venv): """Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).""" soabi = get_config_var('SOABI') impl = get_abbr_impl() soabi = venv.config_var('SOABI') impl = get_abbr_impl(venv) if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'): d = '' m = '' u = '' if get_flag('Py_DEBUG', if get_flag(venv, 'Py_DEBUG', lambda: hasattr(sys, 'gettotalrefcount'), warn=(impl == 'cp')): d = 'd' if get_flag('WITH_PYMALLOC', if get_flag(venv, 'WITH_PYMALLOC', lambda: impl == 'cp', warn=(impl == 'cp')): m = 'm' if get_flag('Py_UNICODE_SIZE', if get_flag(venv, 'Py_UNICODE_SIZE', lambda: sys.maxunicode == 0x10ffff, expected=4, warn=(impl == 'cp' and sys.version_info < (3, 3))) \ and sys.version_info < (3, 3): venv.version_info < (3, 3))) \ and venv.version_info < (3, 3): u = 'u' abi = '%s%s%s%s%s' % (impl, get_impl_ver(), d, m, u) abi = '%s%s%s%s%s' % (impl, get_impl_ver(venv), d, m, u) elif soabi and soabi.startswith('cpython-'): abi = 'cp' + soabi.split('-')[1] elif soabi: Loading @@ -105,7 +99,7 @@ def get_platform(): return result def get_supported(versions=None, supplied_platform=None): def get_supported(venv, versions=None, supplied_platform=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"], Loading @@ -116,17 +110,17 @@ def get_supported(versions=None, supplied_platform=None): # Versions must be given with respect to the preference if versions is None: versions = [] version_info = get_impl_version_info() version_info = get_impl_version_info(venv) major = version_info[:-1] # Support all previous minor Python versions. for minor in range(version_info[-1], -1, -1): versions.append(''.join(map(str, major + (minor,)))) impl = get_abbr_impl() impl = get_abbr_impl(venv) abis = [] abi = get_abi_tag() abi = get_abi_tag(venv) if abi: abis[0:0] = [abi] Loading poetry/utils/venv.py +58 −3 Changes for poetry/utils/venv.py: 58 added lines, 3 removed lines. Original line number Diff line number Diff line import os import platform import subprocess import sys import sysconfig import warnings from contextlib import contextmanager from pathlib import Path Loading Loading @@ -39,6 +42,7 @@ class Venv: self._bin_dir = self._venv / bin_dir self._version_info = None self._python_implementation = None @classmethod def create(cls, io, name=None) -> 'Venv': Loading Loading @@ -123,27 +127,78 @@ class Venv: return self._bin('pip') @property def version_info(self): def version_info(self) -> tuple: if self._version_info is not None: return self._version_info if not self.is_venv(): self._version_info = sys.version_info else: output = self.run('python', '--version') output = self.run('python', '--version', shell=True) version = output.split(' ') self._version_info = version[1].strip().split('.') self._version_info = tuple([ int(s) for s in version[1].strip().split('.') ]) return self._version_info @property def python_implementation(self): if self._python_implementation is not None: return self._python_implementation if not self.is_venv(): impl = platform.python_implementation() else: impl = self.run( 'python', '-c', '"import platform; print(platform.python_implementation())"', shell=True ).strip() self._python_implementation = impl return self._python_implementation def config_var(self, var): if not self.is_venv(): try: return sysconfig.get_config_var(var) except IOError as e: warnings.warn("{0}".format(e), RuntimeWarning) return None try: value = self.run( 'python', '-c', f'"import sysconfig; print(sysconfig.get_config_var(\'{var}\'))"', shell=True ).strip() except VenvCommandError as e: warnings.warn("{0}".format(e), RuntimeWarning) return None if value == 'None': value = None elif value == '1': value = 1 elif value == '0': value = 0 return value def run(self, bin: str, *args, **kwargs) -> str: """ Run a command inside the virtual env. """ cmd = [self._bin(bin)] + list(args) shell = kwargs.get('shell', False) try: if shell: cmd = ' '.join(cmd) output = subprocess.check_output( cmd, stderr=subprocess.STDOUT, **kwargs Loading Loading
CHANGELOG.md +7 −0 Changes for CHANGELOG.md: 7 added lines, 0 removed lines. Original line number Diff line number Diff line # Change Log [Unreleased] ### Fixed - Fixed built wheels not getting information from the virtualenv. [0.6.2] - 2018-03-19 ### Changed Loading
poetry/masonry/builders/sdist.py +1 −1 Changes for poetry/masonry/builders/sdist.py: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -11,7 +11,6 @@ from pprint import pformat from typing import List from poetry.packages import Dependency from poetry.version.helpers import format_python_constraint from ..utils.helpers import normalize_file_permissions Loading @@ -19,6 +18,7 @@ from .builder import Builder SETUP = """\ # -*- coding: utf-8 -*- from distutils.core import setup {before} Loading
poetry/masonry/builders/wheel.py +3 −3 Changes for poetry/masonry/builders/wheel.py: 3 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -203,10 +203,10 @@ class WheelBuilder(Builder): def tag(self): if self._package.build: platform = get_platform().replace('.', '_').replace('-', '_') impl_name = get_abbr_impl() impl_ver = get_impl_ver() impl_name = get_abbr_impl(self._venv) impl_ver = get_impl_ver(self._venv) impl = impl_name + impl_ver abi_tag = str(get_abi_tag()).lower() abi_tag = str(get_abi_tag(self._venv)).lower() tag = (impl, abi_tag, platform) else: platform = 'any' Loading
poetry/masonry/utils/tags.py +30 −36 Changes for poetry/masonry/utils/tags.py: 30 added lines, 36 removed lines. Original line number Diff line number Diff line """Generate and work with PEP 425 Compatibility Tags.""" import distutils.util import platform import sys import sysconfig import warnings def get_config_var(var): try: return sysconfig.get_config_var(var) except IOError as e: warnings.warn("{0}".format(e), RuntimeWarning) return None def get_abbr_impl(): def get_abbr_impl(venv): """Return abbreviated implementation name.""" impl = platform.python_implementation() impl = venv.python_implementation if impl == 'PyPy': return 'pp' elif impl == 'Jython': Loading @@ -30,29 +21,29 @@ def get_abbr_impl(): raise LookupError('Unknown Python implementation: ' + impl) def get_impl_ver(): def get_impl_ver(venv): """Return implementation version.""" impl_ver = get_config_var("py_version_nodot") if not impl_ver or get_abbr_impl() == 'pp': impl_ver = ''.join(map(str, get_impl_version_info())) impl_ver = venv.config_var("py_version_nodot") if not impl_ver or get_abbr_impl(venv) == 'pp': impl_ver = ''.join(map(str, get_impl_version_info(venv))) return impl_ver def get_impl_version_info(): def get_impl_version_info(venv): """Return sys.version_info-like tuple for use in decrementing the minor version.""" if get_abbr_impl() == 'pp': if get_abbr_impl(venv) == 'pp': # as per https://github.com/pypa/pip/issues/2882 return (sys.version_info[0], sys.pypy_version_info.major, sys.pypy_version_info.minor) return venv.version_info[:3] else: return sys.version_info[0], sys.version_info[1] return venv.version_info[:2] def get_flag(var, fallback, expected=True, warn=True): def get_flag(venv, var, fallback, expected=True, warn=True): """Use a fallback method for determining SOABI flags if the needed config var is unset or unavailable.""" val = get_config_var(var) val = venv.config_var(var) if val is None: if warn: warnings.warn("Config variable '{0}' is unset, Python ABI tag may " Loading @@ -61,31 +52,34 @@ def get_flag(var, fallback, expected=True, warn=True): return val == expected def get_abi_tag(): def get_abi_tag(venv): """Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).""" soabi = get_config_var('SOABI') impl = get_abbr_impl() soabi = venv.config_var('SOABI') impl = get_abbr_impl(venv) if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'): d = '' m = '' u = '' if get_flag('Py_DEBUG', if get_flag(venv, 'Py_DEBUG', lambda: hasattr(sys, 'gettotalrefcount'), warn=(impl == 'cp')): d = 'd' if get_flag('WITH_PYMALLOC', if get_flag(venv, 'WITH_PYMALLOC', lambda: impl == 'cp', warn=(impl == 'cp')): m = 'm' if get_flag('Py_UNICODE_SIZE', if get_flag(venv, 'Py_UNICODE_SIZE', lambda: sys.maxunicode == 0x10ffff, expected=4, warn=(impl == 'cp' and sys.version_info < (3, 3))) \ and sys.version_info < (3, 3): venv.version_info < (3, 3))) \ and venv.version_info < (3, 3): u = 'u' abi = '%s%s%s%s%s' % (impl, get_impl_ver(), d, m, u) abi = '%s%s%s%s%s' % (impl, get_impl_ver(venv), d, m, u) elif soabi and soabi.startswith('cpython-'): abi = 'cp' + soabi.split('-')[1] elif soabi: Loading @@ -105,7 +99,7 @@ def get_platform(): return result def get_supported(versions=None, supplied_platform=None): def get_supported(venv, versions=None, supplied_platform=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"], Loading @@ -116,17 +110,17 @@ def get_supported(versions=None, supplied_platform=None): # Versions must be given with respect to the preference if versions is None: versions = [] version_info = get_impl_version_info() version_info = get_impl_version_info(venv) major = version_info[:-1] # Support all previous minor Python versions. for minor in range(version_info[-1], -1, -1): versions.append(''.join(map(str, major + (minor,)))) impl = get_abbr_impl() impl = get_abbr_impl(venv) abis = [] abi = get_abi_tag() abi = get_abi_tag(venv) if abi: abis[0:0] = [abi] Loading
poetry/utils/venv.py +58 −3 Changes for poetry/utils/venv.py: 58 added lines, 3 removed lines. Original line number Diff line number Diff line import os import platform import subprocess import sys import sysconfig import warnings from contextlib import contextmanager from pathlib import Path Loading Loading @@ -39,6 +42,7 @@ class Venv: self._bin_dir = self._venv / bin_dir self._version_info = None self._python_implementation = None @classmethod def create(cls, io, name=None) -> 'Venv': Loading Loading @@ -123,27 +127,78 @@ class Venv: return self._bin('pip') @property def version_info(self): def version_info(self) -> tuple: if self._version_info is not None: return self._version_info if not self.is_venv(): self._version_info = sys.version_info else: output = self.run('python', '--version') output = self.run('python', '--version', shell=True) version = output.split(' ') self._version_info = version[1].strip().split('.') self._version_info = tuple([ int(s) for s in version[1].strip().split('.') ]) return self._version_info @property def python_implementation(self): if self._python_implementation is not None: return self._python_implementation if not self.is_venv(): impl = platform.python_implementation() else: impl = self.run( 'python', '-c', '"import platform; print(platform.python_implementation())"', shell=True ).strip() self._python_implementation = impl return self._python_implementation def config_var(self, var): if not self.is_venv(): try: return sysconfig.get_config_var(var) except IOError as e: warnings.warn("{0}".format(e), RuntimeWarning) return None try: value = self.run( 'python', '-c', f'"import sysconfig; print(sysconfig.get_config_var(\'{var}\'))"', shell=True ).strip() except VenvCommandError as e: warnings.warn("{0}".format(e), RuntimeWarning) return None if value == 'None': value = None elif value == '1': value = 1 elif value == '0': value = 0 return value def run(self, bin: str, *args, **kwargs) -> str: """ Run a command inside the virtual env. """ cmd = [self._bin(bin)] + list(args) shell = kwargs.get('shell', False) try: if shell: cmd = ' '.join(cmd) output = subprocess.check_output( cmd, stderr=subprocess.STDOUT, **kwargs Loading