setup.py 3.05 KB
Newer Older
Hongkun Yu's avatar
Hongkun Yu committed
1
# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Hongkun Yu's avatar
Hongkun Yu committed
2
3
4
5
6
7
8
9
10
11
12
13
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Hongkun Yu's avatar
Hongkun Yu committed
14

Hongkun Yu's avatar
Hongkun Yu committed
15
"""Sets up TensorFlow Official Models."""
Chen Chen's avatar
Chen Chen committed
16
import datetime
Chen Chen's avatar
Chen Chen committed
17
import os
Chen Chen's avatar
Chen Chen committed
18
19
import sys

Hongkun Yu's avatar
Hongkun Yu committed
20
21
22
from setuptools import find_packages
from setuptools import setup

23
version = '2.7.0'
24
tf_version = '2.7.0'  # Major version.
Chen Chen's avatar
Chen Chen committed
25
26
27

project_name = 'tf-models-official'

Chen Chen's avatar
Chen Chen committed
28
29
30
31
32
33
long_description = """The TensorFlow official models are a collection of
models that use TensorFlow's high-level APIs.
They are intended to be well-maintained, tested, and kept up to date with the
latest TensorFlow API. They should also be reasonably optimized for fast
performance while still being easy to read."""

Chen Chen's avatar
Chen Chen committed
34
35
36
37
38
39
if '--project_name' in sys.argv:
  project_name_idx = sys.argv.index('--project_name')
  project_name = sys.argv[project_name_idx + 1]
  sys.argv.remove('--project_name')
  sys.argv.pop(project_name_idx)

Chen Chen's avatar
Chen Chen committed
40
41
42
43
44
45
46
47
48

def _get_requirements():
  """Parses requirements.txt file."""
  install_requires_tmp = []
  dependency_links_tmp = []
  with open(
      os.path.join(os.path.dirname(__file__), '../requirements.txt'), 'r') as f:
    for line in f:
      package_name = line.strip()
Chen Chen's avatar
Chen Chen committed
49
50
51
      # Skip empty line or comments starting with "#".
      if not package_name or package_name[0] == '#':
        continue
Chen Chen's avatar
Chen Chen committed
52
53
54
55
56
57
58
59
      if package_name.startswith('-e '):
        dependency_links_tmp.append(package_name[3:].strip())
      else:
        install_requires_tmp.append(package_name)
  return install_requires_tmp, dependency_links_tmp

install_requires, dependency_links = _get_requirements()

Chen Chen's avatar
Chen Chen committed
60
if project_name == 'tf-models-nightly':
Chen Chen's avatar
Chen Chen committed
61
  version += '.dev' + datetime.datetime.now().strftime('%Y%m%d')
Chen Chen's avatar
Chen Chen committed
62
  install_requires.append('tf-nightly')
63
  install_requires.append('tensorflow-text-nightly')
Chen Chen's avatar
Chen Chen committed
64
else:
65
66
  install_requires.append(f'tensorflow~={tf_version}')
  install_requires.append(f'tensorflow-text~={tf_version}')
Chen Chen's avatar
Chen Chen committed
67
68
69

print('install_requires: ', install_requires)
print('dependency_links: ', dependency_links)
Chen Chen's avatar
Chen Chen committed
70

Hongkun Yu's avatar
Hongkun Yu committed
71
setup(
Chen Chen's avatar
Chen Chen committed
72
73
    name=project_name,
    version=version,
Hongkun Yu's avatar
Hongkun Yu committed
74
    description='TensorFlow Official Models',
Chen Chen's avatar
Chen Chen committed
75
    long_description=long_description,
Hongkun Yu's avatar
Hongkun Yu committed
76
77
78
79
    author='Google Inc.',
    author_email='no-reply@google.com',
    url='https://github.com/tensorflow/models',
    license='Apache 2.0',
Chen Chen's avatar
Chen Chen committed
80
81
82
83
    packages=find_packages(exclude=[
        'research*',
        'official.pip_package*',
        'official.benchmark*',
84
        'official.colab*',
85
        'official.recommendation.ranking.data.preprocessing*',
Chen Chen's avatar
Chen Chen committed
86
    ]),
Hongkun Yu's avatar
Hongkun Yu committed
87
    exclude_package_data={
Chen Chen's avatar
Chen Chen committed
88
89
        '': ['*_test.py',],
    },
Chen Chen's avatar
Chen Chen committed
90
91
    install_requires=install_requires,
    dependency_links=dependency_links,
92
    python_requires='>=3.7',
Hongkun Yu's avatar
Hongkun Yu committed
93
)