@@ -51,11 +51,13 @@ jobs:
5151 CCHARDET_VERSION : ${{ matrix.version }}
5252
5353 steps :
54- - name : Checkout cChardet ${{ env.CCHARDET_VERSION }}
54+ # Upstream tagged 2.1.7 and earlier bare (2.1.7); starting at 2.2.0 tags
55+ # carry a "v" prefix (v2.2.0, v2.3.0).
56+ - name : Checkout cChardet v${{ env.CCHARDET_VERSION }}
5557 uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
5658 with :
5759 repository : PyYoshi/cChardet
58- ref : ${{ env.CCHARDET_VERSION }}
60+ ref : v ${{ env.CCHARDET_VERSION }}
5961 submodules : recursive
6062 persist-credentials : false
6163
@@ -68,10 +70,10 @@ jobs:
6870
6971 - name : Build sdist
7072 id : sdist
71- # This tag ships no pyproject.toml: setup.py cythonises _cchardet.pyx
72- # itself whenever Cython is importable, so Cython has to be
73- # preinstalled with isolation off, or the bundled .cpp is whatever a
74- # bare `setuptools`+`wheel` env leaves behind (nothing, in practice).
73+ # setup.py cythonises _cchardet.pyx itself whenever Cython is
74+ # importable, so Cython has to be preinstalled with isolation off, or
75+ # the bundled .cpp is whatever a bare `setuptools`+`wheel` env leaves
76+ # behind (nothing, in practice).
7577 run : |
7678 uv pip install cython setuptools wheel build twine
7779 python -m build --sdist --no-isolation
8486 path : dist/*.tar.gz
8587 if-no-files-found : error
8688
89+ # tools/wheel_smoke.py (upstream's own [tool.cibuildwheel] test-command)
90+ # isn't part of the sdist (not listed in MANIFEST.in - that only
91+ # ships what the installable package needs), so carry it separately
92+ # from this checkout rather than freezing a copy into the workflow,
93+ # which would silently drift from upstream on the next version bump.
94+ - name : Upload wheel_smoke.py artifact
95+ uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
96+ with :
97+ name : cchardet-${{ env.CCHARDET_VERSION }}-smoke
98+ path : tools/wheel_smoke.py
99+ if-no-files-found : error
100+
87101 build_wheels :
88102 needs : [setup, build_sdist]
89103 if : needs.setup.outputs.versions != '[]'
@@ -106,87 +120,18 @@ jobs:
106120 name : cchardet-${{ env.CCHARDET_VERSION }}-sdist
107121 path : dist/
108122
109- - name : Extract sdist and stage the wheel smoke tests
110- # Upstream's own suite (src/tests/test.py) uses nose, dead on modern
111- # Python; this reproduces its checks with plain pytest assertions
112- # against the same bundled testdata/samples.
123+ - name : Download wheel_smoke.py
124+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
125+ with :
126+ name : cchardet-${{ env.CCHARDET_VERSION }}-smoke
127+ path : smoke/
128+
129+ - name : Extract sdist and stage the wheel smoke test
113130 run : |
114131 mkdir pkg
115132 tar xzf dist/*.tar.gz --strip-components=1 -C pkg
116- cat > pkg/riscv64_test_cchardet.py <<'EOF'
117- import glob
118- import os
119-
120- import cchardet
121-
122- TESTDATA_DIR = "pkg/src/tests/testdata"
123- SAMPLES_DIR = "pkg/src/tests/samples"
124-
125- SKIP_LIST = [
126- TESTDATA_DIR + "/ja/utf-16le.txt",
127- TESTDATA_DIR + "/ja/utf-16be.txt",
128- TESTDATA_DIR + "/es/iso-8859-15.txt",
129- TESTDATA_DIR + "/da/iso-8859-1.txt",
130- TESTDATA_DIR + "/he/iso-8859-8.txt",
131- ]
132- SKIP_LIST_DECODE = SKIP_LIST + [
133- TESTDATA_DIR + "/vi/viscii.txt",
134- TESTDATA_DIR + "/zh/euc-tw.txt",
135- ]
136-
137-
138- def test_ascii():
139- assert cchardet.detect(b"abcdefghijklmnopqrstuvwxyz")["encoding"].lower() == "ascii"
140-
141-
142- def test_detect():
143- testfiles = glob.glob(TESTDATA_DIR + "/*/*.txt")
144- assert testfiles
145- for testfile in testfiles:
146- if testfile in SKIP_LIST:
147- continue
148- expected = os.path.splitext(os.path.basename(testfile))[0]
149- with open(testfile, "rb") as f:
150- result = cchardet.detect(f.read())
151- assert result["encoding"] is not None, testfile
152- assert result["encoding"].lower() == expected.lower(), (testfile, result)
153-
154-
155- def test_detector():
156- detector = cchardet.UniversalDetector()
157- with open(SAMPLES_DIR + "/wikipediaJa_One_Thousand_and_One_Nights_SJIS.txt", "rb") as f:
158- for line in f:
159- detector.feed(line)
160- if detector.done:
161- break
162- detector.close()
163- assert detector.result["encoding"].lower() == "shift_jis"
164-
165-
166- def test_github_issue_20():
167- msg = b"\x8f"
168- cchardet.detect(msg)
169- detector = cchardet.UniversalDetector()
170- detector.feed(msg)
171- detector.close()
172-
173-
174- def test_decode():
175- for testfile in glob.glob(TESTDATA_DIR + "/*/*.txt"):
176- if testfile in SKIP_LIST_DECODE:
177- continue
178- with open(testfile, "rb") as f:
179- msg = f.read()
180- msg.decode(cchardet.detect(msg)["encoding"])
181-
182-
183- def test_utf8_with_bom():
184- assert cchardet.detect(b"\xef\xbb\xbf")["encoding"].lower() == "utf-8-sig"
185-
186-
187- def test_null_bytes():
188- assert cchardet.detect(b"ABC\x00\x80\x81")["encoding"] is None
189- EOF
133+ mkdir -p pkg/tools
134+ cp smoke/wheel_smoke.py pkg/tools/wheel_smoke.py
190135
191136 - name : Build and test wheels
192137 uses : pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
@@ -196,10 +141,10 @@ jobs:
196141 only : ${{ matrix.python }}-manylinux_riscv64
197142 env :
198143 CIBW_MANYLINUX_RISCV64_IMAGE : ${{ env.MANYLINUX_RISCV64_IMAGE }}
199- CIBW_TEST_REQUIRES : pytest
144+ # Mirrors upstream's own [tool.cibuildwheel] test-command/test-sources.
200145 # CIBW_TEST_SOURCES is relative to the cwd, not package-dir, hence "pkg/".
201- CIBW_TEST_SOURCES : pkg/riscv64_test_cchardet .py pkg/src/tests/testdata pkg/src/tests/samples
202- CIBW_TEST_COMMAND : python -m pytest pkg/riscv64_test_cchardet .py -v
146+ CIBW_TEST_SOURCES : pkg/tools/wheel_smoke .py
147+ CIBW_TEST_COMMAND : python pkg/tools/wheel_smoke .py
203148
204149 - name : Verify the wheel ships the compiled extension
205150 run : |
0 commit comments