1- try : 
2-      from   setuptools   import  setup ,  find_packages 
3- except   ImportError : 
4-      from   ez_setup   import  use_setuptools 
5-      use_setuptools () 
6-      from  setuptools  import  setup , find_packages 
1+ # Template by setupmobans 
2+ import  os 
3+ import   sys 
4+ import  codecs 
5+ from   shutil   import   rmtree 
6+ from  setuptools  import  setup , find_packages ,  Command 
77
88NAME  =  'pyexcel-odsr' 
99AUTHOR  =  'C.W.' 
10- VERSION  =  '0.5.0 ' 
10+ VERSION  =  '0.5.1 ' 
11111212LICENSE  =  'New BSD' 
1313DESCRIPTION  =  (
1616    '' 
1717)
1818URL  =  'https://github.com/pyexcel/pyexcel-odsr' 
19- DOWNLOAD_URL  =  '%s/archive/0.5.0 .tar.gz'  %  URL 
20- FILES  =  ['README.rst' , 'CONTRIBUTORS.rst' , 'CHANGELOG.rst' ]
19+ DOWNLOAD_URL  =  '%s/archive/0.5.1 .tar.gz'  %  URL 
20+ FILES  =  ['README.rst' ,   'CONTRIBUTORS.rst' , 'CHANGELOG.rst' ]
2121KEYWORDS  =  [
2222    'excel' ,
2323    'ods' ,
4848PACKAGES  =  find_packages (exclude = ['ez_setup' , 'examples' , 'tests' ])
4949EXTRAS_REQUIRE  =  {
5050}
51+ PUBLISH_COMMAND  =  '{0} setup.py sdist bdist_wheel upload -r pypi' .format (
52+     sys .executable )
53+ GS_COMMAND  =  ('gs pyexcel-odsr v0.5.1 '  + 
54+               "Find 0.5.1 in changelog for more details" )
55+ here  =  os .path .abspath (os .path .dirname (__file__ ))
56+ 
57+ 
58+ class  PublishCommand (Command ):
59+     """Support setup.py upload.""" 
60+ 
61+     description  =  'Build and publish the package on github and pypi' 
62+     user_options  =  []
63+ 
64+     @staticmethod  
65+     def  status (s ):
66+         """Prints things in bold.""" 
67+         print ('\033 [1m{0}\033 [0m' .format (s ))
68+ 
69+     def  initialize_options (self ):
70+         pass 
71+ 
72+     def  finalize_options (self ):
73+         pass 
74+ 
75+     def  run (self ):
76+         try :
77+             self .status ('Removing previous builds...' )
78+             rmtree (os .path .join (here , 'dist' ))
79+         except  OSError :
80+             pass 
81+ 
82+         self .status ('Building Source and Wheel (universal) distribution...' )
83+         if  os .system (GS_COMMAND ) ==  0 :
84+             os .system (PUBLISH_COMMAND )
85+ 
86+         sys .exit ()
5187
5288
5389def  read_files (* files ):
@@ -61,7 +97,7 @@ def read_files(*files):
6197
6298def  read (afile ):
6399    """Read a file into setup""" 
64-     with  open (afile , 'r' ) as  opened_file :
100+     with  codecs . open (afile , 'r'  ,  'utf-8 ' ) as  opened_file :
65101        content  =  filter_out_test_code (opened_file )
66102        content  =  "" .join (list (content ))
67103        return  content 
@@ -109,5 +145,9 @@ def filter_out_test_code(file_handle):
109145        packages = PACKAGES ,
110146        include_package_data = True ,
111147        zip_safe = False ,
112-         classifiers = CLASSIFIERS 
148+         classifiers = CLASSIFIERS ,
149+         setup_requires = ['gease' ],
150+         cmdclass = {
151+             'publish' : PublishCommand ,
152+         }
113153    )
0 commit comments