Skip to content

Commit 6ef3686

Browse files
committed
fix console entries for bdist_wheel command
1 parent 68b21b4 commit 6ef3686

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

CHANGES.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGES
22
^^^^^^^
33

4+
0.8.2 (2017-09-08)
5+
------------------
6+
7+
- Fix script generation for bdist_wheel
8+
9+
410
0.8.1 (2017-09-08)
511
------------------
612

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import setup
22

3-
version = '0.8.1'
3+
version = '0.8.2'
44

55

66
setup(

setuptools_rust/patch.py

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
from distutils.dist import Distribution as DistDistribution
55
from 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

814
def 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

Comments
 (0)