Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
镜像
Python_Packaging_Authority
pip
提交
f73385ad
P
pip
项目概览
镜像
/
Python_Packaging_Authority
/
pip
12 个月 前同步成功
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pip
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f73385ad
编写于
3月 22, 2011
作者:
D
Dan Sully
提交者:
Jannis Leidel
4月 25, 2011
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow requirements.txt URLs to have egg= definitions.
上级
98947e00
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
56 addition
and
22 deletion
+56
-22
docs/requirement-format.txt
docs/requirement-format.txt
+9
-0
pip/index.py
pip/index.py
+10
-6
pip/req.py
pip/req.py
+21
-15
tests/test_requirements.py
tests/test_requirements.py
+16
-1
未找到文件。
docs/requirement-format.txt
浏览文件 @
f73385ad
...
...
@@ -24,6 +24,15 @@ The ``#egg=MyProject`` part is important, because while you can
install simply given the svn location, the project name is useful in
other places.
You can also specify the egg name for a non-editable url. This is useful to
point to HEAD locations on the local filesystem:
file:///path/to/your/lib/project#egg=MyProject
or relative paths:
file:../../lib/project#egg=MyProject
If you need to give pip (and by association easy_install) hints
about where to find a package, you can use the ``-f``
(``--find-links``) option, like::
...
...
pip/index.py
浏览文件 @
f73385ad
...
...
@@ -578,13 +578,9 @@ class Link(object):
@
property
def
filename
(
self
):
url
=
self
.
url
url
=
url
.
split
(
'#'
,
1
)[
0
]
url
=
url
.
split
(
'?'
,
1
)[
0
]
url
=
url
.
rstrip
(
'/'
)
url
=
self
.
url_fragment
name
=
posixpath
.
basename
(
url
)
assert
name
,
(
'URL %r produced no filename'
%
url
)
assert
name
,
(
'URL %r produced no filename'
%
url
)
return
name
@
property
...
...
@@ -598,6 +594,14 @@ class Link(object):
def
splitext
(
self
):
return
splitext
(
posixpath
.
basename
(
self
.
path
.
rstrip
(
'/'
)))
@
property
def
url_fragment
(
self
):
url
=
self
.
url
url
=
url
.
split
(
'#'
,
1
)[
0
]
url
=
url
.
split
(
'?'
,
1
)[
0
]
url
=
url
.
rstrip
(
'/'
)
return
url
_egg_fragment_re
=
re
.
compile
(
r
'#egg=([^&]*)'
)
@
property
...
...
pip/req.py
浏览文件 @
f73385ad
...
...
@@ -73,28 +73,34 @@ class InstallRequirement(object):
"""
url
=
None
name
=
name
.
strip
()
req
=
nam
e
req
=
Non
e
path
=
os
.
path
.
normpath
(
os
.
path
.
abspath
(
name
))
link
=
None
if
is_url
(
name
):
url
=
name
## FIXME: I think getting the requirement here is a bad idea:
#req = get_requirement_from_url(url)
req
=
None
link
=
Link
(
name
)
elif
os
.
path
.
isdir
(
path
)
and
(
os
.
path
.
sep
in
name
or
name
.
startswith
(
'.'
)):
if
not
is_installable_dir
(
path
):
raise
InstallationError
(
"Directory %r is not installable. File 'setup.py' not found."
%
name
)
url
=
path_to_url
(
name
)
#req = get_requirement_from_url(url)
req
=
None
raise
InstallationError
(
"Directory %r is not installable. File 'setup.py' not found."
,
name
)
link
=
Link
(
path_to_url
(
name
))
elif
is_archive_file
(
path
):
if
not
os
.
path
.
isfile
(
path
):
logger
.
warn
(
'Requirement %r looks like a filename, but the file does not exist'
%
name
)
url
=
path_to_url
(
name
)
#req = get_requirement_from_url(url)
req
=
None
logger
.
warn
(
'Requirement %r looks like a filename, but the file does not exist'
,
name
)
link
=
Link
(
path_to_url
(
name
))
# If the line has an egg= definition, but isn't editable, pull the requirement out.
# Otherwise, assume the name is the req for the non URL/path/archive case.
if
link
and
req
is
None
:
url
=
link
.
url_fragment
req
=
link
.
egg_fragment
# Handle relative file URLs
if
link
.
scheme
==
'file'
and
re
.
search
(
r
'\.\./'
,
url
):
url
=
path_to_url
(
os
.
path
.
normpath
(
os
.
path
.
abspath
(
link
.
path
)))
else
:
req
=
name
return
cls
(
req
,
comes_from
,
url
=
url
)
def
__str__
(
self
):
...
...
tests/test_requirements.py
浏览文件 @
f73385ad
import
textwrap
from
pip.backwardcompat
import
urllib
from
pip.req
import
Requirements
from
tests.test_pip
import
reset_env
,
run_pip
,
write_file
,
pyversion
from
tests.test_pip
import
reset_env
,
run_pip
,
write_file
,
pyversion
,
here
from
tests.local_repos
import
local_checkout
from
tests.path
import
Path
def
test_requirements_file
():
"""
...
...
@@ -22,6 +24,19 @@ def test_requirements_file():
fn
=
'%s-%s-py%s.egg-info'
%
(
other_lib_name
,
other_lib_version
,
pyversion
)
assert
result
.
files_created
[
env
.
site_packages
/
fn
].
dir
def
test_relative_requirements_file
():
"""
Test installing from a requirements file with a relative path with an egg= definition..
"""
url
=
'file://'
+
str
(
urllib
.
quote
(
Path
(
here
).
abspath
+
'/packages/../packages/FSPkg'
)
+
'#egg=FSPkg'
).
replace
(
'
\\
'
,
'/'
)
env
=
reset_env
()
write_file
(
'file-egg-req.txt'
,
textwrap
.
dedent
(
"""
\
%s
"""
%
url
))
result
=
run_pip
(
'install'
,
'-vvv'
,
'-r'
,
env
.
scratch_path
/
'file-egg-req.txt'
)
assert
(
env
.
site_packages
/
'FSPkg-0.1dev-py%s.egg-info'
%
pyversion
)
in
result
.
files_created
,
str
(
result
)
assert
(
env
.
site_packages
/
'fspkg'
)
in
result
.
files_created
,
str
(
result
.
stdout
)
def
test_multiple_requirements_files
():
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录