diff --git a/build.py b/build.py index 6e884c8..66e08b7 100644 --- a/build.py +++ b/build.py @@ -1,12 +1,16 @@ -import glob import os import subprocess -from itertools import chain +from pathlib import Path -armaclass_path = 'armaclass' +armaclass_path = Path('armaclass') types = ('*.html', '*.c', '*.cpp', '*.pyd', '*.so') -files_to_delete = chain(*(glob.glob(os.path.join(armaclass_path, file_type)) for file_type in types)) + +files_to_delete = [] +for file_type in types: + files_to_delete.extend(armaclass_path.glob(file_type)) + for file_path in files_to_delete: + print('Deleting', file_path) os.remove(file_path) subprocess.run('python setup_cython.py build_ext --inplace --force', shell=True, check=True) diff --git a/setup.py b/setup.py index 7c58fb0..c4c901b 100644 --- a/setup.py +++ b/setup.py @@ -1,13 +1,13 @@ import os import platform import sys +from pathlib import Path from setuptools import setup # read the contents of your README file -this_directory = os.path.abspath(os.path.dirname(__file__)) -with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f: - long_description = f.read() +this_directory = Path(__file__).parent +long_description = (this_directory / 'README.md').read_text(encoding='utf-8') ext_modules = None if not any(arg in sys.argv for arg in ['clean', 'check']) and \ @@ -23,7 +23,7 @@ compiler_directives['linetrace'] = True ext_modules = cythonize( - os.path.join('armaclass', 'parser.py'), + str(this_directory / 'armaclass' / 'parser.py'), language_level=3, compiler_directives=compiler_directives, ) diff --git a/setup_cython.py b/setup_cython.py index 8ec0562..8912ac6 100644 --- a/setup_cython.py +++ b/setup_cython.py @@ -1,10 +1,12 @@ -import os +from pathlib import Path -from setuptools import setup from Cython.Build import cythonize +from setuptools import setup + +this_directory = Path(__file__).parent setup( - ext_modules=cythonize(os.path.join('armaclass', 'parser.py'), + ext_modules=cythonize(str(this_directory / 'armaclass' / 'parser.py'), language_level=3, annotate=True, ), diff --git a/tests/testconfig.py b/tests/testconfig.py index d78f514..89d5f53 100644 --- a/tests/testconfig.py +++ b/tests/testconfig.py @@ -1,6 +1,5 @@ import json import lzma -import os import sys import time from itertools import zip_longest @@ -9,7 +8,7 @@ current_dir = Path(__file__).parent sys.path.insert(0, str(current_dir.parent)) -import armaclass +import armaclass # noqa CONFIG_CPP = current_dir / 'config_data' / 'config.cpp' CONFIG_JSON = current_dir / 'config_data' / 'config.json' @@ -44,7 +43,7 @@ raise -import pstats, cProfile +import pstats, cProfile # noqa # import pyximport # pyximport.install() @@ -128,5 +127,6 @@ def compare_lists_equal(model, current, path=''): error = f'{path}[{i}] == {item_current} instead of {item_model}' raise ValueError(error) + # COMPARE HERE compare_dicts_equal(model, parsed)