Skip to content

Commit a9d56c7

Browse files
authored
Merge pull request #4700 from dstufft/make-internal
2 parents c58a4cc + 8860dc0 commit a9d56c7

File tree

343 files changed

+593
-591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+593
-591
lines changed

.landscape.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
ignore-paths:
2-
- pip/_vendor/
2+
- src/pip/_vendor/

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ matrix:
1818
python: 2.7
1919
- env: TOXENV=py36
2020
python: 3.6
21-
# Unvendored
22-
- env: "TOXENV=py27 VENDOR=no WHEELS=yes"
23-
python: 2.7
24-
- env: "TOXENV=py36 VENDOR=no WHEELS=yes"
25-
python: 3.6
2621
# All the other Py3 versions
2722
- env: TOXENV=py33
2823
python: 3.3

.travis/run.sh

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,6 @@
22
set -e
33
set -x
44

5-
# We want to create the virtual environment here, but not actually run anything
6-
tox --notest
7-
8-
# If we have a VENDOR=no then we want to reinstall pip into the virtual
9-
# environment without the vendor directory included as well as install the
10-
# dependencies we need installed.
11-
if [[ $VENDOR = "no" ]]; then
12-
# Install our dependencies if we're not installing from wheels
13-
if [[ $WHEELS != "yes" ]]; then
14-
.tox/$TOXENV/bin/pip install -r pip/_vendor/vendor.txt --no-deps
15-
fi
16-
17-
# Install our dependencies if we're installing from wheels
18-
if [[ $WHEELS = "yes" ]]; then
19-
mkdir -p /tmp/wheels
20-
pip wheel --wheel-dir /tmp/wheels --no-deps -r pip/_vendor/vendor.txt
21-
cp /tmp/wheels/* `echo .tox/$TOXENV/lib/python*/site-packages/pip/_vendor/`
22-
fi
23-
24-
# Remove the vendored dependencies from within the installed pip inside of
25-
# our installed copy of pip.
26-
find .tox/$TOXENV/lib/python*/site-packages/pip/_vendor -d \
27-
-not -regex '.*/pip/_vendor/__init__\.py$' \
28-
-not -regex '.*/pip/_vendor$' \
29-
-exec rm -rf {} \;
30-
31-
# Patch our installed pip/_vendor/__init__.py so that it knows to look for
32-
# the vendored dependencies instead of only looking for the vendored.
33-
sed -i 's/DEBUNDLED = False/DEBUNDLED = True/' \
34-
.tox/$TOXENV/lib/python*/site-packages/pip/_vendor/__init__.py
35-
36-
# Test to make sure that we successfully installed without vendoring
37-
if [ -f .tox/$TOXENV/lib/python*/site-packages/pip/_vendor/six.py ]; then
38-
echo "Did not successfully unvendor"
39-
exit 1
40-
fi
41-
fi
42-
435
if [[ $TOXENV == py* ]]; then
446
# Run unit tests
457
tox -- -m unit

MANIFEST.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ include LICENSE.txt
33
include NEWS.rst
44
include README.rst
55
include pyproject.toml
6-
include pip/_vendor/README.rst
7-
include pip/_vendor/vendor.txt
6+
include src/pip/_vendor/README.rst
7+
include src/pip/_vendor/vendor.txt
88

99
exclude .coveragerc
1010
exclude .mailmap
1111
exclude .travis.yml
1212
exclude .landscape.yml
13-
exclude pip/_vendor/Makefile
13+
exclude src/pip/_vendor/Makefile
1414
exclude tox.ini
1515
exclude dev-requirements.txt
1616
exclude appveyor.yml
1717

18-
recursive-include pip/_vendor *.pem
18+
recursive-include src/pip/_vendor *.pem
1919
recursive-include docs Makefile *.rst *.py *.bat
2020

2121
prune .github

docs/pipext.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from docutils.parsers import rst
77
from docutils.statemachine import ViewList
88
from textwrap import dedent
9-
from pip.commands import commands_dict as commands
10-
from pip import cmdoptions
11-
from pip.utils import get_prog
9+
from pip._internal import cmdoptions
10+
from pip._internal.commands import commands_dict as commands
11+
from pip._internal.utils.misc import get_prog
1212

1313

1414
class PipCommandUsage(rst.Directive):

news/4696.removal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Move all of pip's APIs into the pip._internal package, properly reflecting the
2+
fact that pip does not currently have any public APIs.

news/4700.removal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Move all of pip's APIs into the pip._internal package, properly reflecting the
2+
fact that pip does not currently have any public APIs.

pip/models/__init__.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude = .tox,.idea,*.egg,build,_vendor,data
1515
select = E,W,F
1616

1717
[tool:pytest]
18-
addopts = --ignore pip/_vendor --ignore tests/tests_cache
18+
addopts = --ignore src/pip/_vendor --ignore tests/tests_cache
1919

2020
[bdist_wheel]
2121
universal=1

setup.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def find_version(*file_paths):
3838

3939
setup(
4040
name="pip",
41-
version=find_version("pip", "__init__.py"),
41+
version=find_version("src", "pip", "__init__.py"),
4242
description="The PyPA recommended tool for installing Python packages.",
4343
long_description=long_description,
4444
classifiers=[
@@ -60,7 +60,11 @@ def find_version(*file_paths):
6060
author_email='[email protected]',
6161
url='https://pip.pypa.io/',
6262
license='MIT',
63-
packages=find_packages(exclude=["contrib", "docs", "tests*", "tasks"]),
63+
package_dir={"": "src"},
64+
packages=find_packages(
65+
where="src",
66+
exclude=["contrib", "docs", "tests*", "tasks"],
67+
),
6468
package_data={
6569
"pip._vendor.certifi": ["*.pem"],
6670
"pip._vendor.requests": ["*.pem"],
@@ -69,9 +73,9 @@ def find_version(*file_paths):
6973
},
7074
entry_points={
7175
"console_scripts": [
72-
"pip=pip:main",
73-
"pip%s=pip:main" % sys.version[:1],
74-
"pip%s=pip:main" % sys.version[:3],
76+
"pip=pip._internal:main",
77+
"pip%s=pip._internal:main" % sys.version[:1],
78+
"pip%s=pip._internal:main" % sys.version[:3],
7579
],
7680
},
7781
tests_require=tests_require,

src/pip/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "10.0.0.dev0"

pip/__main__.py renamed to src/pip/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
path = os.path.dirname(os.path.dirname(__file__))
1414
sys.path.insert(0, path)
1515

16-
import pip # noqa
16+
from pip._internal import main as _main # noqa
1717

1818
if __name__ == '__main__':
19-
sys.exit(pip.main())
19+
sys.exit(_main())

pip/__init__.py renamed to src/pip/_internal/__init__.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@
4040
else:
4141
securetransport.inject_into_urllib3()
4242

43-
from pip.exceptions import CommandError, PipError
44-
from pip.utils import get_installed_distributions, get_prog
45-
from pip.utils import deprecation
46-
from pip.vcs import git, mercurial, subversion, bazaar # noqa
47-
from pip.baseparser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
48-
from pip.commands import get_summaries, get_similar_commands
49-
from pip.commands import commands_dict
43+
from pip import __version__
44+
from pip._internal import cmdoptions
45+
from pip._internal.exceptions import CommandError, PipError
46+
from pip._internal.utils.misc import get_installed_distributions, get_prog
47+
from pip._internal.utils import deprecation
48+
from pip._internal.vcs import git, mercurial, subversion, bazaar # noqa
49+
from pip._internal.baseparser import (
50+
ConfigOptionParser, UpdatingDefaultsHelpFormatter,
51+
)
52+
from pip._internal.commands import get_summaries, get_similar_commands
53+
from pip._internal.commands import commands_dict
5054
from pip._vendor.requests.packages.urllib3.exceptions import (
5155
InsecureRequestWarning,
5256
)
@@ -57,12 +61,8 @@
5761
# This fixes a peculiarity when importing via __import__ - as we are
5862
# initialising the pip module, "from pip import cmdoptions" is recursive
5963
# and appears not to work properly in that situation.
60-
import pip.cmdoptions
61-
cmdoptions = pip.cmdoptions
62-
63-
# The version as used in the setup.py and the docs conf.py
64-
__version__ = "10.0.0.dev0"
65-
64+
# import pip._internal.cmdoptions
65+
# cmdoptions = pip._internal.cmdoptions
6666

6767
logger = logging.getLogger(__name__)
6868

@@ -249,7 +249,3 @@ def main(args=None):
249249
logger.debug("Ignoring error %s when setting locale", e)
250250
command = commands_dict[cmd_name](isolated=check_isolated(cmd_args))
251251
return command.main(cmd_args)
252-
253-
254-
if __name__ == '__main__':
255-
sys.exit(main())

pip/basecommand.py renamed to src/pip/_internal/basecommand.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,27 @@
88
import sys
99
import warnings
1010

11-
from pip import cmdoptions
12-
from pip.baseparser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
13-
from pip.compat import WINDOWS
14-
from pip.download import PipSession
15-
from pip.exceptions import (
11+
from pip._internal import cmdoptions
12+
from pip._internal.baseparser import (
13+
ConfigOptionParser, UpdatingDefaultsHelpFormatter
14+
)
15+
from pip._internal.compat import WINDOWS
16+
from pip._internal.download import PipSession
17+
from pip._internal.exceptions import (
1618
BadCommand, CommandError, InstallationError, PreviousBuildDirError,
1719
UninstallationError
1820
)
19-
from pip.index import PackageFinder
20-
from pip.locations import running_under_virtualenv
21-
from pip.req import InstallRequirement, parse_requirements
22-
from pip.status_codes import (
21+
from pip._internal.index import PackageFinder
22+
from pip._internal.locations import running_under_virtualenv
23+
from pip._internal.req import InstallRequirement, parse_requirements
24+
from pip._internal.status_codes import (
2325
ERROR, PREVIOUS_BUILD_DIR_ERROR, SUCCESS, UNKNOWN_ERROR,
2426
VIRTUALENV_NOT_FOUND
2527
)
26-
from pip.utils import deprecation, get_prog, normalize_path
27-
from pip.utils.logging import IndentingFormatter
28-
from pip.utils.outdated import pip_version_check
28+
from pip._internal.utils import deprecation
29+
from pip._internal.utils.logging import IndentingFormatter
30+
from pip._internal.utils.misc import get_prog, normalize_path
31+
from pip._internal.utils.outdated import pip_version_check
2932

3033
__all__ = ['Command']
3134

@@ -130,7 +133,7 @@ def main(self, args):
130133
"disable_existing_loggers": False,
131134
"filters": {
132135
"exclude_warnings": {
133-
"()": "pip.utils.logging.MaxLevelFilter",
136+
"()": "pip._internal.utils.logging.MaxLevelFilter",
134137
"level": logging.WARNING,
135138
},
136139
},
@@ -143,20 +146,24 @@ def main(self, args):
143146
"handlers": {
144147
"console": {
145148
"level": level,
146-
"class": "pip.utils.logging.ColorizedStreamHandler",
149+
"class":
150+
"pip._internal.utils.logging.ColorizedStreamHandler",
147151
"stream": self.log_streams[0],
148152
"filters": ["exclude_warnings"],
149153
"formatter": "indent",
150154
},
151155
"console_errors": {
152156
"level": "WARNING",
153-
"class": "pip.utils.logging.ColorizedStreamHandler",
157+
"class":
158+
"pip._internal.utils.logging.ColorizedStreamHandler",
154159
"stream": self.log_streams[1],
155160
"formatter": "indent",
156161
},
157162
"user_log": {
158163
"level": "DEBUG",
159-
"class": "pip.utils.logging.BetterRotatingFileHandler",
164+
"class":
165+
("pip._internal.utils.logging"
166+
".BetterRotatingFileHandler"),
160167
"filename": options.log or "/dev/null",
161168
"delay": True,
162169
"formatter": "indent",

pip/baseparser.py renamed to src/pip/_internal/baseparser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
from pip._vendor.six import string_types
1111

12-
from pip.configuration import Configuration
13-
from pip.utils import get_terminal_size
12+
from pip._internal.configuration import Configuration
13+
from pip._internal.utils.misc import get_terminal_size
1414

1515
logger = logging.getLogger(__name__)
1616

pip/cache.py renamed to src/pip/_internal/cache.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
from pip._vendor.packaging.utils import canonicalize_name
1010

11-
import pip.index
12-
from pip.compat import expanduser
13-
from pip.download import path_to_url
14-
from pip.wheel import InvalidWheelFilename, Wheel
11+
from pip._internal import index
12+
from pip._internal.compat import expanduser
13+
from pip._internal.download import path_to_url
14+
from pip._internal.wheel import InvalidWheelFilename, Wheel
1515

1616
logger = logging.getLogger(__name__)
1717

@@ -71,7 +71,7 @@ def _get_candidates(self, link, package_name):
7171
return []
7272

7373
canonical_name = canonicalize_name(package_name)
74-
formats = pip.index.fmt_ctl_formats(
74+
formats = index.fmt_ctl_formats(
7575
self.format_control, canonical_name
7676
)
7777
if not self.allowed_formats.intersection(formats):
@@ -100,7 +100,7 @@ def _link_for_candidate(self, link, candidate):
100100
root = self.get_path_for_link(link)
101101
path = os.path.join(root, candidate)
102102

103-
return pip.index.Link(path_to_url(path))
103+
return index.Link(path_to_url(path))
104104

105105

106106
class WheelCache(Cache):

pip/cmdoptions.py renamed to src/pip/_internal/cmdoptions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
from functools import partial
1414
from optparse import SUPPRESS_HELP, Option, OptionGroup
1515

16-
from pip.index import (
16+
from pip._internal.index import (
1717
FormatControl, fmt_ctl_handle_mutual_exclude, fmt_ctl_no_binary
1818
)
19-
from pip.locations import USER_CACHE_DIR, src_prefix
20-
from pip.models import PyPI
21-
from pip.utils.hashes import STRONG_HASHES
22-
from pip.utils.ui import BAR_TYPES
19+
from pip._internal.locations import USER_CACHE_DIR, src_prefix
20+
from pip._internal.models import PyPI
21+
from pip._internal.utils.hashes import STRONG_HASHES
22+
from pip._internal.utils.ui import BAR_TYPES
2323

2424

2525
def make_option_group(group, parser):

pip/commands/__init__.py renamed to src/pip/_internal/commands/__init__.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
"""
44
from __future__ import absolute_import
55

6-
from pip.commands.completion import CompletionCommand
7-
from pip.commands.configuration import ConfigurationCommand
8-
from pip.commands.download import DownloadCommand
9-
from pip.commands.freeze import FreezeCommand
10-
from pip.commands.hash import HashCommand
11-
from pip.commands.help import HelpCommand
12-
from pip.commands.list import ListCommand
13-
from pip.commands.check import CheckCommand
14-
from pip.commands.search import SearchCommand
15-
from pip.commands.show import ShowCommand
16-
from pip.commands.install import InstallCommand
17-
from pip.commands.uninstall import UninstallCommand
18-
from pip.commands.wheel import WheelCommand
6+
from pip._internal.commands.completion import CompletionCommand
7+
from pip._internal.commands.configuration import ConfigurationCommand
8+
from pip._internal.commands.download import DownloadCommand
9+
from pip._internal.commands.freeze import FreezeCommand
10+
from pip._internal.commands.hash import HashCommand
11+
from pip._internal.commands.help import HelpCommand
12+
from pip._internal.commands.list import ListCommand
13+
from pip._internal.commands.check import CheckCommand
14+
from pip._internal.commands.search import SearchCommand
15+
from pip._internal.commands.show import ShowCommand
16+
from pip._internal.commands.install import InstallCommand
17+
from pip._internal.commands.uninstall import UninstallCommand
18+
from pip._internal.commands.wheel import WheelCommand
1919

2020
commands_order = [
2121
InstallCommand,

pip/commands/check.py renamed to src/pip/_internal/commands/check.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22

3-
from pip.basecommand import Command
4-
from pip.operations.check import check_requirements
5-
from pip.utils import get_installed_distributions
3+
from pip._internal.basecommand import Command
4+
from pip._internal.operations.check import check_requirements
5+
from pip._internal.utils.misc import get_installed_distributions
66

77
logger = logging.getLogger(__name__)
88

0 commit comments

Comments
 (0)