Commit b0859c20 authored by Xavier Thompson's avatar Xavier Thompson

WIP attempt to do --respect-pinned

parent 449f1618
......@@ -607,18 +607,21 @@ class Buildout(DictMixin):
def bootstrap(self, args):
__doing__ = 'Bootstrapping.'
if os.path.exists(self['buildout']['develop-eggs-directory']):
if os.path.isdir(self['buildout']['develop-eggs-directory']):
rmtree(self['buildout']['develop-eggs-directory'])
self._logger.debug(
"Removed existing develop-eggs directory")
options = self['buildout']
eggs_dir = options['eggs-directory']
develop_eggs_dir = options['develop-eggs-directory']
if os.path.exists(develop_eggs_dir):
if os.path.isdir(develop_eggs_dir):
rmtree(develop_eggs_dir)
self._logger.debug("Removed existing develop-eggs directory")
self._setup_directories()
if '--all-local' in args:
# Now install buildout and dependent eggs, and record destination eggs:
dest = self['buildout']['eggs-directory']
path = [self['buildout']['develop-eggs-directory']]
if '--respect-pinned' in args:
# Now install buildout and dependent eggs
dest = eggs_dir
path = [develop_eggs_dir]
if self.offline:
# Cannot install: just check requirements are already met
path.append(dest)
......@@ -627,43 +630,46 @@ class Buildout(DictMixin):
['zc.buildout'],
dest,
links=self._links,
index=self['buildout'].get('index'),
index=options.get('index'),
path=path,
newest=self.newest,
allow_hosts=self._allow_hosts,
)
else:
# Now copy buildout and setuptools eggs, and record destination eggs:
entries = []
for dist in zc.buildout.easy_install.buildout_and_setuptools_dists:
if dist.precedence == pkg_resources.DEVELOP_DIST:
dest = os.path.join(self['buildout']['develop-eggs-directory'],
dist.key + '.egg-link')
with open(dest, 'w') as fh:
fh.write(dist.location)
entries.append(dist.location)
else:
dest = os.path.join(self['buildout']['eggs-directory'],
os.path.basename(dist.location))
entries.append(dest)
if not os.path.exists(dest):
if os.path.isdir(dist.location):
shutil.copytree(dist.location, dest)
else:
shutil.copy2(dist.location, dest)
ws = pkg_resources.WorkingSet(entries)
ws = zc.buildout.easy_install.buildout_and_setuptools_dists
# Now copy buildout and setuptools eggs, and record destination eggs:
entries = []
for dist in ws.require('zc.buildout'):
print(dist)
if os.path.dirname(dist.location) in (eggs_dir, develop_eggs_dir):
print("ok ", dist.location)
entries.append(dist.location)
elif dist.precedence == pkg_resources.DEVELOP_DIST:
dest = os.path.join(self['buildout']['develop-eggs-directory'],
dist.key + '.egg-link')
with open(dest, 'w') as fh:
fh.write(dist.location)
print("dev", dist.location)
entries.append(dist.location)
else:
dest = os.path.join(self['buildout']['eggs-directory'],
os.path.basename(dist.location))
print("cpy", dest)
entries.append(dest)
if not os.path.exists(dest):
if os.path.isdir(dist.location):
shutil.copytree(dist.location, dest)
else:
shutil.copy2(dist.location, dest)
# Ensure all the requirements are met
ws.require('zc.buildout')
ws = pkg_resources.WorkingSet(entries)
# Create buildout script
options = self['buildout']
eggs_dir = options['eggs-directory']
develop_eggs_dir = options['develop-eggs-directory']
ws = zc.buildout.easy_install.sort_working_set(
ws,
eggs_dir=eggs_dir,
develop_eggs_dir=develop_eggs_dir
develop_eggs_dir=None
)
zc.buildout.easy_install.scripts(
['zc.buildout'], ws, sys.executable,
......
......@@ -69,6 +69,10 @@ default_index_url = os.environ.get(
)
logger = logging.getLogger('zc.buildout.easy_install')
def info(fmt, *args):
print(fmt % args)
logger.info = info
logger.debug = info
url_match = re.compile('[a-z0-9+.-]+://').match
is_source_encoding_line = re.compile(r'coding[:=]\s*([-\w.]+)').search
......@@ -1954,15 +1958,20 @@ def _move_to_eggs_dir_and_compile(dist, dest):
return newdist
def sort_working_set(ws, eggs_dir, develop_eggs_dir):
def sort_working_set(ws, eggs_dir, develop_eggs_dir=None):
develop_paths = set()
pattern = os.path.join(develop_eggs_dir, '*.egg-link')
for egg_link in glob.glob(pattern):
with open(egg_link, 'rt') as f:
path = f.readline().strip()
if path:
develop_paths.add(path)
if develop_eggs_dir:
pattern = os.path.join(develop_eggs_dir, '*.egg-link')
for egg_link in glob.glob(pattern):
with open(egg_link, 'rt') as f:
path = f.readline().strip()
if path:
develop_paths.add(path)
print(develop_paths)
print(ws.entries)
print([dist for dist in ws])
sorted_paths = []
egg_paths = []
other_paths = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment