|
| 1 | +import os.path |
| 2 | +import sys |
| 3 | + |
| 4 | +from distutils.core import setup |
| 5 | +from distutils.command.install_data import install_data |
| 6 | +from distutils.command.install_lib import install_lib |
| 7 | +from distutils.command.install_scripts import install_scripts |
| 8 | +from distutils.command.sdist import sdist |
| 9 | + |
| 10 | +# Find the install bin subdirectory: |
| 11 | +this_file = os.path.join(os.getcwd(), __file__) |
| 12 | +this_dir = os.path.abspath(os.path.dirname(this_file)) |
| 13 | +bin_dir = os.path.abspath(os.path.join(this_dir, 'bin')) |
| 14 | + |
| 15 | +# Now that we've found the bin subdirectory, inject it into the path: |
| 16 | +sys.path.insert(0, bin_dir) |
| 17 | + |
| 18 | +# Now we can import some weewx modules |
| 19 | +import weewx |
| 20 | +VERSION = weewx.__version__ |
| 21 | +import config_util |
| 22 | + |
| 23 | +#============================================================================== |
| 24 | +# sdist |
| 25 | +#============================================================================== |
| 26 | + |
| 27 | +class weewx_sdist(sdist): |
| 28 | + """Specialized version of sdist which checks for password information in |
| 29 | + the configuration file before creating the distribution. |
| 30 | +
|
| 31 | + For other sdist methods, see: |
| 32 | + http://epydoc.sourceforge.net/stdlib/distutils.command.sdist.sdist-class.html |
| 33 | + """ |
| 34 | + |
| 35 | + def copy_file(self, f, install_dir, **kwargs): |
| 36 | + """Specialized version of copy_file. |
| 37 | +
|
| 38 | + Return a tuple (dest_name, copied): 'dest_name' is the actual name of |
| 39 | + the output file, and 'copied' is true if the file was copied (or would |
| 40 | + have been copied, if 'dry_run' true).""" |
| 41 | + # If this is the configuration file, then check it for passwords |
| 42 | + if f == 'weewx.conf': |
| 43 | + import configobj |
| 44 | + config = configobj.ConfigObj(f) |
| 45 | + |
| 46 | + try: |
| 47 | + password = config['StdReport']['FTP']['password'] |
| 48 | + sys.exit("\n*** FTP password found in configuration file. Aborting ***\n\n") |
| 49 | + except KeyError: |
| 50 | + pass |
| 51 | + |
| 52 | + try: |
| 53 | + password = config['StdRESTful']['Wunderground']['password'] |
| 54 | + sys.exit("\n*** Wunderground password found in configuration file. Aborting ***\n\n") |
| 55 | + except KeyError: |
| 56 | + pass |
| 57 | + |
| 58 | + try: |
| 59 | + password = config['StdRESTful']['Wunderground']['password'] |
| 60 | + sys.exit("\n*** PWSweather password found in configuration file. Aborting ***\n\n") |
| 61 | + except KeyError: |
| 62 | + pass |
| 63 | + |
| 64 | + # Pass on to my superclass: |
| 65 | + return sdist.copy_file(self, f, install_dir, **kwargs) |
| 66 | + |
| 67 | +#============================================================================== |
| 68 | +# main entry point |
| 69 | +#============================================================================== |
| 70 | + |
| 71 | +if __name__ == "__main__": |
| 72 | + # now invoke the standard python setup |
| 73 | + setup(name='weewx', |
| 74 | + version=VERSION, |
| 75 | + description='weather software', |
| 76 | + long_description="weewx interacts with a weather station to produce graphs, " |
| 77 | + "reports, and HTML pages. weewx can upload data to services such as the " |
| 78 | + "WeatherUnderground, PWSweather.com, or CWOP.", |
| 79 | + author='Tom Keffer', |
| 80 | + |
| 81 | + url='http://www.weewx.com', |
| 82 | + license='GPLv3', |
| 83 | + classifiers=['Development Status :: 5 - Production/Stable', |
| 84 | + 'Intended Audience :: End Users/Desktop', |
| 85 | + 'License :: GPLv3', |
| 86 | + 'Operating System :: OS Independent', |
| 87 | + 'Programming Language :: Python', |
| 88 | + 'Programming Language :: Python :: 2', |
| 89 | + ], |
| 90 | + requires=['configobj(>=4.5)', |
| 91 | + 'serial(>=2.3)', |
| 92 | + 'Cheetah(>=2.0)', |
| 93 | + 'sqlite3(>=2.5)', |
| 94 | + 'PIL(>=1.1.6)'], |
| 95 | + provides=['weedb', |
| 96 | + 'weeplot', |
| 97 | + 'weeutil', |
| 98 | + 'weewx'], |
| 99 | + cmdclass = {"sdist" : weewx_sdist}, |
| 100 | +# cmdclass = {"install_data": weewx_install_data, |
| 101 | +# "install_lib": weewx_install_lib, |
| 102 | +# "sdist": weewx_sdist, |
| 103 | +# "install_scripts": weewx_install_scripts}, |
| 104 | + platforms=['any'], |
| 105 | + package_dir={'': 'bin'}, |
| 106 | + packages=['examples', |
| 107 | + 'schemas', |
| 108 | + 'user', |
| 109 | + 'weedb', |
| 110 | + 'weeplot', |
| 111 | + 'weeutil', |
| 112 | + 'weewx', |
| 113 | + 'weewx.drivers'], |
| 114 | + py_modules=['daemon'], |
| 115 | + scripts=['bin/wee_config_database', |
| 116 | + 'bin/wee_config_device', |
| 117 | + 'bin/weewxd', |
| 118 | + 'bin/wee_reports'], |
| 119 | + ) |
0 commit comments