Skip to content

Commit 6c75b3e

Browse files
committed
Merge branch 'release'
2 parents 103ce65 + 4b5dd11 commit 6c75b3e

File tree

11 files changed

+100
-41
lines changed

11 files changed

+100
-41
lines changed

.github/workflows/build.yml

+24-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66

77
steps:
88
- name: Check out repository code
9-
uses: actions/checkout@v3
9+
uses: actions/checkout@v4
1010

1111
- name: Install testing framework
1212
run: python -m pip install pytest
@@ -27,20 +27,21 @@ jobs:
2727
run: pytest
2828

2929
- name: Run performance test
30-
run: python testconfig.py
30+
run: python tests/testconfig.py
3131

3232
make_sdist:
3333
needs: test
3434
runs-on: ubuntu-latest
3535

3636
steps:
37-
- uses: actions/checkout@v3
37+
- uses: actions/checkout@v4
3838

3939
- name: Make Sdist
4040
run: python setup.py sdist
4141

42-
- uses: actions/upload-artifact@v3
42+
- uses: actions/upload-artifact@v4
4343
with:
44+
name: artifact-source
4445
path: dist/*.tar.gz
4546

4647
build_wheels:
@@ -53,10 +54,14 @@ jobs:
5354
os: [ubuntu-latest, windows-latest, macOS-latest]
5455

5556
steps:
56-
- uses: actions/checkout@v3
57+
- uses: actions/checkout@v4
5758

5859
# Used to host cibuildwheel
59-
- uses: actions/setup-python@v3
60+
- uses: actions/setup-python@v5
61+
with:
62+
python-version: '3.10'
63+
env:
64+
PIP_DISABLE_PIP_VERSION_CHECK: 1
6065

6166
- name: Install cibuildwheel
6267
run: python -m pip install cibuildwheel
@@ -68,12 +73,23 @@ jobs:
6873
CIBW_SKIP: pp*
6974
CIBW_TEST_REQUIRES: pytest
7075
CIBW_TEST_COMMAND: pytest {project}
76+
CIBW_TEST_SKIP: "cp38-macosx_arm64"
7177

72-
73-
- uses: actions/upload-artifact@v3
78+
- uses: actions/upload-artifact@v4
7479
with:
80+
name: artifact-${{ matrix.os }}
7581
path: ./wheelhouse/*.whl
7682

83+
merge_artifacts:
84+
runs-on: ubuntu-latest
85+
needs: [make_sdist, build_wheels]
86+
steps:
87+
- name: Merge Artifacts
88+
uses: actions/upload-artifact/merge@v4
89+
with:
90+
name: armaclass
91+
pattern: artifact-*
92+
7793
# upload_all:
7894
# needs: [ build_wheels, make_sdist ]
7995
# runs-on: ubuntu-latest

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Lukasz Taczuk
3+
Copyright (c) 2024 Lukasz Taczuk
44
Copyright (c) 2018 Moritz Schmidt (original JavaScript code)
55

66
Permission is hereby granted, free of charge, to any person obtaining a copy

armaclass/Shadow.py

+40-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from __future__ import absolute_import
33

44
# Possible version formats: "3.1.0", "3.1.0a1", "3.1.0a1.dev0"
5-
__version__ = "3.0.0b2"
5+
__version__ = "3.0.10"
66

77
try:
88
from __builtin__ import basestring
@@ -110,22 +110,35 @@ class _Optimization(object):
110110

111111
annotation_typing = returns = wraparound = boundscheck = initializedcheck = \
112112
nonecheck = embedsignature = cdivision = cdivision_warnings = \
113-
always_allows_keywords = profile = linetrace = infer_types = \
114-
unraisable_tracebacks = freelist = \
113+
always_allow_keywords = profile = linetrace = infer_types = \
114+
unraisable_tracebacks = freelist = auto_pickle = cpow = trashcan = \
115+
auto_cpdef = c_api_binop_methods = \
116+
allow_none_for_extension_args = callspec = show_performance_hints = \
117+
cpp_locals = py2_import = iterable_coroutine = remove_unreachable = \
115118
lambda _: _EmptyDecoratorAndManager()
116119

120+
# Note that fast_getattr is untested and undocumented!
121+
fast_getattr = lambda _: _EmptyDecoratorAndManager()
122+
117123
exceptval = lambda _=None, check=True: _EmptyDecoratorAndManager()
118124

119125
overflowcheck = lambda _: _EmptyDecoratorAndManager()
120126
optimize = _Optimization()
121127

122-
overflowcheck.fold = optimize.use_switch = \
128+
129+
embedsignature.format = overflowcheck.fold = optimize.use_switch = \
123130
optimize.unpack_method_calls = lambda arg: _EmptyDecoratorAndManager()
124131

125-
final = internal = type_version_tag = no_gc_clear = no_gc = total_ordering = _empty_decorator
132+
final = internal = type_version_tag = no_gc_clear = no_gc = total_ordering = \
133+
ufunc = _empty_decorator
126134

127135
binding = lambda _: _empty_decorator
128136

137+
class warn:
138+
undeclared = unreachable = maybe_uninitialized = unused = \
139+
unused_arg = unused_result = \
140+
lambda _: _EmptyDecoratorAndManager()
141+
129142

130143
_cython_inline = None
131144
def inline(f, *args, **kwds):
@@ -216,6 +229,7 @@ def __exit__(self, exc_class, exc, tb):
216229

217230
nogil = _nogil()
218231
gil = _nogil()
232+
with_gil = _nogil() # Actually not a context manager, but compilation will give the right error.
219233
del _nogil
220234

221235

@@ -437,6 +451,8 @@ def _specialized_from_args(signatures, args, kwargs):
437451
'Py_hash_t',
438452
'Py_ssize_t',
439453
'size_t',
454+
'ssize_t',
455+
'ptrdiff_t',
440456
]
441457
float_types = [
442458
'longdouble',
@@ -477,7 +493,7 @@ def _specialized_from_args(signatures, args, kwargs):
477493
for name in int_types:
478494
reprname = to_repr(name, name)
479495
gs[name] = typedef(py_int, reprname)
480-
if name not in ('Py_UNICODE', 'Py_UCS4') and not name.endswith('size_t'):
496+
if name not in ('Py_UNICODE', 'Py_UCS4', 'Py_hash_t', 'ptrdiff_t') and not name.endswith('size_t'):
481497
gs['u'+name] = typedef(py_int, "unsigned " + reprname)
482498
gs['s'+name] = typedef(py_int, "signed " + reprname)
483499

@@ -491,10 +507,19 @@ def _specialized_from_args(signatures, args, kwargs):
491507
void = typedef(None, "void")
492508
Py_tss_t = typedef(None, "Py_tss_t")
493509

494-
for t in int_types + float_types + complex_types + other_types:
510+
for t in int_types:
511+
for i in range(1, 4):
512+
gs["%s_%s" % ('p'*i, t)] = gs[t]._pointer(i)
513+
if 'u'+t in gs:
514+
gs["%s_u%s" % ('p'*i, t)] = gs['u'+t]._pointer(i)
515+
gs["%s_s%s" % ('p'*i, t)] = gs['s'+t]._pointer(i)
516+
517+
for t in float_types + complex_types + other_types:
495518
for i in range(1, 4):
496519
gs["%s_%s" % ('p'*i, t)] = gs[t]._pointer(i)
497520

521+
del t, i
522+
498523
NULL = gs['p_void'](0)
499524

500525
# looks like 'gs' has some users out there by now...
@@ -550,7 +575,6 @@ def __getattr__(self, attr):
550575
sys.modules['cython.%s' % self.__name__] = mod
551576
return getattr(mod, attr)
552577

553-
554578
class CythonCImports(object):
555579
"""
556580
Simplistic module mock to make cimports sort-of work in Python code.
@@ -564,7 +588,14 @@ def __init__(self, module):
564588
def __getattr__(self, item):
565589
if item.startswith('__') and item.endswith('__'):
566590
raise AttributeError(item)
567-
return __import__(item)
591+
try:
592+
return __import__(item)
593+
except ImportError:
594+
import sys
595+
ex = AttributeError(item)
596+
if sys.version_info >= (3, 0):
597+
ex.__cause__ = None
598+
raise ex
568599

569600

570601
import math, sys

build.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
import glob
21
import os
32
import subprocess
4-
from itertools import chain
3+
from pathlib import Path
54

6-
armaclass_path = 'armaclass'
5+
armaclass_path = Path('armaclass')
76
types = ('*.html', '*.c', '*.cpp', '*.pyd', '*.so')
8-
files_to_delete = chain(*(glob.glob(os.path.join(armaclass_path, file_type)) for file_type in types))
7+
8+
files_to_delete = []
9+
for file_type in types:
10+
files_to_delete.extend(armaclass_path.glob(file_type))
11+
912
for file_path in files_to_delete:
13+
print('Deleting', file_path)
1014
os.remove(file_path)
1115

1216
subprocess.run('python setup_cython.py build_ext --inplace --force', shell=True, check=True)
1317
subprocess.run('pytest -x -s', shell=True, check=True)
14-
subprocess.run('python testconfig.py', shell=True, check=True)
18+
subprocess.run('python tests/testconfig.py', shell=True, check=True)

requirements-cython.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Cython~=3.0b
1+
Cython~=3.0

setup.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import os
22
import platform
33
import sys
4+
from pathlib import Path
45

56
from setuptools import setup
67

78
# read the contents of your README file
8-
this_directory = os.path.abspath(os.path.dirname(__file__))
9-
with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
10-
long_description = f.read()
9+
this_directory = Path(__file__).parent
10+
long_description = (this_directory / 'README.md').read_text(encoding='utf-8')
1111

1212
ext_modules = None
1313
if not any(arg in sys.argv for arg in ['clean', 'check']) and \
@@ -23,7 +23,7 @@
2323
compiler_directives['linetrace'] = True
2424

2525
ext_modules = cythonize(
26-
os.path.join('armaclass', 'parser.py'),
26+
str(this_directory / 'armaclass' / 'parser.py'),
2727
language_level=3,
2828
compiler_directives=compiler_directives,
2929
)
@@ -44,7 +44,7 @@
4444

4545
classifiers=[
4646
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
47-
'Development Status :: 4 - Beta',
47+
'Development Status :: 5 - Production/Stable',
4848

4949
# Indicate who your project is intended for
5050
'Intended Audience :: Developers',
@@ -56,6 +56,7 @@
5656
'Programming Language :: Python :: 3.9',
5757
'Programming Language :: Python :: 3.10',
5858
'Programming Language :: Python :: 3.11',
59+
'Programming Language :: Python :: 3.12',
5960

6061
'License :: OSI Approved :: MIT License',
6162
],

setup_cython.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import os
1+
from pathlib import Path
22

3-
from setuptools import setup
43
from Cython.Build import cythonize
4+
from setuptools import setup
5+
6+
this_directory = Path(__file__).parent
57

68
setup(
7-
ext_modules=cythonize(os.path.join('armaclass', 'parser.py'),
9+
ext_modules=cythonize(str(this_directory / 'armaclass' / 'parser.py'),
810
language_level=3,
911
annotate=True,
1012
),
File renamed without changes.
File renamed without changes.
File renamed without changes.

testconfig.py tests/testconfig.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import json
22
import lzma
3-
import os
3+
import sys
44
import time
55
from itertools import zip_longest
6+
from pathlib import Path
67

7-
import armaclass
8+
current_dir = Path(__file__).parent
9+
sys.path.insert(0, str(current_dir.parent))
810

9-
CONFIG_CPP = os.path.join('config_data', 'config.cpp')
10-
CONFIG_JSON = os.path.join('config_data', 'config.json')
11+
import armaclass # noqa
1112

12-
if not os.path.exists(CONFIG_CPP):
13-
data = lzma.open(CONFIG_CPP + '.xz').read()
13+
CONFIG_CPP = current_dir / 'config_data' / 'config.cpp'
14+
CONFIG_JSON = current_dir / 'config_data' / 'config.json'
15+
16+
if not CONFIG_CPP.exists():
17+
data = lzma.open(str(CONFIG_CPP) + '.xz').read()
1418
with open(CONFIG_CPP, 'wb') as f:
1519
f.write(data)
1620

17-
if not os.path.exists(CONFIG_JSON):
18-
data = lzma.open(CONFIG_JSON + '.xz').read()
21+
if not CONFIG_JSON.exists():
22+
data = lzma.open(str(CONFIG_JSON) + '.xz').read()
1923
with open(CONFIG_JSON, 'wb') as f:
2024
f.write(data)
2125

@@ -39,7 +43,7 @@
3943
raise
4044

4145

42-
import pstats, cProfile
46+
import pstats, cProfile # noqa
4347

4448
# import pyximport
4549
# pyximport.install()
@@ -123,5 +127,6 @@ def compare_lists_equal(model, current, path=''):
123127
error = f'{path}[{i}] == {item_current} instead of {item_model}'
124128
raise ValueError(error)
125129

130+
126131
# COMPARE HERE
127132
compare_dicts_equal(model, parsed)

0 commit comments

Comments
 (0)