1+ """
2+ The operations in this file are designed for development and testing only.
3+ """
4+
5+
16from setuptools import setup , find_packages
27import distutils .log
38import importlib
4- from pathlib import Path
59
610
711def _extract_module (mod ):
@@ -24,19 +28,21 @@ class ExampleCommand(distutils.cmd.Command):
2428 ]
2529
2630 def initialize_options (self ):
31+ from pathlib import Path
2732 """Set default values for options."""
2833 # Each user option must be listed here with their default value.
2934 self .examples = filter (lambda x : not x .name .startswith ('_' ),
3035 list (Path ('./examples' ).resolve ().glob ('*.py' )))
3136
3237 def _check_ex_path (self , ex ):
38+ from pathlib import Path
3339 file = Path (ex )
3440 if not file .suffix :
3541 file = file .with_suffix ('.py' )
3642 file = (Path ('./examples' ) / file ).resolve ()
3743
3844 assert file .is_file (), ('Invalid example %s' % file )
39- return file . with_suffix ( '' )
45+ return file
4046
4147 def finalize_options (self ):
4248 """Post-process options."""
@@ -59,6 +65,40 @@ def run(self):
5965 print (traceback .format_exc ())
6066
6167
68+ class ZipCommand (distutils .cmd .Command ):
69+ """A custom command to create a minimal zip distribution."""
70+
71+ description = 'create a minimal pyrasterframes source zip file'
72+ user_options = []
73+
74+ def initialize_options (self ):
75+ pass
76+
77+ def finalize_options (self ):
78+ pass
79+
80+ def run (self ):
81+ """Create the zip."""
82+ import zipfile
83+ from pathlib import Path
84+ import os
85+ zfile = 'pyrasterframes.zip'
86+
87+ if os .path .isfile (zfile ):
88+ os .remove (zfile )
89+ with zipfile .ZipFile (zfile , 'w' ) as przip :
90+ przip .write ('pyrasterframes' )
91+ # Bring in source files and readme
92+ patterns = ['*.py' , '*.rst' , '*.jar' ]
93+ root = Path ('.' ).resolve ()
94+ for pattern in patterns :
95+ for file in list (root .glob ('pyrasterframes/' + pattern )):
96+ przip .write (str (file .relative_to (root )))
97+ # Put a copy of the license in the zip
98+ przip .write ('LICENSE.md' , 'pyrasterframes/LICENSE.md' )
99+
100+
101+
62102
63103
64104with open ('README.rst' ) as f :
@@ -75,31 +115,33 @@ def run(self):
75115 author = 'Simeon H.K. Fitch' ,
7611677117 license = 'Apache 2' ,
78- setup_requires = ['pytest-runner' , pyspark_ver ],
118+ setup_requires = ['pytest-runner' , pyspark_ver , 'pathlib' ],
79119 install_requires = [
80- pyspark_ver ,
120+ # pyspark_ver,
121+ # 'pathlib'
81122 ],
82123 tests_require = [
83124 pyspark_ver ,
84125 'pytest==3.4.2'
85126 ],
86127 test_suite = "pytest-runner" ,
87- packages = [ '.' ] + find_packages (exclude = ['tests' ]),
128+ packages = find_packages (exclude = ['tests' , 'examples ' ]),
88129 include_package_data = True ,
89- package_data = {'.' :['LICENSE' , 'static/* ' ]},
90- exclude_package_data = {'.' :['setup.cfg ' ]},
130+ package_data = {'.' :['LICENSE.md' ] , 'pyrasterframes' :[ '*.jar ' ]},
131+ exclude_package_data = {'.' :['setup.*' , 'README.* ' ]},
91132 classifiers = [
92133 'Development Status :: 3 - Alpha' ,
93134 'Environment :: Other Environment' ,
94135 'License :: OSI Approved :: Apache Software License' ,
95136 'Natural Language :: English' ,
96137 'Operating System :: Unix' ,
97- 'Programming Language :: Python :: 3 :: Only ' ,
138+ 'Programming Language :: Python' ,
98139 'Topic :: Software Development :: Libraries'
99140 ],
100141 zip_safe = False ,
101142 cmdclass = {
102- 'examples' : ExampleCommand
143+ 'examples' : ExampleCommand ,
144+ 'minzip' : ZipCommand
103145 }
104146 # entry_points={
105147 # "console_scripts": ['pyrasterframes=pyrasterframes:console']
0 commit comments