Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / tools / telemetry / third_party / gsutilz / setup.py
blob187a721fbf205dfd979f4c8befdebc0725571fde
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright 2011 Google Inc. All Rights Reserved.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 """Setup installation module for gsutil."""
19 import os
21 from setuptools import find_packages
22 from setuptools import setup
23 from setuptools.command import build_py
24 from setuptools.command import sdist
26 long_desc = """
27 gsutil is a Python application that lets you access Google Cloud Storage from
28 the command line. You can use gsutil to do a wide range of bucket and object
29 management tasks, including:
30 * Creating and deleting buckets.
31 * Uploading, downloading, and deleting objects.
32 * Listing buckets and objects.
33 * Moving, copying, and renaming objects.
34 * Editing object and bucket ACLs.
35 """
37 requires = [
38 'boto==2.38.0',
39 'crcmod>=1.7',
40 'gcs-oauth2-boto-plugin>=1.9',
41 'google-apitools==0.4.8',
42 'httplib2>=0.8',
43 'oauth2client>=1.4.11',
44 'protorpc>=0.10.0',
45 'pyOpenSSL>=0.13',
46 'python-gflags>=2.0',
47 'retry_decorator>=1.0.0',
48 'six>=1.8.0',
49 # Not using 1.02 because of:
50 # https://code.google.com/p/socksipy-branch/issues/detail?id=3
51 'SocksiPy-branch==1.01',
54 dependency_links = [
55 # Note: this commit ID should be kept in sync with the 'third_party/boto'
56 # entry in 'git submodule status'.
57 # pylint: disable=line-too-long
58 'https://github.com/boto/boto/archive/cb8aeec987ddcd5fecd206e38777b9a15cb0bcab.tar.gz#egg=boto-2.38.0',
61 CURDIR = os.path.abspath(os.path.dirname(__file__))
62 BOTO_DIR = os.path.join(CURDIR, 'third_party', 'boto')
64 with open(os.path.join(CURDIR, 'VERSION'), 'r') as f:
65 VERSION = f.read().strip()
67 with open(os.path.join(CURDIR, 'CHECKSUM'), 'r') as f:
68 CHECKSUM = f.read()
71 def PlaceNeededFiles(self, target_dir):
72 """Populates necessary files into the gslib module and unit test modules."""
73 target_dir = os.path.join(target_dir, 'gslib')
74 self.mkpath(target_dir)
76 # Copy the gsutil root VERSION file into gslib module.
77 with open(os.path.join(target_dir, 'VERSION'), 'w') as fp:
78 fp.write(VERSION)
80 # Copy the gsutil root CHECKSUM file into gslib module.
81 with open(os.path.join(target_dir, 'CHECKSUM'), 'w') as fp:
82 fp.write(CHECKSUM)
84 # Copy the Boto test module required by gsutil unit tests.
85 tests_dir = os.path.join(target_dir, 'tests')
86 self.mkpath(tests_dir)
87 mock_storage_dst = os.path.join(tests_dir, 'mock_storage_service.py')
88 mock_storage_src1 = os.path.join(
89 BOTO_DIR, 'tests', 'integration', 's3', 'mock_storage_service.py')
90 mock_storage_src2 = os.path.join(
91 CURDIR, 'gslib', 'tests', 'mock_storage_service.py')
92 mock_storage_src = (
93 mock_storage_src1
94 if os.path.isfile(mock_storage_src1) else mock_storage_src2)
95 if not os.path.isfile(mock_storage_src):
96 raise Exception('Unable to find required boto test source file at %s or %s.'
97 % (mock_storage_src1, mock_storage_src2))
98 with open(mock_storage_src, 'r') as fp:
99 mock_storage_contents = fp.read()
100 with open(mock_storage_dst, 'w') as fp:
101 fp.write('#\n'
102 '# This file was copied during gsutil package generation from\n'
103 '# the Boto test suite, originally located at:\n'
104 '# tests/integration/s3/mock_storage_service.py\n'
105 '# DO NOT MODIFY\n'
106 '#\n\n')
107 fp.write(mock_storage_contents)
110 class CustomBuildPy(build_py.build_py):
111 """Excludes update command from package-installed versions of gsutil."""
113 def byte_compile(self, files):
114 for filename in files:
115 # Note: we exclude the update command here because binary distributions
116 # (built via setup.py bdist command) don't abide by the MANIFEST file.
117 # For source distributions (built via setup.py sdist), the update command
118 # will be excluded by the MANIFEST file.
119 if 'gslib/commands/update.py' in filename:
120 os.unlink(filename)
121 build_py.build_py.byte_compile(self, files)
123 def run(self):
124 if not self.dry_run:
125 PlaceNeededFiles(self, self.build_lib)
126 build_py.build_py.run(self)
129 class CustomSDist(sdist.sdist):
131 def make_release_tree(self, base_dir, files):
132 sdist.sdist.make_release_tree(self, base_dir, files)
133 PlaceNeededFiles(self, base_dir)
136 setup(
137 name='gsutil',
138 version=VERSION,
139 url='https://developers.google.com/storage/docs/gsutil',
140 download_url='https://developers.google.com/storage/docs/gsutil_install',
141 license='Apache 2.0',
142 author='Google Inc.',
143 author_email='gs-team@google.com',
144 description=('A command line tool for interacting with cloud storage '
145 'services.'),
146 long_description=long_desc,
147 zip_safe=True,
148 classifiers=[
149 'Development Status :: 5 - Production/Stable',
150 'Environment :: Console',
151 'Intended Audience :: Developers',
152 'Intended Audience :: System Administrators',
153 'License :: OSI Approved :: Apache Software License',
154 'Natural Language :: English',
155 'Topic :: System :: Filesystems',
156 'Topic :: Utilities',
158 platforms='any',
159 packages=find_packages(exclude=['third_party']),
160 include_package_data=True,
161 entry_points={
162 'console_scripts': [
163 'gsutil = gslib.__main__:main',
166 install_requires=requires,
167 dependency_links=dependency_links,
168 cmdclass={
169 'build_py': CustomBuildPy,
170 'sdist': CustomSDist,