python_binary()

This is liable to change in the future.

A python_binary() rule is used to build a PEX file -- an exectuble python package that includes python sources and resources from all transitive python_library dependencies.

Arguments

  • name (required) #

    The name of the rule. The output PEX file will also get this name, with an additional .pex suffix.

  • main_module (required) #

    The module which serves as the entry point for this rule. The __main__.py file of this module will be executed by the interpreter when the PEX file is run.

  • base_module (defaults to None) #

    The package for which the main module should reside under in it's final location in the binary. If unset, the project relative directory that houses the BUCK file is used.

  • platform (defaults to None) #

    The name of the Python platform to build against by default (as defined in the `python#name` section of `.buckconfig`).

  • deps (defaults to []) #

    python_library rules to include in the PEX file (including all transitive dependencies).

  • preload_deps (defaults to []) #

    A list of C/C++ library dependencies that need to be loaded before any other libraries when the python binary starts up. This requires dynamic loader support found on most systems (e.g. `LD_PRELOAD`).

  • package_style (defaults to None) #

    Used to override the global packaging style set with python.package_style.

  • linker_flags (defaults to []) #

    Additional linker flags that should be applied to any links which are specific to this rule. Note that whether these flags are used are dependent on the native link strategy selected in `.buckconfig` and currently only applies to the `MERGED` link strategy, as the `SEPARATE` link strategy pulls in shared libraries linked in the context of their owning rule (e.g. `cxx_library`).

  • visibility (defaults to []) #

    List of build target patterns that identify the build rules that can include this rule in its deps.

  • licenses (defaults to []) #

    Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query.

  • labels (defaults to []) #

    Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using buck query attrfilter.

Examples

python_binary(
  name = 'tailer',
  main_module = 'tailer',
  deps = [
    ':tailerutils',
  ],
)

python_library(
  name = 'tailerutils',
  # tailer.py, the main module, should be specified here.
  srcs = glob(['*.py']),
)

Here is an example of using the `platform` parameter to select the "py2" Python platform as defined in `.buckconfig`:

; .buckconfig
[python#py2]
  interpreter = /usr/bin/python2.7
# BUCK
python_binary(
  name = 'bin',
  platform = 'py2',
  main_module = 'main',
  deps = [
    ':bar',
  ],
)
::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::