4
4
from distutils .dist import Distribution as DistDistribution
5
5
from setuptools .dist import Distribution
6
6
7
+ try :
8
+ from wheel .bdist_wheel import bdist_wheel
9
+ wheel = True
10
+ except :
11
+ wheel = False
12
+
7
13
8
14
def monkey_patch_dist (build_ext ):
9
15
# allow to use 'rust_extensions' parameter for setup() call
@@ -57,7 +63,9 @@ def finalize_options(self):
57
63
ep_scripts = self .distribution .entry_points .get (
58
64
'console_scripts' )
59
65
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 )
61
69
else :
62
70
ep_scripts = scripts
63
71
@@ -73,6 +81,37 @@ def finalize_options(self):
73
81
74
82
install .finalize_options = finalize_options
75
83
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
+
76
115
# clean rust project
77
116
def run_clean (self ):
78
117
self .orig_run ()
0 commit comments