Skip to content

Commit

Permalink
Revert "Merge pull request #933 from pypa/feature/581-depend-not-bundle"
Browse files Browse the repository at this point in the history
This reverts commit 089cdeb, reversing
changes made to aaec654.
  • Loading branch information
jaraco committed Feb 24, 2017
1 parent 4c560ef commit 3d0cc35
Show file tree
Hide file tree
Showing 67 changed files with 9,044 additions and 135 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ setuptools.egg-info
*.swp
*~
.hg*
requirements.txt
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ matrix:
- python: 2.7
env: LC_ALL=C LC_CTYPE=C
script:
# need tox and rwt to get started
- pip install tox rwt
- pip install tox

# Output the env, to verify behavior
- env

# update egg_info based on setup.py in checkout
- python bootstrap.py

#- python -m tox
- tox

before_deploy:
Expand Down
47 changes: 2 additions & 45 deletions bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
egg-info command to flesh out the egg-info directory.
"""

from __future__ import unicode_literals

import os
import io
import re
import contextlib
import tempfile
import shutil
import sys
import textwrap
import subprocess
Expand Down Expand Up @@ -48,8 +41,7 @@ def build_egg_info():
"""

os.mkdir('setuptools.egg-info')
filename = 'setuptools.egg-info/entry_points.txt'
with io.open(filename, 'w', encoding='utf-8') as ep:
with open('setuptools.egg-info/entry_points.txt', 'w') as ep:

This comment has been minimized.

Copy link
@jakirkham

jakirkham May 31, 2017

Contributor

Can probably still go with io.open here.

This comment has been minimized.

Copy link
@jaraco

jaraco Jun 4, 2017

Author Member

Done in 3b443bc.

ep.write(minimal_egg_info)


Expand All @@ -61,44 +53,9 @@ def run_egg_info():
subprocess.check_call(cmd)


def gen_deps():
with io.open('setup.py', encoding='utf-8') as strm:
text = strm.read()
pattern = r'install_requires=\[(.*?)\]'
match = re.search(pattern, text, flags=re.M|re.DOTALL)
reqs = eval(match.group(1).replace('\n', ''))
with io.open('requirements.txt', 'w', encoding='utf-8') as reqs_file:
reqs_file.write('\n'.join(reqs))


@contextlib.contextmanager
def install_deps():
"Just in time make the deps available"
import pip
tmpdir = tempfile.mkdtemp()
args = [
'install',
'-t', tmpdir,
'-r', 'requirements.txt',
]
pip.main(args)
os.environ['PYTHONPATH'] = tmpdir
try:
yield tmpdir
finally:
shutil.rmtree(tmpdir)


def main():
ensure_egg_info()
gen_deps()
try:
# first assume dependencies are present
run_egg_info()
except Exception:
# but if that fails, try again with dependencies just in time
with install_deps():
run_egg_info()
run_egg_info()


__name__ == '__main__' and main()
32 changes: 32 additions & 0 deletions pavement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import re

from paver.easy import task, path as Path
import pip


def remove_all(paths):
for path in paths:
path.rmtree() if path.isdir() else path.remove()


@task
def update_vendored():
vendor = Path('pkg_resources/_vendor')
# pip uninstall doesn't support -t, so do it manually
remove_all(vendor.glob('packaging*'))
remove_all(vendor.glob('six*'))
remove_all(vendor.glob('pyparsing*'))
remove_all(vendor.glob('appdirs*'))
install_args = [
'install',
'-r', str(vendor / 'vendored.txt'),
'-t', str(vendor),
]
pip.main(install_args)
packaging = vendor / 'packaging'
for file in packaging.glob('*.py'):
text = file.text()
text = re.sub(r' (pyparsing|six)', r' pkg_resources.extern.\1', text)
file.write_text(text)
remove_all(vendor.glob('*.dist-info'))
remove_all(vendor.glob('*.egg-info'))
15 changes: 8 additions & 7 deletions pkg_resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
# Python 3.2 compatibility
import imp as _imp

import six
from six.moves import urllib, map, filter
from pkg_resources.extern import six
from pkg_resources.extern.six.moves import urllib, map, filter

# capture these to bypass sandboxing
from os import utime
Expand All @@ -67,11 +67,12 @@
except ImportError:
importlib_machinery = None

import packaging.version
import packaging.specifiers
import packaging.requirements
import packaging.markers
import appdirs
from pkg_resources.extern import appdirs
from pkg_resources.extern import packaging
__import__('pkg_resources.extern.packaging.version')
__import__('pkg_resources.extern.packaging.specifiers')
__import__('pkg_resources.extern.packaging.requirements')
__import__('pkg_resources.extern.packaging.markers')

This comment has been minimized.

Copy link
@jakirkham

jakirkham May 31, 2017

Contributor

Don't know the history here, but figured I'd draw attention to the __import__ calls here in case they are not needed and a regular import works.

This comment has been minimized.

Copy link
@jaraco

jaraco Jun 4, 2017

Author Member

I'm trying here to do the equivalent of what's on the left, to put packaging and appdirs in the namespace, but to ensure that packaging.{version,specifiers,requirements,markers} are imported. If I were to simply import pkg_resources.extern.packaging.version, that would add pkg_resources to the namespace. Is that what you had in mind?


if (3, 0) < sys.version_info < (3, 3):
raise RuntimeError("Python 3.3 or later is required")
Expand Down
Empty file.
Loading

0 comments on commit 3d0cc35

Please sign in to comment.