macos 在 Mac OS X 10.6 Snow Leopard 上安装 Mercurial

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1461374/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:25:47  来源:igfitidea点击:

Installing Mercurial on Mac OS X 10.6 Snow Leopard

pythonmacosmercurialosx-snow-leopard

提问by Matthew Rankin

Installing Mercurial on Mac OS X 10.6 Snow Leopard

在 Mac OS X 10.6 Snow Leopard 上安装 Mercurial

I installed Mercurial 1.3.1 on Mac OS X 10.6 Snow Leopard from source using the following:

我使用以下代码在 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

This installs the site-packages files for Mercurial in /usr/local/lib/python2.6/site-packages/. I know that installing Mercurial from the Mac Disk Image will install the files into /Library/Python/2.6/site-packages/, which is the site-packages directory for the Mac OS X default Python install.

这将安装 Mercurial 的站点包文件/usr/local/lib/python2.6/site-packages/。我知道从 Mac 磁盘映像安装 Mercurial 会将文件安装到/Library/Python/2.6/site-packages/,这是 Mac OS X 默认 Python 安装的站点包目录。

I have Python 2.6.2+ installed as a Framework with its site-packages directory in:

我将 Python 2.6.2+ 作为框架安装,其站点包目录位于:

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

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

With Mercurial installed this way, I have to issue:

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

PYTHONPATH=/usr/local/lib/python2.6/site-packages:"${PYTHONPATH}"

PYTHONPATH=/usr/local/lib/python2.6/site-packages:"${PYTHONPATH}"

in order to get Mercurial to work.

为了让 Mercurial 工作。

Questions

问题

  • How can I install Mercurial from source with the site-packages in a different directory?
  • Is there an advantage or disadvantage to having the site-packages in the current location? Would it be better in one of the Python site-package directories that already exist?
  • Do I need to be concerned about virtualenv working correctly since I have modified PYTHONPATH (or any other conflicts for that matter)?
  • 如何使用不同目录中的站点包从源代码安装 Mercurial?
  • 将站点包放在当前位置是否有优势或劣势?在已经存在的 Python 站点包目录之一中会更好吗?
  • 由于我修改了 PYTHONPATH(或任何其他与此相关的冲突),我是否需要担心 virtualenv 正常工作?

Reasons for Installing from Source

从源安装的原因

Dan Benjaminof Hivelogicprovides the benefits of and instructions for installing Mercurial from source in his article Installing Mercurial on Snow Leopard.

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

采纳答案by Horst Gutmann

Especially since you have Python 2.6 available you can do something like python setup.py install --user, which will install Mercurial with ~/.local as prefix. You don't have to change the PYTHONPATH for this but only add ~/.local/bin to your PATH.

特别是因为您有 Python 2.6 可用,您可以执行类似的操作python setup.py install --user,它将安装带有 ~/.local 前缀的 Mercurial。您不必为此更改 PYTHONPATH,而只需将 ~/.local/bin 添加到您的 PATH。

Regarding advantages and disadvantages: That all depends on what your PYTHONPATH in general looks like since modifying it will naturally modify the load order of packages (which becomes relevant if you have one version of Mercurial installed with one prefix and another with a different prefix). In general, I try to put all custom packages into a certain site-packages folder (say /usr/local/lib/python2.6/site-packages). Again: If you are the only person who will use those libs, the --user flag provided by Python 2.6's distutils makes something like this pretty easy (with adding ~/.local to the default search path for modules).

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

virtualenv should work just fine as long you your PYTHONPATH is used consistently.

只要您始终如一地使用 PYTHONPATH,virtualenv 应该可以正常工作。

回答by William Yeung

Why need to use macports? python easy_installis the easiest way and error free:

为什么需要使用macports?pythoneasy_install是最简单的方法并且没有错误:

easy_install -U mercurial

It's just a simple gold bullet, all the time.

这只是一个简单的金子弹,一直。

回答by Sridhar Ratnakumar

Install mercurial - or any Python package in general - into your user home directory. Thus you can access them from any Python (of same version) or any virtualenv. See PEP 370for details.

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

$ cd mercurial-x.y.z/
$ python2.6 setup.py install --user
$ ~/.local/bin/hg
...

But why do you want to build mercurial manually? I use macports.

但是为什么要手动构建 mercurial 呢?我使用macports

$ sudo port install mercurial
$ which hg
/opt/local/bin/hg

Update: Nowadays, I simply use PyPMto install mercurial into ~/.local/bin/hg.

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

回答by meduz

as suggested by Sridhar, macports works fine on multiple architecture and versions of MacOsX + allows updates and more:

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

$ port variants mercurial
mercurial has the variants:
   bash_completion: Completion support for bash
   zsh_completion: Install mercurial zsh completion file
$

so that you may use:

以便您可以使用:

$ 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
$

回答by PlanBForOpenOffice

All those answers look complicated to the average mac OS X users, because they are specific to other install platforms. As of now the Mercurial website offers an installer package (compressed as a zip file).

对于普通的 mac OS X 用户来说,所有这些答案看起来都很复杂,因为它们特定于其他安装平台。截至目前,Mercurial 网站提供了一个安装程序包(压缩为 zip 文件)。