Skip to content

Commit

Permalink
Prepare 0.13.0
Browse files Browse the repository at this point in the history
Vendorize latest virtualenv with cleanup fixes
Bump version to 0.13.0

fixes pybuilder#795, pybuilder#777, pybuilder#774, pybuilder#771
  • Loading branch information
arcivanov committed Sep 26, 2021
1 parent d8173a3 commit c61bec6
Show file tree
Hide file tree
Showing 35 changed files with 227 additions and 65 deletions.
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"Documentation": "https://pybuilder.io/documentation"
}
license = "Apache License, Version 2.0"
version = "0.13.0.dev"
version = "0.13.0"

requires_python = ">=3.6"

Expand Down
6 changes: 3 additions & 3 deletions src/main/python/pybuilder/_vendor/LICENSES
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ See the License for the specific language governing permissions and
limitations under the License.


setuptools-58.0.4
setuptools-58.1.0
==========
Copyright Jason R. Coombs

Expand Down Expand Up @@ -131,7 +131,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


virtualenv-20.8.0
virtualenv-20.8.1
==========
Copyright (c) 2020-202x The virtualenv developers

Expand Down Expand Up @@ -206,7 +206,7 @@ OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org>


platformdirs-2.3.0
platformdirs-2.4.0
==========
# This is the MIT license

Expand Down
2 changes: 1 addition & 1 deletion src/main/python/pybuilder/_vendor/distlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
import logging

__version__ = '0.3.2'
__version__ = '0.3.3'

class DistlibException(Exception):
pass
Expand Down
26 changes: 14 additions & 12 deletions src/main/python/pybuilder/_vendor/distlib/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@ def quote(s):
from itertools import ifilter as filter
from itertools import ifilterfalse as filterfalse

_userprog = None
def splituser(host):
"""splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
global _userprog
if _userprog is None:
import re
_userprog = re.compile('^(.*)@(.*)$')

match = _userprog.match(host)
if match: return match.group(1, 2)
return None, host
# Leaving this around for now, in case it needs resurrecting in some way
# _userprog = None
# def splituser(host):
# """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
# global _userprog
# if _userprog is None:
# import re
# _userprog = re.compile('^(.*)@(.*)$')

# match = _userprog.match(host)
# if match: return match.group(1, 2)
# return None, host

else: # pragma: no cover
from io import StringIO
Expand All @@ -68,7 +69,7 @@ def splituser(host):
import builtins
import configparser
import shutil
from urllib.parse import (urlparse, urlunparse, urljoin, splituser, quote,
from urllib.parse import (urlparse, urlunparse, urljoin, quote,
unquote, urlsplit, urlunsplit, splittype)
from urllib.request import (urlopen, urlretrieve, Request, url2pathname,
pathname2url,
Expand All @@ -88,6 +89,7 @@ def splituser(host):
from itertools import filterfalse
filter = filter


try:
from ssl import match_hostname, CertificateError
except ImportError: # pragma: no cover
Expand Down
17 changes: 17 additions & 0 deletions src/main/python/pybuilder/_vendor/distlib/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,29 @@
# as ~= and === which aren't in Python, necessitating a different approach.

import os
import re
import sys
import platform

from .compat import string_types
from .util import in_venv, parse_marker
from .version import NormalizedVersion as NV

__all__ = ['interpret']

_VERSION_PATTERN = re.compile(r'((\d+(\.\d+)*\w*)|\'(\d+(\.\d+)*\w*)\'|\"(\d+(\.\d+)*\w*)\")')

def _is_literal(o):
if not isinstance(o, string_types) or not o:
return False
return o[0] in '\'"'

def _get_versions(s):
result = []
for m in _VERSION_PATTERN.finditer(s):
result.append(NV(m.groups()[0]))
return set(result)

class Evaluator(object):
"""
This class is used to evaluate marker expessions.
Expand Down Expand Up @@ -70,6 +80,13 @@ def evaluate(self, expr, context):

lhs = self.evaluate(elhs, context)
rhs = self.evaluate(erhs, context)
if ((elhs == 'python_version' or erhs == 'python_version') and
op in ('<', '<=', '>', '>=', '===', '==', '!=', '~=')):
lhs = NV(lhs)
rhs = NV(rhs)
elif elhs == 'python_version' and op in ('in', 'not in'):
lhs = NV(lhs)
rhs = _get_versions(rhs)
result = self.operations[op](lhs, rhs)
return result

Expand Down
10 changes: 8 additions & 2 deletions src/main/python/pybuilder/_vendor/distlib/scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .compat import sysconfig, detect_encoding, ZipFile
from .resources import finder
from .util import (FileOperator, get_export_entry, convert_path,
get_executable, in_venv)
get_executable, get_platform, in_venv)

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -170,6 +170,11 @@ def _get_shebang(self, encoding, post_interp=b'', options=None):
sysconfig.get_config_var('BINDIR'),
'python%s%s' % (sysconfig.get_config_var('VERSION'),
sysconfig.get_config_var('EXE')))
if not os.path.isfile(executable):
# for Python builds from source on Windows, no Python executables with
# a version suffix are created, so we use python.exe
executable = os.path.join(sysconfig.get_config_var('BINDIR'),
'python%s' % (sysconfig.get_config_var('EXE')))
if options:
executable = self._get_alternate_executable(executable, options)

Expand Down Expand Up @@ -379,7 +384,8 @@ def _get_launcher(self, kind):
bits = '64'
else:
bits = '32'
name = '%s%s.exe' % (kind, bits)
platform_suffix = '-arm' if get_platform() == 'win-arm64' else ''
name = '%s%s%s.exe' % (kind, bits, platform_suffix)
# Issue 31: don't hardcode an absolute package name, but
# determine it relative to the current package
distlib_package = __name__.rsplit('.', 1)[0]
Expand Down
Binary file not shown.
4 changes: 4 additions & 0 deletions src/main/python/pybuilder/_vendor/distlib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ def get_versions(ver_remaining):
if not ver_remaining or ver_remaining[0] != ',':
break
ver_remaining = ver_remaining[1:].lstrip()
# Some packages have a trailing comma which would break things
# See issue #148
if not ver_remaining:
break
m = COMPARE_OP.match(ver_remaining)
if not m:
raise SyntaxError('invalid constraint: %s' % ver_remaining)
Expand Down
2 changes: 1 addition & 1 deletion src/main/python/pybuilder/_vendor/distlib/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _pep_440_key(s):
if not groups[0]:
epoch = 0
else:
epoch = int(groups[0])
epoch = int(groups[0][:-1])
pre = groups[4:6]
post = groups[7:9]
dev = groups[10:12]
Expand Down
Binary file not shown.
5 changes: 1 addition & 4 deletions src/main/python/pybuilder/_vendor/distlib/wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@

VER_SUFFIX = sysconfig.get_config_var('py_version_nodot')
if not VER_SUFFIX: # pragma: no cover
if sys.version_info[1] >= 10:
VER_SUFFIX = '%s_%s' % sys.version_info[:2] # PEP 641 (draft)
else:
VER_SUFFIX = '%s%s' % sys.version_info[:2]
VER_SUFFIX = '%s%s' % sys.version_info[:2]
PYVER = 'py' + VER_SUFFIX
IMPVER = IMP_PREFIX + VER_SUFFIX

Expand Down
16 changes: 16 additions & 0 deletions src/main/python/pybuilder/_vendor/platformdirs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ def user_log_dir(
return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_log_dir


def user_documents_dir() -> str:
"""
:returns: documents directory tied to the user
"""
return PlatformDirs().user_documents_dir


def user_runtime_dir(
appname: Optional[str] = None,
appauthor: Union[str, None, "Literal[False]"] = None,
Expand Down Expand Up @@ -272,6 +279,13 @@ def user_log_path(
return PlatformDirs(appname=appname, appauthor=appauthor, version=version, opinion=opinion).user_log_path


def user_documents_path() -> Path:
"""
:returns: documents path tied to the user
"""
return PlatformDirs().user_documents_path


def user_runtime_path(
appname: Optional[str] = None,
appauthor: Union[str, None, "Literal[False]"] = None,
Expand Down Expand Up @@ -299,6 +313,7 @@ def user_runtime_path(
"user_cache_dir",
"user_state_dir",
"user_log_dir",
"user_documents_dir",
"user_runtime_dir",
"site_data_dir",
"site_config_dir",
Expand All @@ -307,6 +322,7 @@ def user_runtime_path(
"user_cache_path",
"user_state_path",
"user_log_path",
"user_documents_path",
"user_runtime_path",
"site_data_path",
"site_config_path",
Expand Down
1 change: 1 addition & 0 deletions src/main/python/pybuilder/_vendor/platformdirs/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"user_cache_dir",
"user_state_dir",
"user_log_dir",
"user_documents_dir",
"user_runtime_dir",
"site_data_dir",
"site_config_dir",
Expand Down
23 changes: 23 additions & 0 deletions src/main/python/pybuilder/_vendor/platformdirs/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ def user_log_dir(self) -> str:
path = os.path.join(path, "log")
return path

@property
def user_documents_dir(self) -> str:
"""
:return: documents directory tied to the user e.g. ``/storage/emulated/0/Documents``
"""
return _android_documents_folder()

@property
def user_runtime_dir(self) -> str:
"""
Expand Down Expand Up @@ -89,6 +96,22 @@ def _android_folder() -> str:
return result


@lru_cache(maxsize=1)
def _android_documents_folder() -> str:
""":return: documents folder for the Android OS"""
# Get directories with pyjnius
try:
from jnius import autoclass # noqa: SC200

Context = autoclass("android.content.Context") # noqa: SC200
Environment = autoclass("android.os.Environment")
documents_dir: str = Context.getExternalFilesDir(Environment.DIRECTORY_DOCUMENTS).getAbsolutePath()
except Exception:
documents_dir = "/storage/emulated/0/Documents"

return documents_dir


__all__ = [
"Android",
]
10 changes: 10 additions & 0 deletions src/main/python/pybuilder/_vendor/platformdirs/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def user_state_dir(self) -> str:
def user_log_dir(self) -> str:
""":return: log directory tied to the user"""

@property
@abstractmethod
def user_documents_dir(self) -> str:
""":return: documents directory tied to the user"""

@property
@abstractmethod
def user_runtime_dir(self) -> str:
Expand Down Expand Up @@ -139,6 +144,11 @@ def user_log_path(self) -> Path:
""":return: log path tied to the user"""
return Path(self.user_log_dir)

@property
def user_documents_path(self) -> Path:
""":return: documents path tied to the user"""
return Path(self.user_documents_dir)

@property
def user_runtime_path(self) -> Path:
""":return: runtime path tied to the user"""
Expand Down
5 changes: 5 additions & 0 deletions src/main/python/pybuilder/_vendor/platformdirs/macos.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def user_log_dir(self) -> str:
""":return: log directory tied to the user, e.g. ``~/Library/Logs/$appname/$version``"""
return self._append_app_name_and_version(os.path.expanduser("~/Library/Logs"))

@property
def user_documents_dir(self) -> str:
""":return: documents directory tied to the user, e.g. ``~/Documents``"""
return os.path.expanduser("~/Documents")

@property
def user_runtime_dir(self) -> str:
""":return: runtime directory tied to the user, e.g. ``~/Library/Caches/TemporaryItems/$appname/$version``"""
Expand Down
36 changes: 36 additions & 0 deletions src/main/python/pybuilder/_vendor/platformdirs/unix.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import sys
from configparser import ConfigParser
from pathlib import Path
from typing import Optional

from .api import PlatformDirsABC

Expand Down Expand Up @@ -111,6 +113,19 @@ def user_log_dir(self) -> str:
path = os.path.join(path, "log")
return path

@property
def user_documents_dir(self) -> str:
"""
:return: documents directory tied to the user, e.g. ``~/Documents``
"""
documents_dir = _get_user_dirs_folder("XDG_DOCUMENTS_DIR")
if documents_dir is None:
documents_dir = os.environ.get("XDG_DOCUMENTS_DIR", "").strip()
if not documents_dir:
documents_dir = os.path.expanduser("~/Documents")

return documents_dir

@property
def user_runtime_dir(self) -> str:
"""
Expand Down Expand Up @@ -139,6 +154,27 @@ def _first_item_as_path_if_multipath(self, directory: str) -> Path:
return Path(directory)


def _get_user_dirs_folder(key: str) -> Optional[str]:
"""Return directory from user-dirs.dirs config file. See https://freedesktop.org/wiki/Software/xdg-user-dirs/"""
user_dirs_config_path = os.path.join(Unix().user_config_dir, "user-dirs.dirs")
if os.path.exists(user_dirs_config_path):
parser = ConfigParser()

with open(user_dirs_config_path) as stream:
# Add fake section header, so ConfigParser doesn't complain
parser.read_string(f"[top]\n{stream.read()}")

if key not in parser["top"]:
return None

path = parser["top"][key].strip('"')
# Handle relative home paths
path = path.replace("$HOME", os.path.expanduser("~"))
return path

return None


__all__ = [
"Unix",
]
4 changes: 2 additions & 2 deletions src/main/python/pybuilder/_vendor/platformdirs/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""" Version information """

__version__ = "2.3.0"
__version_info__ = (2, 3, 0)
__version__ = "2.4.0"
__version_info__ = (2, 4, 0)
Loading

0 comments on commit c61bec6

Please sign in to comment.