1+ # Copyright 2016 Google Inc.
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ """Make a hacked PTH file to simulate "setup.py develop"."""
16+
117import argparse
218import json
319import os
@@ -31,6 +47,9 @@ def fake_core_dist_info(site_packages):
3147 """Fake the dist. info of google-cloud-core.
3248
3349 It needs to be faked since we don't actually install it.
50+
51+ :type site_packages: str
52+ :param site_packages: Path to a site packages directory.
3453 """
3554 dist_info = os .path .join (site_packages , CORE_DIST_INFO )
3655 if not os .path .isdir (dist_info ):
@@ -42,7 +61,11 @@ def fake_core_dist_info(site_packages):
4261
4362
4463def add_hacked_pth_file (site_packages ):
45- """Add the hacked .PTH file to the site packages dir."""
64+ """Add the hacked .PTH file to the site packages dir.
65+
66+ :type site_packages: str
67+ :param site_packages: Path to a site packages directory.
68+ """
4669 installer = namespaces .Installer ()
4770 part1 = installer ._gen_nspkg_line ('google' )
4871 part2 = EXTRA_PATH_TEMPLATE .format (
@@ -60,16 +83,18 @@ def add_hacked_pth_file(site_packages):
6083 file_obj .write (file_contents )
6184
6285
63- def main (site_packages ):
64- add_hacked_pth_file (site_packages )
65- fake_core_dist_info (site_packages )
66-
67-
68- if __name__ == '__main__' :
86+ def main ():
87+ """Main script for making a hacked PTH file."""
6988 parser = argparse .ArgumentParser (
7089 description = 'Make a hacked PTH file to emulate "setup.py develop"' )
7190 help_txt = 'Site packages directory where .pth file will be added.'
7291 parser .add_argument ('--site-packages' , dest = 'site_packages' ,
7392 required = True , help = help_txt )
7493 args = parser .parse_args ()
75- main (args .site_packages )
94+
95+ add_hacked_pth_file (args .site_packages )
96+ fake_core_dist_info (args .site_packages )
97+
98+
99+ if __name__ == '__main__' :
100+ main ()
0 commit comments