11import argparse
2+ import atexit
23import glob
34import os
45import sys
56from setuptools import setup
7+ from setuptools .command .install import install
8+ from setuptools .dist import Distribution
69from datetime import datetime
710
811from Cython .Build import cythonize
2326VERSION = f'''{ THE_TIME .year } .{ THE_TIME .month } .{ THE_TIME .day } ''' \
2427 f'''{ THE_TIME .hour * 3600 + THE_TIME .minute * 60 + THE_TIME .second } '''
2528
29+ def _post_install (* args ):
30+ bdist_wheel_cmd = args [0 ].get_command_obj ('bdist_wheel' )
31+ tag = '-' .join (bdist_wheel_cmd .get_tag ())
32+ os .system (f'python -m pip install --force-reinstall ./dist/{ bdist_wheel_cmd .wheel_dist_name } -{ tag } .whl' )
33+ class new_install (install ):
34+ def __init__ (self , * args , ** kwargs ):
35+ super (new_install , self ).__init__ (* args , ** kwargs )
36+ atexit .register (_post_install , * args )
2637class BasePackagePatch_BuildExt (build_ext ):
2738 """ Create __init__.py for base package, after build
2839 """
@@ -91,10 +102,11 @@ def parse_cli_args(cls):
91102 clean = args .clean )
92103
93104 def compile (self ):
94- script_args = ['build' , '--build-base={0}' .format (self .build )]
105+ script_args = ['build' , '--build-base={0}' .format (self .build ), 'bdist_wheel' ]
95106
107+ cmds = dict (build_ext = BasePackagePatch_BuildExt )
96108 if self .install :
97- script_args . append ( 'install' )
109+ cmds [ 'install' ] = new_install
98110
99111 if self .force :
100112 script_args .append ('--force' )
@@ -108,7 +120,7 @@ def compile(self):
108120 version = VERSION ,
109121 ext_modules = cythonize (self ._pyx_files ,
110122 include_path = self .include_path ),
111- cmdclass = dict ( build_ext = BasePackagePatch_BuildExt ) ,
123+ cmdclass = cmds ,
112124 script_args = script_args )
113125
114126 def extend (self , dist ):
0 commit comments