pip는 setup.py의 dependency_links를 무시합니다.
내 setup.py에 dependency_links가 있습니다.
...
dependency_links = ['http://github.com/robot-republic/python-s3/tarball/master.tar.gz#egg=python-s3'],
...
하지만 작동하지 않습니다. 그러나 install_requires는 잘 작동합니다. 아마도 setup.py에 필요한 git repo를 설정하는 다른 방법이 있습니까?
이 답변 이 도움이 될 것입니다. 간단히 말해서, 당신은을위한 버전 (또는 "DEV")을 지정할 필요 #egg=python-s3
가 보이는 있도록 #egg=python-s3-1.0.0
.
@Cerin의 의견을 기반으로 한 업데이트 :
- Pip 1.5.x에는 종속성 링크 처리를 활성화하는 플래그가 있습니다 :
--process-dependency-links
. 아래 내용에 동의하므로 테스트하지 않았습니다. - 이 토론 은 pip에 종속성 링크를 사용하는 것이 나쁜 습관임을 나타내는 것 같습니다. 이 기능은 더 이상 사용되지 않지만 더 이상 사용되지 않습니다. 개인 패키지에 대한 유효한 사용 사례가 있습니다.
나는 이것이 오래된 질문이라는 것을 알고 있지만, 내가 한 것처럼 여기에서 자신을 발견하는 경우를 대비하여 이것이 나를 위해 일한 것입니다.
다른 GitHub (pypi가 아닌) 패키지에 의존하는 GitHub (pypi에 등록되지 않음)에 패키지가 있습니다. 나는 이것을 올바르게 처리하기 위해 pip를 얻는 방법을 알아내는 데 과도한 시간을 보냈습니다. 여기에 수정 한 내용을 포함하겠습니다.
requirements.txt 파일에 종속성을 넣는 것이 종속성을 나열하는 데 선호되는 방법입니다. 그러나 설치시 install_requires도 채워야합니다. 이 단계에서 GitHub에서 종속성을 설치하고 싶지 않은 pip가있는 장애물에 부딪 혔습니다.
이 질문에 대한 답변을 포함하여 대부분의 장소에서 설정의 dependency_links 섹션을 채우라고합니다. 그러나 dependency_links에서 참조하는 패키지의 이름으로 install_requires 필드를 채워야합니다.
예를 들어, requirements.txt에 다음이 포함 된 경우.
somepackage==1.2.0
https://github.com/user/repo/tarball/master#egg=repo-1.0.0
anotherpackage==4.2.1
그러면 설정 호출이 다음과 같이 표시됩니다.
setup(
name='yourpackage',
version='1.7.5',
packages=[],
url='',
license='',
author='',
author_email='',
description='',
install_requires=[
'somepackage==1.2.0',
'repo==1.0.0',
'anotherpackage==4.2.1'
],
dependency_links=[
'https://github.com/user/repo/tarball/master#egg=repo-1.0.0'
]
)
이제 패키지가 구성되었습니다. 설치는 다음 작업입니다. 이것은 내가 많은 시간을 보낸 곳입니다. 왜 dependency_links를 지정하면 아무 일도하지 않는 이유를 알 수 없습니다. 트릭은 경우에 따라 pip에 대해 allow-all-external (더 구체적 일 수 있음) 플래그를 설정해야한다는 것입니다. 예를 들면 :
pip install git+https://github.com/user/anotherrepo.git
--process-dependency-links --allow-all-external
완료되었으며 작동합니다!
면책 조항 : dependency_links 및 플래그 process-dependency-links 및 allow-all-external은 더 이상 사용되지 않으므로 곧 제거됩니다. 내가 보낸 시간에는 더 좋고 선호하는 방법을 찾을 수 없었고 여전히 pip 기능을 제대로 가지고 있습니다.
pip 버전 18.1 PEP 508 URL 이 지원 되기 때문 입니다. 즉, 더 이상 사용되지 않는 dependency_link가 필요하지 않습니다. 대신 install_requires 목록에 직접 종속성을 작성합니다. @Chad의 예는 다음과 같습니다.
setup(
name='yourpackage',
version='1.7.5',
packages=[],
url='',
license='',
author='',
author_email='',
description='',
install_requires=[
'somepackage==1.2.0',
'repo==1.0.0 @ https://github.com/user/archive/master.zip#egg=repo-1.0.0',
'anotherpackage==4.2.1'
],
)
패키지를 설치하려면 다음과 같이 작성하면됩니다.
pip install yourpackage
(--process-dependency-links없이)
특히 개인 저장소에서 설치하는 경우 발견 한 몇 가지 문제에 대한 몇 가지 참고 사항입니다.
pip 및 setuptools에서 설치하는 데 약간의 차이가 있습니다. 그러나이 방법은 둘 다 작동합니다.
from setuptools import setup
import os
# get deploy key from https://help.github.com/articles/git-automation-with-oauth-tokens/
github_token = os.environ['GITHUB_TOKEN']
setup(
# ...
install_requires='package',
dependency_links = [
'git+https://{github_token}@github.com/user/{package}.git/@{version}#egg={package}-0'
.format(github_token=github_token, package=package, version=master)
]
여기에 몇 가지 참고 사항이 있습니다.
- For private repos, you need to authenticate with GitHub; the simplest way I found is to create an oauth token, drop that into your environment, and then include it with the URL
- You need to include some version number (here is
0
) at the end of the link, even if there's no package on PyPI. This has to be a actual number, not a word. - You need to preface with
git+
to tell setuptools it's to clone the repo, rather than pointing at a zip / tarball version
can be a branch, a tag, or a commit hash- You need to supply
--process-dependency-links
if installing from pip
First upgrade your pip version as this is a new syntax.
pip install pip --upgrade
Then do the following:
install_requires=[
'bleualign-git @ https://github.com/rsennrich/Bleualign/archive/<commit-hash or branch-name>.zip#egg=bleualign-git-1.0.0'
]
- Version 1.0.0 and name "bluealign-git" are randomly chosen.
- The version number is necessary.
- We advisedly used the name "bleualign-git" to distinguish it from the main repository version.
Hope this helps.
Comments:
Good answer (upvoted). Also want to mention that the actual result would likely depend on the platform and/or pip version, though. I've seen when it works, or seemingly works but did not really pull the dependency from the specified link, or simply being rejected. So I would probably just use this as a short time workaround only. Stick with the mainstream way whenever possible.
참고URL : https://stackoverflow.com/questions/12518499/pip-ignores-dependency-links-in-setup-py
'Development Tip' 카테고리의 다른 글
JUnit을 사용한 내부 클래스의 테스트 케이스 (0) | 2020.12.03 |
---|---|
자바 스크립트 개체 키 이름 가져 오기 (0) | 2020.12.03 |
전체 diff 출력을 얻기 위해 nose에서 self.maxDiff를 설정하는 방법은 무엇입니까? (0) | 2020.12.03 |
정규식-문자열로 시작 및 끝 (0) | 2020.12.03 |
한 Mac에서 다른 Mac으로 Atom 설치 (패키지 및 설정)를 공유 / 전송하는 방법은 무엇입니까? (0) | 2020.12.03 |