44from distutils .dist import Distribution as DistDistribution
55from setuptools .dist import Distribution
66
7+ try :
8+ from wheel .bdist_wheel import bdist_wheel
9+ wheel = True
10+ except :
11+ wheel = False
12+
713
814def monkey_patch_dist (build_ext ):
915 # allow to use 'rust_extensions' parameter for setup() call
@@ -57,7 +63,9 @@ def finalize_options(self):
5763 ep_scripts = self .distribution .entry_points .get (
5864 'console_scripts' )
5965 if ep_scripts :
60- ep_scripts .extend (scripts )
66+ for script in scripts :
67+ if script not in ep_scripts :
68+ ep_scripts .append (scripts )
6169 else :
6270 ep_scripts = scripts
6371
@@ -73,6 +81,37 @@ def finalize_options(self):
7381
7482 install .finalize_options = finalize_options
7583
84+ if wheel :
85+ # this is for console entries
86+ bdist_wheel .orig_finalize_options = bdist_wheel .finalize_options
87+
88+ def finalize_options (self ):
89+ scripts = []
90+ for ext in self .distribution .rust_extensions :
91+ scripts .extend (ext .entry_points ())
92+
93+ if scripts :
94+ if not self .distribution .entry_points :
95+ self .distribution .entry_points = {
96+ 'console_scripts' : scripts ,
97+ }
98+ else :
99+ ep_scripts = self .distribution .entry_points .get (
100+ 'console_scripts' )
101+ if ep_scripts :
102+ for script in scripts :
103+ if script not in ep_scripts :
104+ ep_scripts .append (scripts )
105+ else :
106+ ep_scripts = scripts
107+
108+ self .distribution .entry_points [
109+ 'console_scripts' ] = ep_scripts
110+
111+ self .orig_finalize_options ()
112+
113+ bdist_wheel .finalize_options = finalize_options
114+
76115 # clean rust project
77116 def run_clean (self ):
78117 self .orig_run ()
0 commit comments