Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve PEP 518 build isolation #5824

Merged
merged 1 commit into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/html/reference/pip.rst
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ appropriately.
does not support the use of environment markers and extras (only version
specifiers are respected).

* ``pip<18.1``: build dependencies using .pth files are not properly supported;
as a result namespace packages do not work under Python 3.2 and earlier.

Future Developments
~~~~~~~~~~~~~~~~~~~
Expand Down
1 change: 1 addition & 0 deletions news/5656.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Improve PEP 518 build isolation: handle .pth files, so namespace packages are correctly supported under Python 3.2 and earlier.
10 changes: 10 additions & 0 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import logging
import os
import sys
import textwrap
from distutils.sysconfig import get_python_lib
from sysconfig import get_paths

Expand Down Expand Up @@ -61,6 +62,15 @@ def __enter__(self):

os.environ['PYTHONNOUSERSITE'] = '1'

# Ensure .pth files are honored.
with open(os.path.join(purelib, 'sitecustomize.py'), 'w') as fp:
fp.write(textwrap.dedent(
'''
import site
site.addsitedir({!r})
'''
).format(purelib))

return self.path

def __exit__(self, exc_type, exc_val, exc_tb):
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools",
"wheel",
"simple_namespace",
]
2 changes: 2 additions & 0 deletions tests/data/src/pep518_with_namespace_package-1.0/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal=1
10 changes: 10 additions & 0 deletions tests/data/src/pep518_with_namespace_package-1.0/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from setuptools import setup

import simple_namespace.module


setup(
name='pep518_with_namespace_package',
version='1.0',
py_modules=['pep518_with_namespace_package'],
)
2 changes: 2 additions & 0 deletions tests/data/src/simple_namespace/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
universal=1
9 changes: 9 additions & 0 deletions tests/data/src/simple_namespace/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from setuptools import setup


setup(
name='simple_namespace',
version='1.0',
namespace_packages=['simple_namespace'],
packages=['simple_namespace.module'],
)
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ def test_pep518_with_extra_and_markers(script, data, common_wheels):
)


def test_pep518_with_namespace_package(script, data, common_wheels):
script.pip(
'wheel', '--no-index',
'-f', common_wheels,
'-f', data.find_links,
data.src.join("pep518_with_namespace_package-1.0"),
use_module=True,
)


@pytest.mark.timeout(60)
@pytest.mark.parametrize('command', ('install', 'wheel'))
@pytest.mark.parametrize('package', ('pep518_forkbomb',
Expand Down