@@ -47,11 +47,11 @@ def initialize_options(self):
4747
4848 def finalize_options (self ):
4949 pass
50-
50+
5151 def _unpack_linux (self , filename , targetfolder ):
52-
52+
5353 assert platform .architecture ()[0 ] == "64bit" , "Downloaded linux pandoc is only compiled for 64bit."
54-
54+
5555 print ("* Unpacking %s to tempfolder..." % (filename ))
5656
5757 tempfolder = tempfile .mkdtemp ()
@@ -77,7 +77,7 @@ def _unpack_linux(self, filename, targetfolder):
7777 finally :
7878 os .chdir (cur_wd )
7979 shutil .rmtree (tempfolder )
80-
80+
8181 def _unpack_darwin (self , filename , targetfolder ):
8282 print ("* Unpacking %s to tempfolder..." % (filename ))
8383
@@ -124,6 +124,7 @@ def _unpack_win32(self, filename, targetfolder):
124124 shutil .rmtree (tempfolder )
125125 print ("* Done." )
126126
127+
127128 def run (self ):
128129 pf = sys .platform
129130 # compatibility with py3
@@ -144,7 +145,7 @@ def run(self):
144145 response = urlopen (url )
145146 with open (filename , 'wb' ) as out_file :
146147 shutil .copyfileobj (response , out_file )
147-
148+
148149 targetfolder = os .path .join (os .path .dirname (os .path .realpath (__file__ )), "pypandoc" , "files" )
149150
150151 # Make sure target folder exists...
@@ -154,7 +155,7 @@ def run(self):
154155 pass # dir already exists...
155156
156157 unpack = getattr (self , "_unpack_" + pf )
157-
158+
158159 unpack (filename , targetfolder )
159160
160161
@@ -165,22 +166,48 @@ def run(self):
165166# binaries.
166167if (os .path .isfile (os .path .join ("pypandoc" , "files" , "pandoc" )) or
167168 os .path .isfile (os .path .join ("pypandoc" , "files" , "pandoc.exe" ))):
168-
169+ print ( "Patching wheel building..." )
169170 try :
170171 from wheel .bdist_wheel import bdist_wheel
171172 except ImportError :
172173 # No wheel installed, so we also can't run that command...
173174 pass
174175 else :
176+ # these imports should fail as our our later functions relies on it...
177+ from wheel .bdist_wheel import (get_platform , get_abbr_impl ,
178+ get_impl_ver , pep425tags , sysconfig )
179+ print ("Making sure that wheel is platform specific..." )
175180 class new_bdist_wheel (bdist_wheel ):
181+ def get_tag (self ):
182+ # originally get_tag would branch for 'root_is_pure" and return
183+ # tags suitable for wheels running on any py3/py2 system. So
184+ # setting the attribute in finalize_options was enough. But
185+ # In the 3.5 instead of the attribute,
186+ # self.distribution.is_pure() is called, so we have to overwrite
187+ # the complete functions...
188+
189+ supported_tags = pep425tags .get_supported ()
190+ plat_name = self .plat_name
191+ if plat_name is None :
192+ plat_name = get_platform ()
193+ plat_name = plat_name .replace ('-' , '_' ).replace ('.' , '_' )
194+ impl_name = get_abbr_impl ()
195+ impl_ver = get_impl_ver ()
196+ # PEP 3149 -- no SOABI in Py 2
197+ # For PyPy?
198+ # "pp%s%s" % (sys.pypy_version_info.major,
199+ # sys.pypy_version_info.minor)
200+ abi_tag = sysconfig .get_config_vars ().get ('SOABI' , 'none' )
201+ if abi_tag .startswith ('cpython-' ):
202+ abi_tag = 'cp' + abi_tag .rsplit ('-' , 1 )[- 1 ]
203+
204+ tag = (impl_name + impl_ver , abi_tag , plat_name )
205+ # XXX switch to this alternate implementation for non-pure:
206+ assert tag == supported_tags [0 ]
207+ return tag
176208 def finalize_options (self ):
177209 bdist_wheel .finalize_options (self )
178- # this turns on the proper filenames
179- self .root_is_pure = False
180- # in the orig finalize_options this is set to:
181- # self.root_is_pure = not (self.distribution.has_ext_modules()
182- # or self.distribution.has_c_libraries())
183-
210+ assert "any" not in self .get_archive_basename (), "bdist_wheel will not generate platform specific names, aborting!"
184211 cmd_classes ["bdist_wheel" ] = new_bdist_wheel
185212
186213module = pypandoc
0 commit comments