2010-12-10 2 views
2

간단한 "hello world"스크립트 용으로 만든 테스트 설정 파일이 있습니다. 나는 이라는 패키지에 hello이라는 기능을 가지고있다. 이제 매우 간단합니다. setup.py. 방금 python setup.py install을 실행하면 모든 것이 잘 작동합니다. 그러나 lib를 홈 폴더 (python setup.py install --home=/home/blah)에 설치하려면 패키지를 더 이상 사용할 수 없습니다 (import mytest에서 python을 실행하면 이됩니다).python setup.py를 다른 경로에 설치하면 설치된 패키지를 찾을 수 없습니다.

수동으로 pth 파일을 site-packages 폴더에 추가해야합니까? (내용이 /home/blah/lib/python 인 패키지를 넣었습니다.) 그리고 가져 오기 mytest이 정상적으로 작동했습니다. 자동으로 실행하면 안됩니까? 아니면 내가 놓친 게 있니?

EDIT :

 
[email protected]:~/py/mytest-0.1$ python setup.py install --home=/home/ago/py/ 
running install 
running build 
running build_py 
copying src/mytest/mytest.py -> build/lib.linux-x86_64-2.6/mytest 
running build_scripts 
copying and adjusting src/main.py -> build/scripts-2.6 
running install_lib 
copying build/lib.linux-x86_64-2.6/mytest/mytest.py -> /home/ago/py//lib/python/mytest 
byte-compiling /home/ago/py//lib/python/mytest/mytest.py to mytest.pyc 
running install_scripts 
copying build/scripts-2.6/main.py -> /home/ago/py//bin 
changing mode of /home/ago/py//bin/main.py to 755 
running install_egg_info 
Removing /home/ago/py//lib/python/mytest-0.1.egg-info 
Writing /home/ago/py//lib/python/mytest-0.1.egg-info 

및 setup.py :

출력 설치

 
from distutils.core import setup 

setup(name='mytest', 
     description='test', 
     author='Ago', 
     author_email='email', 
     version='0.1', 
     package_dir={'mytest': 'src/mytest'}, 
     packages=['mytest'], 
     scripts=['src/main.py'] 
    ) 

폴더 구조 :

 
-src: 
    -mytest: 
     __init__.py 
     mytest.py 
    main.py 
setup.py 

main.py 방금 ​​executabl 인 e는 mytest를 가져오고 hello world를 인쇄하는 함수를 호출합니다. 하지만 난 단지 import mytest Python에서 볼 수 있는지, lib 설치 여부를 실행하려고했습니다.

+0

글쎄요, 현재 mytest.pth 파일을 내용'/ home/ago/py/lib/python'과 함께'site-packages'에 추가했습니다. 하지만 누군가가 왜 내 모듈/패키지가'python setup.py install '과 함께 제공되지 않는지에 대한 해결책이 있다면, 나는 여전히 관심이있다. 감사! – Ago

답변

2

나는 python setup.py install --home=/home/blah 명령의 전체 출력을보고 싶습니다. 디렉토리가 존재하지 않거나 pth 파일을 지원하지 않으면 경고 또는 오류가 발생합니다. 실제로 설치가 실패합니다.

거기에 물건을 넣을 수도 있기 때문에 setup.py 파일을 보는 것이 도움이됩니다.

+0

답장을 보내 주셔서 감사합니다! 질문을 수정하고 요청한 사항을 추가했습니다. – Ago

+0

이상한. 그것이 맞다면 버그입니다,하지만 당신이 설치 명령을 내린 경로는 distutils가 정규화되지 않은 슬래쉬를 가지고 있습니다. '--home =/home/ago/py /'대신'--home =/home/ago/py'와 같은 명령어를 사용할 수 있습니까? – jonesy

+0

후행 슬래시없이 시도했습니다. 여전히 동일합니다. – Ago

0

적어도 파이썬은 유닉스 환경과 윈도우 환경에서 매개 변수를 통합 한 것처럼 보입니다. 오늘 파이썬 참조 (https://docs.python.org/2/install/index.html, 2017 년 12 월)를 보면 두 OS 모두에서 --prefix=<head installation path>을 사용할 수 있음을 보여줍니다. 참조 번호 인 "Alternate installation: Unix (the prefix scheme)""Alternate installation: Windows (the prefix scheme)"을 살펴보십시오. 난 그냥 Oct2Py (옥타브 - 파이썬 변환기), easy_install 또는 pip와 함께 설치하는 데 문제가 있었는지 테스트했지만이 방법은 꽤 잘 했어.

귀하의 파이썬 패키지는 (파이썬 2.7을 사용한다고 가정) <head installation path>/lib/python2.7/site-packages 또는 <head installation path>/lib/python2.7/dist-packages입니다.