aboutsummaryrefslogtreecommitdiff
path: root/ldcg-python-manylinux-tensorflow/ansible/roles/tensorflow/tasks/manylinux-build.yml
blob: 637b8c729d351fd153cbb466b17d84ecb942ed17 (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
- name: copy upper constraints
  template:
    src: "files/upper-constraints.txt"
    dest: "{{ wheels_dir }}/upper-constraints.txt"
    mode: 0400
    force: true

- name: create {{ py_ver }} virtualenv
  include_role:
    name: python
    tasks_from: virtualenv.yml

- name: build and install wheels of binary Python packages
  include_role:
    name: python
    tasks_from: wheel.yml
  loop:
    - grpcio
    - "numpy{{ numpy_version }}"
    - "h5py{{ h5py_version }}"
    - Keras_Applications
    - Keras_Preprocessing
  loop_control:
    loop_var: wheel_name

- name: remove TensorFlow {{ tensorflow_version }} sources from previous build
  file:
    path: "{{ build_dir }}/tensorflow-{{ tensorflow_version }}/"
    state: absent

- include: fetch.yml

- name: build TensorFlow {{ tensorflow_version }}  # noqa no-changed-when
  shell:
    cmd: |
      set -xe
      source {{ virtualenv_path }}/bin/activate
      expect configure_tensorflow
      bazel clean --expunge
      export BAZEL_LINKLIBS=-l%:libstdc++.a
      bazel build --config=noaws --config=nogcp --config=nonccl \
            //tensorflow/tools/pip_package:build_pip_package --verbose_failures
      mkdir tensorflow-pkg
      bazel-bin/tensorflow/tools/pip_package/build_pip_package --cpu ./tensorflow-pkg
    chdir: "{{ build_dir }}/tensorflow-{{ tensorflow_version }}/"
    executable: /bin/bash

- name: stop bazel server
  include_role:
    name: bazel
    tasks_from: stop.yml

- name: get list of wheel files
  find:
    path: "{{ build_dir }}/tensorflow-{{ tensorflow_version }}/tensorflow-pkg/"
    patterns: "tensorflow_*.whl"
    file_type: file
  register: wheel_files

- name: get filename of latest wheel
  set_fact:
    wheel_file: "{{ wheel_files.files | sort(attribute='mtime') | last }}"

- name: install Python package
  pip:
    name: "{{ wheel_file.path }}"
    virtualenv: "{{ virtualenv_path }}"
    virtualenv_python: "/opt/python/{{ py_ver }}/bin/python3"
    extra_args: "--extra-index-url {{ pip_extra_index_url }}"

- name: copy resulting wheel
  copy:
    src: "{{ wheel_file.path }}"
    dest: "{{ wheels_dir }}"
    mode: 0666