Skip to content

Commit

Permalink
simplify my_build_ext and make it work for non top-level extensions
Browse files Browse the repository at this point in the history
get_ext_fullname() does give us src_path without any need to tinker
with modpath. build_extension always returns None.
  • Loading branch information
schmir committed Jan 19, 2012
1 parent 7b13952 commit bd29a4b
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions my_build_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ def symlink_or_copy(src, dst):
class build_ext(_build_ext):
def build_extension(self, ext):
self.inplace = 0
result = _build_ext.build_extension(self, ext)
modpath = self.get_ext_fullname(ext.name).split('.')
_build_ext.build_extension(self, ext)
filename = self.get_ext_filename(ext.name)
filename = os.path.split(filename)[-1]
filename = os.path.join(*modpath[:-1] + [filename])
build_path = os.path.abspath(os.path.join(self.build_lib, filename))
src_path = os.path.abspath(os.path.basename(build_path))
src_path = os.path.abspath(filename)
if build_path != src_path:
try:
os.unlink(src_path)
Expand All @@ -41,5 +38,3 @@ def build_extension(self, ext):
sys.stderr.write('Linking %s to %s\n' % (build_path, src_path))

symlink_or_copy(build_path, src_path)

return result

0 comments on commit bd29a4b

Please sign in to comment.