diff --git a/nimporter/nexporter.py b/nimporter/nexporter.py index 46360bc..e9f54c9 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 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(),