mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Test and validate vendoring update from-scratch
Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
Vendored
+15
-19
@@ -1,23 +1,19 @@
|
||||
Copyright (c) 2012 Vladimir Keleshev, <vladimir@keleshev.com>
|
||||
|
||||
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:
|
||||
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 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.
|
||||
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.
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2017 Matthias C. M. Troffaes
|
||||
Copyright (c) 2014 Matthias C. M. Troffaes
|
||||
Copyright (c) 2012-2014 Antoine Pitrou and contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
||||
+33
-19
@@ -3,7 +3,8 @@
|
||||
# Taken from pip
|
||||
# see https://github.com/pypa/pip/blob/95bcf8c5f6394298035a7332c441868f3b0169f4/tasks/vendoring/__init__.py
|
||||
from pathlib import Path
|
||||
from pipenv.utils import TemporaryDirectory, mkdir_p
|
||||
# from pipenv.utils import TemporaryDirectory, mkdir_p
|
||||
from tempfile import TemporaryDirectory
|
||||
import tarfile
|
||||
import zipfile
|
||||
import os
|
||||
@@ -47,7 +48,8 @@ FILE_WHITE_LIST = (
|
||||
'README.rst',
|
||||
'README.md',
|
||||
'appdirs.py',
|
||||
'safety.zip'
|
||||
'safety.zip',
|
||||
'cacert.pem'
|
||||
)
|
||||
|
||||
LIBRARY_RENAMES = {
|
||||
@@ -257,15 +259,9 @@ def get_patched(ctx):
|
||||
# Special cases: apply stored patches
|
||||
log("Apply patches")
|
||||
patch_dir = Path(__file__).parent / 'patches'
|
||||
current_dir = os.path.abspath(os.curdir)
|
||||
os.chdir(str(patched_dir))
|
||||
git_root = ctx.run('git rev-parse --show-toplevel', hide=True).stdout.strip()
|
||||
os.chdir(git_root)
|
||||
try:
|
||||
for patch in patch_dir.glob('*.patch'):
|
||||
for patch in patch_dir.glob('*.patch'):
|
||||
if not patch.name.startswith('_post'):
|
||||
apply_patch(ctx, patch)
|
||||
finally:
|
||||
os.chdir(current_dir)
|
||||
|
||||
# Global import rewrites
|
||||
# log("Rewriting all imports related to vendored libs")
|
||||
@@ -285,6 +281,11 @@ def get_patched(ctx):
|
||||
backport_init.write_text('\n'.join(init_content) + '\n')
|
||||
# elif item.name not in FILE_WHITE_LIST:
|
||||
# rewrite_file_imports(item, vendored_libs)
|
||||
log('Applying post-vendor patches...')
|
||||
for patch in patch_dir.glob('_post*.patch'):
|
||||
if not patch.name.startswith('_post-pip-tools'):
|
||||
apply_patch(ctx, patch)
|
||||
drop_dir(patched_dir / 'piptools' / '_vendored')
|
||||
|
||||
|
||||
def vendor(ctx, vendor_dir):
|
||||
@@ -316,23 +317,36 @@ def vendor(ctx, vendor_dir):
|
||||
rewrite_imports(item, vendored_libs, vendor_dir)
|
||||
if item.name in LIBRARY_RENAMES:
|
||||
new_path = item.parent / LIBRARY_RENAMES[item.name]
|
||||
item.rename(str(new_path))
|
||||
log('Renaming %s => %s' % (item.name, new_path))
|
||||
try:
|
||||
item.rename(str(new_path))
|
||||
except OSError:
|
||||
for child in item.iterdir():
|
||||
child.rename(str(new_path / child.name))
|
||||
elif item.name in LIBRARY_OVERRIDES:
|
||||
new_path = item.parent / LIBRARY_OVERRIDES[item.name]
|
||||
item.rename(str(new_path))
|
||||
log('Renaming %s => %s' % (item.name, new_path))
|
||||
try:
|
||||
item.rename(str(new_path))
|
||||
except OSError:
|
||||
for child in item.iterdir():
|
||||
child.rename(str(new_path / child.name))
|
||||
if item.name == 'backports':
|
||||
backport_init = item / '__init__.py'
|
||||
backport_libs = detect_vendored_libs(item)
|
||||
init_content = backport_init.read_text().splitlines()
|
||||
init_py_lines = backport_init.read_text().splitlines()
|
||||
for lib in backport_libs:
|
||||
init_content.append('from . import {0}'.format(lib))
|
||||
backport_init.write_text('\n'.join(init_content) + '\n')
|
||||
lib_line = 'from . import {0}'.format(lib)
|
||||
if lib_line not in init_py_lines:
|
||||
log('Adding backport %s to __init__.py exports' % lib)
|
||||
init_py_lines.append(lib_line)
|
||||
backport_init.write_text('\n'.join(init_py_lines) + '\n')
|
||||
elif item.name not in FILE_WHITE_LIST:
|
||||
rewrite_file_imports(item, vendored_libs, vendor_dir)
|
||||
log('Applying patches...')
|
||||
patch_dir = Path(__file__).parent / 'patches' / 'vendor'
|
||||
for patch in patch_dir.glob('*.patch'):
|
||||
apply_patch(ctx, patch)
|
||||
log('Applying patches...')
|
||||
patch_dir = Path(__file__).parent / 'patches' / 'vendor'
|
||||
for patch in patch_dir.glob('*.patch'):
|
||||
apply_patch(ctx, patch)
|
||||
|
||||
|
||||
@invoke.task
|
||||
|
||||
Reference in New Issue
Block a user