在Mac OS X 10.6 Snow Leopard上安装Mercurial

Mat*_*kin 13 python macos mercurial osx-snow-leopard

在Mac OS X 10.6 Snow Leopard上安装Mercurial

我使用以下内容从源代码在Mac OS X 10.6 Snow Leopard上安装了Mercurial 1.3.1:

cd ~/src
curl -O https://www.mercurial-scm.org/release/mercurial-1.3.1.tar.gz
tar -xzvf mercurial-1.3.1.tar.gz
cd mercurial-1.3.1
make all
sudo make install
Run Code Online (Sandbox Code Playgroud)

这将安装Mercurial的站点包文件/usr/local/lib/python2.6/site-packages/.我知道从M​​ac Disk Image安装Mercurial会将文件安装到/Library/Python/2.6/site-packages/,这是Mac OS X默认Python安装的site-packages目录.

我将Python 2.6.2+作为Framework安装,其site-packages目录位于:

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

以这种方式安装Mercurial,我必须发出:

PYTHONPATH =在/ usr/local/lib目录/ python2.6的/站点包: "$ {PYTHONPATH}"

为了让Mercurial工作.

问题

  • 如何从源代码将Mercurial与site-packages安装在不同的目录中?
  • 在当前位置使用网站包是否有利有弊?在一个已经存在的Python站点包目录中会更好吗?
  • 我是否需要关注virtualenv正常工作,因为我修改了PYTHONPATH(或任何其他冲突)?

从源安装的原因

丹本杰明Hivelogic提供了在他的文章从源代码安装水银的益处和说明雪豹安装水银.

Wil*_*ung 13

为什么需要使用macports?python easy_install是最简单的方法,没有错误:

easy_install -U mercurial
Run Code Online (Sandbox Code Playgroud)

它一直只是一个简单的金子弹.


Hor*_*ann 8

特别是因为你有Python 2.6可用,你可以做类似的事情python setup.py install --user,它将使用〜/ .local作为前缀安装Mercurial.您不必为此更改PYTHONPATH,而只需将〜/ .local/bin添加到PATH中.

关于优点和缺点:这一切都取决于你的PYTHONPATH一般看起来是什么样的,因为修改它会自然地修改包的加载顺序(如果你有一个版本的Mercurial安装了一个前缀而另一个版本带有不同的前缀,那么它就变得相关).通常,我尝试将所有自定义包放入某个site-packages文件夹(例如/usr/local/lib/python2.6/site-packages).再说一遍:如果你是唯一一个使用这些库的人,那么Python 2.6的distutils提供的--user标志就可以很容易了(将〜/ .local添加到模块的默认搜索路径中).

只要你一直使用PYTHONPATH,virtualenv应该可以正常工作.


Rei*_*ica 7

将mercurial(或任何Python包)安装到用户主目录中.因此,您可以从任何Python(相同版本)或任何virtualenv访问它们.有关详细信息,请参阅PEP 370.

$ cd mercurial-x.y.z/
$ python2.6 setup.py install --user
$ ~/.local/bin/hg
...
Run Code Online (Sandbox Code Playgroud)

但是你为什么要手动建立mercurial?我用macports.

$ sudo port install mercurial
$ which hg
/opt/local/bin/hg
Run Code Online (Sandbox Code Playgroud)

更新:现在,我只是使用PyPM来安装mercurial ~/.local/bin/hg.


med*_*duz 5

正如Sridhar所建议的那样,macports在多种架构上运行良好,MacOsX +版本允许更新等等:

$ port variants mercurial
mercurial has the variants:
   bash_completion: Completion support for bash
   zsh_completion: Install mercurial zsh completion file
$
Run Code Online (Sandbox Code Playgroud)

这样你就可以使用:

$ sudo port install mercurial +bash_completion
--->  Computing dependencies for mercurial
--->  Fetching mercurial
--->  Attempting to fetch mercurial-1.3.1.tar.gz from http://arn.se.distfiles.macports.org/python
--->  Attempting to fetch mercurial-1.3.1.tar.gz from http://www.selenic.com/mercurial/release/
--->  Verifying checksum(s) for mercurial
--->  Extracting mercurial
--->  Configuring mercurial
--->  Building mercurial
--->  Staging mercurial into destroot
--->  Installing mercurial @1.3.1_0+bash_completion
--->  Activating mercurial @1.3.1_0+bash_completion
--->  Cleaning mercurial
$
Run Code Online (Sandbox Code Playgroud)