提交 6a24249f 编写于 作者: J Jannis Leidel
......@@ -136,7 +136,7 @@ tell you what all the exact versions are.
To create a new requirements file from a known working environment, use::
$ pip freeze stable-req.txt
$ pip freeze > stable-req.txt
This will write a listing of *all* installed libraries to ``stable-req.txt``
with exact versions for every library. You may want to edit the file down after
......@@ -146,7 +146,7 @@ stable starting point for constructing your requirements file.
You can also give it an existing requirements file, and it will use that as a
sort of template for the new file. So if you do::
$ pip freeze stable-req.txt -r devel-req.txt
$ pip freeze -r devel-req.txt > stable-req.txt
it will keep the packages listed in ``devel-req.txt`` in order and preserve
comments.
......
News for pip
============
tip
---
* Added ability to override the default log file name (``pip-log.txt``)
with the environmental variable ``$PIP_LOG_FILE``.
* Made the freeze command to return the installed packages instead of
writing them to a file. Use simple redirection (e.g.
``pip freeze > stable-req.txt``) to get a file with requirements.
* Fixed problem of freezing an editable packages from a Git repository.
* Added support for base URLs using ``<base href='...'>`` when parsing
HTML pages.
0.4
---
......
......@@ -290,7 +290,7 @@ class Command(object):
if log_fp is not None:
log_fp.close()
if exit:
log_fn = './pip-log.txt'
log_fn = os.environ.get('PIP_LOG_FILE', './pip-log.txt')
text = '\n'.join(complete_log)
logger.fatal('Storing complete log in %s' % log_fn)
log_fp = open_logfile_append(log_fn)
......@@ -501,8 +501,8 @@ DownloadCommand()
class FreezeCommand(Command):
name = 'freeze'
usage = '%prog [OPTIONS] FREEZE_NAME.txt'
summary = 'Put all currently installed packages (exact versions) into a requirements file'
usage = '%prog [OPTIONS]'
summary = 'Output all currently installed packages (exact versions) to stdout'
def __init__(self):
super(FreezeCommand, self).__init__()
......@@ -522,10 +522,6 @@ class FreezeCommand(Command):
help='URL for finding packages, which will be added to the frozen requirements file')
def run(self, options, args):
if args:
filename = args[0]
else:
filename = '-'
requirement = options.requirement
find_links = options.find_links or []
## FIXME: Obviously this should be settable:
......@@ -534,15 +530,11 @@ class FreezeCommand(Command):
if os.environ.get('PIP_SKIP_REQUIREMENTS_REGEX'):
skip_match = re.compile(os.environ['PIP_SKIP_REQUIREMENTS_REGEX'])
if filename == '-':
logger.move_stdout_to_stderr()
logger.move_stdout_to_stderr()
dependency_links = []
if filename == '-':
f = sys.stdout
else:
## FIXME: should be possible to overwrite requirement file
logger.notify('Writing frozen requirements to %s' % filename)
f = open(filename, 'w')
f = sys.stdout
for dist in pkg_resources.working_set:
if dist.has_metadata('dependency_links.txt'):
dependency_links.extend(dist.get_metadata_lines('dependency_links.txt'))
......@@ -593,9 +585,6 @@ class FreezeCommand(Command):
f.write('## The following requirements were added by pip --freeze:\n')
for installation in sorted(installations.values(), key=lambda x: x.name):
f.write(str(installation))
if filename != '-':
logger.notify('Put requirements in %s' % filename)
f.close()
FreezeCommand()
......@@ -2258,6 +2247,7 @@ class HTMLPage(object):
## These aren't so aweful:
_rel_re = re.compile("""<[^>]*\srel\s*=\s*['"]?([^'">]+)[^>]*>""", re.I)
_href_re = re.compile('href=(?:"([^"]*)"|\'([^\']*)\'|([^>\\s\\n]*))', re.I|re.S)
_base_re = re.compile(r"""<base\s+href\s*=\s*['"]?([^'">]+)""", re.I)
def __init__(self, content, url, headers=None):
self.content = content
......@@ -2355,12 +2345,19 @@ class HTMLPage(object):
finally:
conn.close()
@property
def base_url(self):
match = self._base_re.search(self.content)
if match:
return match.group(1)
return self.url
@property
def links(self):
"""Yields all links in the page"""
for match in self._href_re.finditer(self.content):
url = match.group(1) or match.group(2) or match.group(3)
url = self.clean_link(urlparse.urljoin(self.url, url))
url = self.clean_link(urlparse.urljoin(self.base_url, url))
yield Link(url, self)
def rel_links(self):
......@@ -2382,7 +2379,7 @@ class HTMLPage(object):
if not match:
continue
url = match.group(1) or match.group(2) or match.group(3)
url = self.clean_link(urlparse.urljoin(self.url, url))
url = self.clean_link(urlparse.urljoin(self.base_url, url))
yield Link(url, self)
def scraped_rel_links(self):
......@@ -2396,7 +2393,7 @@ class HTMLPage(object):
url = match.group(1) or match.group(2) or match.group(3)
if not url:
continue
url = self.clean_link(urlparse.urljoin(self.url, url))
url = self.clean_link(urlparse.urljoin(self.base_url, url))
yield Link(url, self)
_clean_re = re.compile(r'[^a-z0-9$&+,/:;=?@.#%_\\|-]', re.I)
......@@ -3024,6 +3021,7 @@ class Git(VersionControl):
[GIT_CMD, 'branch', '-r'], show_stdout=False, cwd=location)
branch_revs = []
for line in branches.splitlines():
line = line.split('->')[0].strip()
branch = "".join([b for b in line.split() if b != '*'])
rev = call_subprocess(
[GIT_CMD, 'rev-parse', branch], show_stdout=False, cwd=location)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册