Skip to content

Commit

Permalink
Python 3 **and 2** compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Technologicat committed Apr 25, 2017
1 parent a7c17d4 commit e3b17c6
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

from __future__ import division, print_function, absolute_import

import os

# remove file, ignore error if it did not exist
#
# portable version for Python 2.7 and 3.x
#
def myremove(filename):
try:
exc = FileNotFoundError # this does not exist in Python 2.7
except:
exc = OSError

try:
os.remove( redirect_name )
except exc:
pass


#########################################################
# Config
#########################################################
Expand All @@ -24,8 +42,6 @@
if sys.version_info < (2,7):
sys.exit('Sorry, Python < 2.7 is not supported')

import os

from setuptools import setup
from setuptools.extension import Extension

Expand All @@ -45,10 +61,7 @@

# remove existing symlink or file if any
#
try:
os.remove( redirect_name )
except FileNotFoundError:
pass
myremove( redirect_name )

# symlink correct file depending on Python version
#
Expand Down Expand Up @@ -259,8 +272,5 @@ def ext_math(extName):

# remove symlink created earlier
#
try:
os.remove( redirect_name )
except FileNotFoundError:
pass
myremove( redirect_name )

0 comments on commit e3b17c6

Please sign in to comment.