mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
This commit is contained in:
parent
3baacaacf3
commit
fa7aeb6cc8
1
news/4092.bugfix
Normal file
1
news/4092.bugfix
Normal file
|
@ -0,0 +1 @@
|
|||
Fixes destination directory of data_files when ``pip install --target`` is used.
|
|
@ -313,14 +313,21 @@ class InstallCommand(RequirementCommand):
|
|||
|
||||
purelib_dir = distutils_scheme('', home=temp_target_dir)['purelib']
|
||||
platlib_dir = distutils_scheme('', home=temp_target_dir)['platlib']
|
||||
data_dir = distutils_scheme('', home=temp_target_dir)['data']
|
||||
|
||||
if os.path.exists(purelib_dir):
|
||||
lib_dir_list.append(purelib_dir)
|
||||
if os.path.exists(platlib_dir) and platlib_dir != purelib_dir:
|
||||
lib_dir_list.append(platlib_dir)
|
||||
if os.path.exists(data_dir):
|
||||
lib_dir_list.append(data_dir)
|
||||
|
||||
for lib_dir in lib_dir_list:
|
||||
for item in os.listdir(lib_dir):
|
||||
if lib_dir == data_dir:
|
||||
ddir = os.path.join(data_dir, item)
|
||||
if any(s.startswith(ddir) for s in lib_dir_list[:-1]):
|
||||
continue
|
||||
target_item_dir = os.path.join(options.target_dir, item)
|
||||
if os.path.exists(target_item_dir):
|
||||
if not options.upgrade:
|
||||
|
|
BIN
tests/data/packages/prjwithdatafile-1.0-py2.py3-none-any.whl
Normal file
BIN
tests/data/packages/prjwithdatafile-1.0-py2.py3-none-any.whl
Normal file
Binary file not shown.
4
tests/data/src/prjwithdatafile/prjwithdatafile/README.txt
Executable file
4
tests/data/src/prjwithdatafile/prjwithdatafile/README.txt
Executable file
|
@ -0,0 +1,4 @@
|
|||
README
|
||||
======
|
||||
|
||||
Test project file
|
0
tests/data/src/prjwithdatafile/prjwithdatafile/somemodule.py
Executable file
0
tests/data/src/prjwithdatafile/prjwithdatafile/somemodule.py
Executable file
12
tests/data/src/prjwithdatafile/setup.py
Executable file
12
tests/data/src/prjwithdatafile/setup.py
Executable file
|
@ -0,0 +1,12 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='prjwithdatafile',
|
||||
version="1.0",
|
||||
packages=['prjwithdatafile'],
|
||||
data_files=[
|
||||
(r'packages1', ['prjwithdatafile/README.txt']),
|
||||
(r'packages2', ['prjwithdatafile/README.txt'])
|
||||
]
|
||||
)
|
|
@ -129,6 +129,42 @@ def test_install_wheel_with_target(script, data):
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.network
|
||||
def test_install_wheel_with_target_and_data_files(script, data):
|
||||
"""
|
||||
Test for issue #4092. It will be checked that a data_files specification in
|
||||
setup.py is handled correctly when a wheel is installed with the --target
|
||||
option.
|
||||
|
||||
The setup() for the wheel 'prjwithdatafile-1.0-py2.py3-none-any.whl' is as
|
||||
follows ::
|
||||
|
||||
setup(
|
||||
name='prjwithdatafile',
|
||||
version='1.0',
|
||||
packages=['prjwithdatafile'],
|
||||
data_files=[
|
||||
(r'packages1', ['prjwithdatafile/README.txt']),
|
||||
(r'packages2', ['prjwithdatafile/README.txt'])
|
||||
]
|
||||
)
|
||||
"""
|
||||
script.pip('install', 'wheel')
|
||||
target_dir = script.scratch_path / 'prjwithdatafile'
|
||||
package = data.packages.join("prjwithdatafile-1.0-py2.py3-none-any.whl")
|
||||
result = script.pip('install', package,
|
||||
'-t', target_dir,
|
||||
'--no-index',
|
||||
expect_error=False)
|
||||
|
||||
assert (Path('scratch') / 'prjwithdatafile' / 'packages1' / 'README.txt'
|
||||
in result.files_created), str(result)
|
||||
assert (Path('scratch') / 'prjwithdatafile' / 'packages2' / 'README.txt'
|
||||
in result.files_created), str(result)
|
||||
assert (Path('scratch') / 'prjwithdatafile' / 'lib' / 'python'
|
||||
not in result.files_created), str(result)
|
||||
|
||||
|
||||
def test_install_wheel_with_root(script, data):
|
||||
"""
|
||||
Test installing a wheel using pip install --root
|
||||
|
|
Loading…
Reference in a new issue