programing

github에서 pip 설치가 작동하도록 구성

javaba 2022. 10. 27. 23:42
반응형

github에서 pip 설치가 작동하도록 구성

pip with github을 사용하여 프로덕션 서버에 개인 패키지를 설치하고 싶습니다.이 질문은 설치를 성공시키기 위해 github repo에 무엇이 포함되어 있는지에 관한 것입니다.

다음의 커맨드 라인을 상정해(정확하게 인증해, 인스톨을 시도합니다).

pip install git+ssh://git@github.com/BlahCo/search/tree/prod_release_branch/ProductName

ProductName에는 무엇이 필요합니까?sdist 옵션과 함께 setup.py를 실행한 후 tar 파일에 일반적으로 포함되는 내용입니까?아니면 실제 tar.gz 파일입니까?

몇 가지 변형을 시도해 봤는데 잘 안 돼서 물어보는 거예요.아무쪼록 잘 부탁드립니다.

python 패키지 전체가 필요합니다.setup.py철해 주세요.

패키지 이름foo다음과 같습니다.

foo # the installable package
├── foo
│   ├── __init__.py
│   └── bar.py
└── setup.py

github에서 다음과 같이 설치합니다.

$ pip install git+ssh://git@github.com/myuser/foo.git
or
$ pip install git+https://github.com/myuser/foo.git@v123
or
$ pip install git+https://github.com/myuser/foo.git@newbranch

자세한 내용은 https://pip.pypa.io/en/stable/reference/pip_install/ #support를 참조하십시오.

github repo에서 설치해야 할 때도 비슷한 문제가 있었지만 git 등을 설치하고 싶지 않았습니다.

간단한 방법은 패키지의 zip 아카이브를 사용하는 것입니다.더하다/zipball/masterrepo URL:

    $ pip install https://github.com/hmarr/django-debug-toolbar-mongo/zipball/master
Downloading/unpacking https://github.com/hmarr/django-debug-toolbar-mongo/zipball/master
  Downloading master
  Running setup.py egg_info for package from https://github.com/hmarr/django-debug-toolbar-mongo/zipball/master
Installing collected packages: django-debug-toolbar-mongo
  Running setup.py install for django-debug-toolbar-mongo
Successfully installed django-debug-toolbar-mongo
Cleaning up...

이렇게 하면 github 소스 저장소에서 pip을 사용할 수 있습니다.

사용하고 싶은 경우requirements.txt파일이 필요합니다.git다음 엔트리와 같은 것을 사용하여 익명으로 마스터 브랜치를 취득합니다.requirements.txt.

일반 설치의 경우:

git+git://github.com/celery/django-celery.git

"편집 가능한" 설치의 경우:

-e git://github.com/celery/django-celery.git#egg=django-celery

편집 가능 모드에서는 프로젝트의 소스 코드가 다운로드됩니다../src현재 디렉토리에 있습니다.이 기능을 통해pip freeze패키지의 올바른 github 위치를 출력합니다.

다른 프로젝트와 마찬가지로 타깃 저장소를 클로닝합니다.

git clone git@github.com:myuser/foo.git

그런 다음 개발 모드로 설치합니다.

cd foo
pip install -e .

원하지 않는 모든 항목과 모든 코드를 변경할 수 있습니다.foo패키지는 수정된 코드를 사용합니다.

이 솔루션에는 다음 2가지 이점이 있습니다.

  1. 홈 프로젝트 디렉터리에 패키지를 설치할 수 있습니다.
  2. 패키지 내용.gitdir, 일반 Git 저장소입니다.바로 포크로 밀어주세요.

여기 간단한 해결책이 있습니다.

git으로

pip install git+https://github.com/jkbr/httpie.git

git 미포함

pip install https://github.com/jkbr/httpie/tarball/master

또는

pip install https://github.com/jkbr/httpie/zipball/master  

또는

pip install https://github.com/jkbr/httpie/archive/master.zip

주의: setup.py 파일이 포함된 python 패키지가 필요합니다.

콜라브에서 이 방법을 시도해 볼 수 있다.

!git clone https://github.com/UKPLab/sentence-transformers.git
!pip install -e /content/sentence-transformers
import sentence_transformers

이하의 포맷을 사용해 인스톨 할 수 있습니다.python라이브러리 경유pip부터GitHub.

pip install <LibName>@git+ssh://git@github.com/<username>/<LibName>#egg<LibName>

terminal 명령어를 사용하여 Optimized Ubuntu 솔루션 테스트:

스텝 1: 선택한 디렉토리에서 git repo를 복제합니다.

예:

$ git clone https://github.com/httpie/httpie.git

순서 2: 디렉토리 및 복제된 폴더의 경로 선택/변경

$ cd ClonedFolderName

순서 3: 다음 명령을 입력하여 패키지를 설치합니다.

ColnedFolderName(directory Name) $ pip install ./

pip install ./ 는 복제된 디렉토리 이름에 입력하는 명령어입니다.

주의: setup.py 가 클론된 repo 내에 있는지 확인하십시오.(디폴트)

언급URL : https://stackoverflow.com/questions/8247605/configuring-so-that-pip-install-can-work-from-github

반응형