Rez中文文档03 Getting Started

基本软件包

安装完成后,需要创建一些基本的Rez软件包。使用rez-bind工具进行创建,
这些软件包会引用系统上已经安装的软件。(—quickstart是以标准创建)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
]$ rez-bind --quickstart
Binding platform into /home/ajohns/packages...
Binding arch into /home/ajohns/packages...
Binding os into /home/ajohns/packages...
Binding python into /home/ajohns/packages...
Binding rez into /home/ajohns/packages...
Binding rezgui into /home/ajohns/packages...
Binding setuptools into /home/ajohns/packages...
Binding pip into /home/ajohns/packages...

Successfully converted the following software found on the current system into Rez packages:

PACKAGE URI
------- ---
arch /home/ajohns/packages/arch/x86_64/package.py
os /home/ajohns/packages/os/osx-10.11.5/package.py
pip /home/ajohns/packages/pip/8.0.2/package.py
platform /home/ajohns/packages/platform/osx/package.py
python /home/ajohns/packages/python/2.7.11/package.py
rez /home/ajohns/packages/rez/2.0.rc1.44/package.py
rezgui /home/ajohns/packages/rezgui/2.0.rc1.44/package.py
setuptools /home/ajohns/packages/setuptools/19.4/package.py

现在你应该可以创建一个包含Python的环境:

1
2
]$ rez-env python -- which python
/home/ajohns/packages/python-2.7.8/platform-linux/arch-x86_64/os-Ubuntu-12.04/bin/python

尝试创建第一个包

创建之前确保两件事

  • %HOME/packages文件夹有可写权限(软件包都安装在这个路径)
  • cmake工具是可用的

rez-build工具用于构建软件包并安装到packages中。
完成构建后就可以通过rez-env使用它们:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
]$ cd example_packages/hello_world
]$ rez-build --install

--------------------------------------------------------------------------------
Building hello_world-1.0.0...
--------------------------------------------------------------------------------
Resolving build environment: python
resolved by ajohns@workstation.local, on Sun Jul 31 14:39:33 2016, using Rez v2.0.rc1.44

requested packages:
python
~platform==osx (implicit)
~arch==x86_64 (implicit)
~os==osx-10.11.5 (implicit)

resolved packages:
arch-x86_64 /home/ajohns/packages/arch/x86_64 (local)
os-osx-10.11.5 /home/ajohns/packages/os/osx-10.11.5 (local)
platform-osx /home/ajohns/packages/platform/osx (local)
python-2.7.11 /home/ajohns/packages/python/2.7.11/platform-osx/arch-x86_64/os-osx-10.11.5 (local)

Invoking cmake build system...
Executing: /usr/local/bin/cmake -d /home/ajohns/workspace/rez/example_packages/hello_world -Wno-dev -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -D_ECLIPSE_VERSION=4.3 --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX=/home/ajohns/packages/hello_world/1.0.0 -DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH} -DCMAKE_BUILD_TYPE=Release -DREZ_BUILD_TYPE=local -DREZ_BUILD_INSTALL=1 -G Unix Makefiles
Not searching for unused variables given on the command line.
-- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ajohns/workspace/rez/example_packages/hello_world/build

Executing: make -j4
[100%] Built target py

Executing: make -j4 install
[100%] Built target py
Install the project...
-- Install configuration: "Release"
-- Installing: /home/ajohns/packages/hello_world/1.0.0/./python/hello_world.py
-- Installing: /home/ajohns/packages/hello_world/1.0.0/./python/hello_world.pyc
-- Installing: /home/ajohns/packages/hello_world/1.0.0/./bin/hello

All 1 build(s) were successful.

测试你的包

你可以使用rez-env命令来请求一个(或多个)你已经安装的软件包环境。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
]$ rez-env hello_world

You are now in a rez-configured environment.

resolved by ajohns@workstation.local, on Sun Jul 31 14:43:54 2016, using Rez v2.0.rc1.44

requested packages:
hello_world
~platform==osx (implicit)
~arch==x86_64 (implicit)
~os==osx-10.11.5 (implicit)

resolved packages:
arch-x86_64 /home/ajohns/packages/arch/x86_64 (local)
hello_world-1.0.0 /home/ajohns/packages/hello_world/1.0.0 (local)
os-osx-10.11.5 /home/ajohns/packages/os/osx-10.11.5 (local)
platform-osx /home/ajohns/packages/platform/osx (local)
python-2.7.11 /home/ajohns/packages/python/2.7.11/platform-osx/arch-x86_64/os-osx-10.11.5 (local)

> ]$ █

现在已经处于配置的环境中,可以尝试运行hello_world包中的hello工具:

1
2
> ]$ hello
Hello world!

如果你已经在rez shell的配置环境中,并且忘记了当前可用的软件包列表。
可以使用rez-context工具查看:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
> ]$ rez-context
resolved by ajohns@workstation.local, on Sun Jul 31 14:43:54 2016, using Rez v2.0.rc1.44

requested packages:
hello_world
~platform==osx (implicit)
~arch==x86_64 (implicit)
~os==osx-10.11.5 (implicit)

resolved packages:
arch-x86_64 /home/ajohns/packages/arch/x86_64 (local)
hello_world-1.0.0 /home/ajohns/packages/hello_world/1.0.0 (local)
os-osx-10.11.5 /home/ajohns/packages/os/osx-10.11.5 (local)
platform-osx /home/ajohns/packages/platform/osx (local)
python-2.7.11 /home/ajohns/packages/python/2.7.11/platform-osx/arch-x86_64/os-osx-10.11.5 (local)

如果要退出这个环境,使用exit命令。

1
2
> ]$ exit
]$

你还可以快速的运行一个命令,当命令执行完成,则自动退出环境。

1
2
3
]$ rez-env hello_world -- hello
Hello world!
]$