Skip to content

Commit

Permalink
merge cxhernandez's amperka#261 'py3 compatibility'
Browse files Browse the repository at this point in the history
  • Loading branch information
amoose136 committed Jan 17, 2019
1 parent 7328145 commit e3deb5e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 19 deletions.
33 changes: 16 additions & 17 deletions ino/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import sys
import os.path
import fnmatch
import functools
import platform

from ino.utils import FileMap, SpaceList
Expand All @@ -25,12 +24,12 @@ def __str__(self):
return self.filename


def filter(f):
def _filter(f):
f.filter = True
return f


@filter
@_filter
def glob(dir, *patterns, **kwargs):
recursive = kwargs.get('recursive', True)
subdir = kwargs.get('subdir', '')
Expand All @@ -52,7 +51,7 @@ def glob(dir, *patterns, **kwargs):
return result


@filter
@_filter
def pjoin(base, *parts):
return os.path.join(str(base), *map(str, parts))

Expand All @@ -63,41 +62,41 @@ def xname(filepath, basename_fmt):
return os.path.join(head, basename_fmt % basename)


@filter
@_filter
def objname(filepath):
return xname(filepath, '%s.o')


@filter
@_filter
def libname(filepath):
return xname(filepath, 'lib%s.a')


@filter
@_filter
def depsname(filepath):
return xname(filepath, '%s.d')


basename = filter(os.path.basename)
dirname = filter(os.path.dirname)
relative_to = filter(os.path.relpath)
basename = _filter(os.path.basename)
dirname = _filter(os.path.dirname)
relative_to = _filter(os.path.relpath)


@filter
@_filter
def filemap(sources, target_dir, rename_rule):
return FileMap((source, GlobFile(xname(source, rename_rule), target_dir))
return FileMap((source, GlobFile(xname(source, rename_rule), target_dir))
for source in sources)

@filter
@_filter
def libmap(source_dirs, target_dir):
return FileMap((
source_dir,
GlobFile(libname(basename(source_dir)),
source_dir,
GlobFile(libname(basename(source_dir)),
pjoin(target_dir, basename(source_dir))))
for source_dir in source_dirs)


@filter
@_filter
def colorize(s, color):
if platform.system() == 'Windows':
return s
Expand All @@ -115,7 +114,7 @@ def colorize(s, color):
}

return ''.join([
'\033[', ccodes[color], 'm',
'\033[', ccodes[color], 'm',
s,
'\033[0m'
])
14 changes: 12 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@
install_requires = open("requirements.txt").read().split('\n')
readme_content = open("README.rst").read()

extra = {}
if sys.version_info >= (3, 0):
extra.update(
use_2to3=True,
)


def gen_data_files(package_dir, subdir):
import os.path
results = []
for root, dirs, files in os.walk(os.path.join(package_dir, subdir)):
results.extend([os.path.join(root, f)[len(package_dir)+1:] for f in files])
results.extend([os.path.join(root, f)[len(package_dir)+1:]
for f in files])
return results

ino_package_data = gen_data_files('ino', 'make') + gen_data_files('ino', 'templates')
ino_package_data = (gen_data_files('ino', 'make') +
gen_data_files('ino', 'templates'))

# Look for install and --record install_*.txt file into argument for
# installation record
Expand Down Expand Up @@ -77,4 +86,5 @@ def gen_data_files(package_dir, subdir):
"Programming Language :: Python",
"Topic :: Software Development :: Embedded Systems",
],
**extra
)

0 comments on commit e3deb5e

Please sign in to comment.