实现全系统独立环境的方法是什么?在Haskell生态系统中?
通过比较(因为我来自Python中的包管理),这是一个使用Python的conda
工具的示例:
ely@eschaton:~$ conda create -n dummy_python python=2.7 numpy=1.8 ipython=2.0 pandas=0.14
Fetching package metadata: .......
Solving package specifications: .
Package plan for installation in environment /home/ely/anaconda/envs/dummy_python:
The following packages will be downloaded:
package | build
---------------------------|-----------------
numpy-1.8.2 | py27_0 7.3 MB
pandas-0.14.1 | np18py27_0 9.0 MB
setuptools-5.8 | py27_0 426 KB
------------------------------------------------------------
Total: 16.8 MB
The following NEW packages will be INSTALLED:
dateutil: 2.1-py27_2
ipython: 2.0.0-py27_0
numpy: 1.8.2-py27_0
openssl: 1.0.1h-1
pandas: 0.14.1-np18py27_0
python: 2.7.8-1
pytz: 2014.7-py27_0
readline: 6.2-2
scipy: 0.14.0-np18py27_0
setuptools: 5.8-py27_0
six: 1.8.0-py27_0
sqlite: 3.8.4.1-0
system: 5.8-1
tk: 8.5.15-0
zlib: 1.2.7-0
Proceed ([y]/n)? y
Fetching packages ...
numpy-1.8.2-py 100% |#####################################################################################################| Time: 0:00:05 1.53 MB/s
pandas-0.14.1- 100% |#####################################################################################################| Time: 0:00:07 1.19 MB/s
setuptools-5.8 100% |#####################################################################################################| Time: 0:00:00 559.36 kB/s
Extracting packages ...
[ COMPLETE ] |#######################################################################################################################| 100%
Linking packages ...
[ COMPLETE ] |#######################################################################################################################| 100%
#
# To activate this environment, use:
# $ source activate dummy_python
#
# To deactivate this environment, use:
# $ source deactivate
#
以上是为Python创建新环境的方法,在该环境中,可以操纵库的版本或Python本身,而不会影响系统Python或任何其他环境。
ely@eschaton:~$ source activate dummy_python
discarding /home/ely/anaconda/bin from PATH
prepending /home/ely/anaconda/envs/dummy_python/bin to PATH
(dummy_python)ely@eschaton:~$ python
Python 2.7.8 |Continuum Analytics, Inc.| (default, Aug 21 2014, 18:22:21)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import IPython
>>> IPython.__version__
'2.0.0'
>>> import pandas
>>> pandas.version
<module 'pandas.version' from '/home/ely/anaconda/envs/dummy_python/lib/python2.7/site-packages/pandas/version.pyc'>
>>> pandas.version.version
'0.14.1'
>>> exit()
(dummy_python)ely@eschaton:~$ source deactivate
discarding /home/ely/anaconda/envs/dummy_python/bin from PATH
ely@eschaton:~$ python
Python 2.7.8 |Anaconda 1.9.0 (64-bit)| (default, Aug 21 2014, 18:22:21)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import pandas
>>> pandas.version.version
'0.13.0'
>>> exit()
所以你可以看到dummy_python
有一组库,而系统Python有不同的集合。我可以在文件系统中的任何位置访问这些环境,而不仅仅是在初始化它们的目录中。
我知道Haskell的cabal
有sandbox features,但这些似乎依赖于文件系统位置,而不是可以从任何地方访问的单独环境。
使用cabal
实现与上述conda
示例更相似的内容的方法是什么?
例如,假设我想要一个&#34;环境&#34;对于安装了HDBC的Haskell。我想在文件系统的任何地方切换到这个环境,但我不想通过在我的机器上全局安装HDBC来改变我的GHC基本安装。