diff --git a/.github/workflows/dev_workflow.yml b/.github/workflows/dev_workflow.yml.bak similarity index 100% rename from .github/workflows/dev_workflow.yml rename to .github/workflows/dev_workflow.yml.bak diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f8a22a0..b183b32 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,8 +13,10 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-latest, macos-latest, ubuntu-latest] - python-version: ['3.11', '3.10', 3.9, 3.8, 3.7] + os: [windows-latest] + python-version: ['3.11'] + # os: [windows-latest, macos-latest, ubuntu-latest] + # python-version: ['3.11', '3.10', 3.9, 3.8, 3.7] steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/test_nim_devel.yml b/.github/workflows/test_nim_devel.yml.bak similarity index 100% rename from .github/workflows/test_nim_devel.yml rename to .github/workflows/test_nim_devel.yml.bak diff --git a/nimporter/nexporter.py b/nimporter/nexporter.py index 46360bc..c8022c8 100644 --- a/nimporter/nexporter.py +++ b/nimporter/nexporter.py @@ -256,22 +256,17 @@ def compile_extensions_to_c(platforms: List[str], root: Path) -> None: prevent_win32_max_path_length_error(out_dir) return - -def _is_valid_identifier(string: str) -> Union[Match[str], None, bool]: - import re - match = re.search('^[A-Za-z_][A-Z-a-z0-9_\\-]*', string) - return match and len(match.string) == len(string) - - def _is_semver(string: str) -> bool: + import re try: - lib_name, lib_version = string.rsplit('-', maxsplit=1) - assert _is_valid_identifier(lib_name) - - major, minor, patch = lib_version.split('.') - assert major.isdigit() - assert minor.isdigit() - assert patch.isdigit() + match = re.search( + r'(\w+)-(?\d+)\.(?\d+)\.(?\d+)(-?.+)', + string + ) + assert match + assert match['major'].isdigit() + assert match['minor'].isdigit() + assert match['patch'].isdigit() return True except: @@ -314,6 +309,13 @@ def prevent_win32_max_path_length_error(path: Path) -> None: mod_name = '@'.join(segments[index:]) break + # Local bare module imports which don't include a semver + else: + mod_name = item.name.replace('@m', '') + new_name = ic(f'NIMPORTER@{mod_name}') + assert not item.with_name(new_name).exists(), ( + f"Bug with @ replacements: {new_name} shouldn't already exist" + ) item.replace(item.with_name(new_name)) return diff --git a/pyproject.toml b/pyproject.toml index d72bac3..fe654b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,21 +4,54 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "nimporter" -version = "2.0.0" +version = "2.0.1" description = "Compile Nim extensions for Python when imported!" -authors = ["Pebaz ", "SekouDiaoNlp "] +authors = [ + "Pebaz ", + "SekouDiaoNlp ", +] license = "MIT" -keywords = ["nim", "python", "compiler", "import", "performance", "cython", "transpiler", "nimpy", "cython-alternative", "nim-source", "nim-compiler", "nimporter-library"] -classifiers = ["Development Status :: 5 - Production/Stable", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities", "Intended Audience :: Developers", "Intended Audience :: End Users/Desktop", "Intended Audience :: Education", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11",] +keywords = [ + "nim", + "python", + "compiler", + "import", + "performance", + "cython", + "transpiler", + "nimpy", + "cython-alternative", + "nim-source", + "nim-compiler", + "nimporter-library", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Topic :: Software Development :: Libraries :: Python Modules", + "Topic :: Utilities", + "Intended Audience :: Developers", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Education", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] homepage = "https://github.com/Pebaz/nimporter" repository = "https://github.com/Pebaz/nimporter" documentation = "https://pebaz.github.io/nimporter/index.html" -maintainers = ["Pebaz ", "SekouDiaoNlp "] -readme = "README.md" -packages = [ - { include = 'nimporter' }, - { include = 'tests', format = 'sdist' }, +maintainers = [ + "Pebaz ", + "SekouDiaoNlp ", ] +readme = "README.md" +packages = [{ include = 'nimporter' }, { include = 'tests', format = 'sdist' }] include = [ { path = 'README.md', format = 'sdist' }, { path = 'LICENSE', format = 'sdist' }, @@ -27,18 +60,16 @@ include = [ { path = '*.sh', format = 'sdist' }, { path = '*.ps1', format = 'sdist' }, ] -exclude = [ - { path = '*.md', format = 'wheel' }, -] +exclude = [{ path = '*.md', format = 'wheel' }] [tool.poetry.scripts] nimporter = 'nimporter.cli:main' [tool.poetry.dependencies] python = "^3.7" -py-cpuinfo = "^9.0.0" # Auto-detect user architecture -icecream = "^2.1.3" # Instrumentation -cookiecutter = "^2.1.1" # Folder structure +py-cpuinfo = "^9.0.0" # Auto-detect user architecture +icecream = "^2.1.3" # Instrumentation +cookiecutter = "^2.1.1" # Folder structure [tool.poetry.dev-dependencies] @@ -60,5 +91,5 @@ files = [ "nimporter/lib.py", "nimporter/nimporter.py", "nimporter/nexporter.py", - "nimporter/cli.py" + "nimporter/cli.py", ] diff --git a/setup.py b/setup.py index 36345d4..070c0bf 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='nimporter', - version='2.0.0', + version='2.0.1', license='MIT', description='Compile Nim extensions for Python when imported!', long_description=io.open('README.md', encoding='utf-8').read(), diff --git a/tests/__init__.py b/tests/__init__.py index 48944e8..140897c 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -8,12 +8,12 @@ @contextlib.contextmanager def temporarily_install_nimporter(): try: - code, _, _ = run_process( + code, out, err = run_process( shlex.split(f'{PYTHON} setup.py install --force'), 'NIMPORTER_INSTRUMENT' in os.environ ) - assert code == 0, 'Nimporter failed to install' + assert code == 0, f'Nimporter failed to install:\n\t{out=}\n\t{err=}' yield finally: