Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 16 additions & 14 deletions nimporter/nexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+)-(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-?.+)',
string
)
assert match
assert match['major'].isdigit()
assert match['minor'].isdigit()
assert match['patch'].isdigit()

return True
except:
Expand Down Expand Up @@ -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
63 changes: 47 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/Pebaz>", "SekouDiaoNlp <[email protected]>"]
authors = [
"Pebaz <https://github.com/Pebaz>",
"SekouDiaoNlp <[email protected]>",
]
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 <https://github.com/Pebaz>", "SekouDiaoNlp <[email protected]>"]
readme = "README.md"
packages = [
{ include = 'nimporter' },
{ include = 'tests', format = 'sdist' },
maintainers = [
"Pebaz <https://github.com/Pebaz>",
"SekouDiaoNlp <[email protected]>",
]
readme = "README.md"
packages = [{ include = 'nimporter' }, { include = 'tests', format = 'sdist' }]
include = [
{ path = 'README.md', format = 'sdist' },
{ path = 'LICENSE', format = 'sdist' },
Expand All @@ -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]
Expand All @@ -60,5 +91,5 @@ files = [
"nimporter/lib.py",
"nimporter/nimporter.py",
"nimporter/nexporter.py",
"nimporter/cli.py"
"nimporter/cli.py",
]
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down