Skip to content

Commit e69b0f5

Browse files
committed
Fix #93
1 parent c4265d7 commit e69b0f5

5 files changed

Lines changed: 70 additions & 35 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
os: [windows-latest, macos-latest, ubuntu-latest]
17-
python-version: ['3.11', '3.10', 3.9, 3.8, 3.7]
16+
os: [windows-latest]
17+
python-version: ['3.11']
18+
# os: [windows-latest, macos-latest, ubuntu-latest]
19+
# python-version: ['3.11', '3.10', 3.9, 3.8, 3.7]
1820

1921
steps:
2022
- uses: actions/checkout@v3

nimporter/nexporter.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,22 +256,17 @@ def compile_extensions_to_c(platforms: List[str], root: Path) -> None:
256256
prevent_win32_max_path_length_error(out_dir)
257257
return
258258

259-
260-
def _is_valid_identifier(string: str) -> Union[Match[str], None, bool]:
261-
import re
262-
match = re.search('^[A-Za-z_][A-Z-a-z0-9_\\-]*', string)
263-
return match and len(match.string) == len(string)
264-
265-
266259
def _is_semver(string: str) -> bool:
260+
import re
267261
try:
268-
lib_name, lib_version = string.rsplit('-', maxsplit=1)
269-
assert _is_valid_identifier(lib_name)
270-
271-
major, minor, patch = lib_version.split('.')
272-
assert major.isdigit()
273-
assert minor.isdigit()
274-
assert patch.isdigit()
262+
match = re.search(
263+
r'(\w+)-(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-?.+)',
264+
string
265+
)
266+
assert match
267+
assert match['major'].isdigit()
268+
assert match['minor'].isdigit()
269+
assert match['patch'].isdigit()
275270

276271
return True
277272
except:
@@ -314,6 +309,13 @@ def prevent_win32_max_path_length_error(path: Path) -> None:
314309
mod_name = '@'.join(segments[index:])
315310
break
316311

312+
# Local bare module imports which don't include a semver
313+
else:
314+
mod_name = item.name.replace('@m', '')
315+
317316
new_name = ic(f'NIMPORTER@{mod_name}')
317+
assert not item.with_name(new_name).exists(), (
318+
f"Bug with @ replacements: {new_name} shouldn't already exist"
319+
)
318320
item.replace(item.with_name(new_name))
319321
return

pyproject.toml

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,54 @@ build-backend = "poetry.core.masonry.api"
44

55
[tool.poetry]
66
name = "nimporter"
7-
version = "2.0.0"
7+
version = "2.0.1"
88
description = "Compile Nim extensions for Python when imported!"
9-
authors = ["Pebaz <https://github.com/Pebaz>", "SekouDiaoNlp <diao.sekou.nlp@gmail.com>"]
9+
authors = [
10+
"Pebaz <https://github.com/Pebaz>",
11+
"SekouDiaoNlp <diao.sekou.nlp@gmail.com>",
12+
]
1013
license = "MIT"
11-
keywords = ["nim", "python", "compiler", "import", "performance", "cython", "transpiler", "nimpy", "cython-alternative", "nim-source", "nim-compiler", "nimporter-library"]
12-
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",]
14+
keywords = [
15+
"nim",
16+
"python",
17+
"compiler",
18+
"import",
19+
"performance",
20+
"cython",
21+
"transpiler",
22+
"nimpy",
23+
"cython-alternative",
24+
"nim-source",
25+
"nim-compiler",
26+
"nimporter-library",
27+
]
28+
classifiers = [
29+
"Development Status :: 5 - Production/Stable",
30+
"Topic :: Software Development :: Libraries :: Python Modules",
31+
"Topic :: Utilities",
32+
"Intended Audience :: Developers",
33+
"Intended Audience :: End Users/Desktop",
34+
"Intended Audience :: Education",
35+
"Intended Audience :: Science/Research",
36+
"License :: OSI Approved :: MIT License",
37+
"Natural Language :: English",
38+
"Operating System :: OS Independent",
39+
"Programming Language :: Python :: 3",
40+
"Programming Language :: Python :: 3.7",
41+
"Programming Language :: Python :: 3.8",
42+
"Programming Language :: Python :: 3.9",
43+
"Programming Language :: Python :: 3.10",
44+
"Programming Language :: Python :: 3.11",
45+
]
1346
homepage = "https://github.com/Pebaz/nimporter"
1447
repository = "https://github.com/Pebaz/nimporter"
1548
documentation = "https://pebaz.github.io/nimporter/index.html"
16-
maintainers = ["Pebaz <https://github.com/Pebaz>", "SekouDiaoNlp <diao.sekou.nlp@gmail.com>"]
17-
readme = "README.md"
18-
packages = [
19-
{ include = 'nimporter' },
20-
{ include = 'tests', format = 'sdist' },
49+
maintainers = [
50+
"Pebaz <https://github.com/Pebaz>",
51+
"SekouDiaoNlp <diao.sekou.nlp@gmail.com>",
2152
]
53+
readme = "README.md"
54+
packages = [{ include = 'nimporter' }, { include = 'tests', format = 'sdist' }]
2255
include = [
2356
{ path = 'README.md', format = 'sdist' },
2457
{ path = 'LICENSE', format = 'sdist' },
@@ -27,18 +60,16 @@ include = [
2760
{ path = '*.sh', format = 'sdist' },
2861
{ path = '*.ps1', format = 'sdist' },
2962
]
30-
exclude = [
31-
{ path = '*.md', format = 'wheel' },
32-
]
63+
exclude = [{ path = '*.md', format = 'wheel' }]
3364

3465
[tool.poetry.scripts]
3566
nimporter = 'nimporter.cli:main'
3667

3768
[tool.poetry.dependencies]
3869
python = "^3.7"
39-
py-cpuinfo = "^9.0.0" # Auto-detect user architecture
40-
icecream = "^2.1.3" # Instrumentation
41-
cookiecutter = "^2.1.1" # Folder structure
70+
py-cpuinfo = "^9.0.0" # Auto-detect user architecture
71+
icecream = "^2.1.3" # Instrumentation
72+
cookiecutter = "^2.1.1" # Folder structure
4273

4374

4475
[tool.poetry.dev-dependencies]
@@ -60,5 +91,5 @@ files = [
6091
"nimporter/lib.py",
6192
"nimporter/nimporter.py",
6293
"nimporter/nexporter.py",
63-
"nimporter/cli.py"
94+
"nimporter/cli.py",
6495
]

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='nimporter',
6-
version='2.0.0',
6+
version='2.0.1',
77
license='MIT',
88
description='Compile Nim extensions for Python when imported!',
99
long_description=io.open('README.md', encoding='utf-8').read(),

tests/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
@contextlib.contextmanager
99
def temporarily_install_nimporter():
1010
try:
11-
code, _, _ = run_process(
11+
code, out, err = run_process(
1212
shlex.split(f'{PYTHON} setup.py install --force'),
1313
'NIMPORTER_INSTRUMENT' in os.environ
1414
)
1515

16-
assert code == 0, 'Nimporter failed to install'
16+
assert code == 0, f'Nimporter failed to install:\n\t{out=}\n\t{err=}'
1717

1818
yield
1919
finally:

0 commit comments

Comments
 (0)