Skip to content

Commit d41f7b8

Browse files
committed
ci: fix build
1 parent 147ea14 commit d41f7b8

File tree

3 files changed

+32
-49
lines changed

3 files changed

+32
-49
lines changed

.github/workflows/default.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
matrix:
1212
os: [windows-latest, macos-latest, macos-14]
13-
python-version: ['3.9', '3.10', '3.11', '3.12']
13+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
1414
dist: [bdist_wheel]
1515
exclude:
1616
- os: macos-14
@@ -22,6 +22,10 @@ jobs:
2222
python-version: ${{ matrix.python-version }}
2323
- name: Checkout code
2424
uses: actions/checkout@v2
25+
- name: Download test image file
26+
run: |
27+
# Photo by Dillon Hunt (https://unsplash.com/@dillon_hunt) on https://unsplash.com/photos/an-aerial-view-of-the-ocean-and-rocks-zQLd8RXbenw
28+
curl -L -o test_image.jpg "https://unsplash.com/photos/zQLd8RXbenw/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MzY0MDA3NTd8&force=true&w=2400"
2529
- name: Install dependencies
2630
run: |
2731
pip install --upgrade pip setuptools rich wheel requests pillow
@@ -30,7 +34,7 @@ jobs:
3034
python setup.py ${{ matrix.dist }}
3135
- name: Run tests
3236
run: |
33-
pip install --find-links=dist materialyoucolor
37+
pip install --find-links=dist materialyoucolor --no-index
3438
python tests/test_all.py test_image.jpg 1
3539
- name: Upload artifacts
3640
uses: actions/upload-artifact@v3

.github/workflows/linux.yml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,39 @@ jobs:
1010
container:
1111
image: quay.io/pypa/manylinux_2_28_x86_64
1212
steps:
13-
- name: Set up Python ${{ matrix.python-version }}
14-
uses: actions/setup-python@v3
15-
with:
16-
python-version: ${{ matrix.python-version }}
1713
- name: Checkout code
1814
uses: actions/checkout@v2
19-
- name: Install dependencies
20-
run: |
21-
/opt/python/cp39-cp39/bin/pip install --upgrade pip setuptools rich wheel requests pillow
22-
/opt/python/cp310-cp310/bin/pip install --upgrade pip setuptools rich wheel requests pillow
23-
/opt/python/cp311-cp311/bin/pip install --upgrade pip setuptools rich wheel requests pillow
24-
/opt/python/cp312-cp312/bin/pip install --upgrade pip setuptools rich wheel requests pillow
25-
- name: Build wheel
15+
- name: Download test image file
2616
run: |
27-
/opt/python/cp39-cp39/bin/python setup.py bdist_wheel
28-
/opt/python/cp310-cp310/bin/python setup.py bdist_wheel
29-
/opt/python/cp311-cp311/bin/python setup.py bdist_wheel
30-
/opt/python/cp312-cp312/bin/python setup.py bdist_wheel sdist
31-
- name: Run tests
17+
# Photo by Dillon Hunt (https://unsplash.com/@dillon_hunt) on https://unsplash.com/photos/an-aerial-view-of-the-ocean-and-rocks-zQLd8RXbenw
18+
curl -L -o test_image.jpg "https://unsplash.com/photos/zQLd8RXbenw/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MzY0MDA3NTd8&force=true&w=2400"
19+
- name: Setup, Build, Test and Audit
3220
run: |
33-
/opt/python/cp39-cp39/bin/pip install --find-links=dist materialyoucolor
34-
/opt/python/cp310-cp310/bin/pip install --find-links=dist materialyoucolor
35-
/opt/python/cp311-cp311/bin/pip install --find-links=dist materialyoucolor
36-
/opt/python/cp312-cp312/bin/pip install --find-links=dist materialyoucolor
21+
python_versions=("cp39" "cp310" "cp311" "cp312" "cp313")
22+
for version in "${python_versions[@]}"; do
23+
24+
/opt/python/$version-$version/bin/pip install --upgrade pip setuptools rich wheel requests pillow
25+
/opt/python/$version-$version/bin/python setup.py bdist_wheel
26+
/opt/python/$version-$version/bin/pip install --find-links=dist materialyoucolor --no-index
27+
/opt/python/$version-$version/bin/python tests/test_all.py test_image.jpg 1 &> /dev/null
28+
29+
if [ "$version" == "cp39" ]; then
30+
/opt/python/$version-$version/bin/python setup.py sdist
31+
/opt/python/$version-$version/bin/pip install auditwheel
32+
mkdir wheelhouse
33+
mv dist/*.tar.gz wheelhouse
34+
auditwheel repair dist/*
35+
echo "Built dists for Python $version:"
36+
ls wheelhouse
37+
fi
38+
39+
done
3740
38-
/opt/python/cp39-cp39/bin/python tests/test_all.py test_image.jpg 1
39-
/opt/python/cp310-cp310/bin/python tests/test_all.py test_image.jpg 1
40-
/opt/python/cp311-cp311/bin/python tests/test_all.py test_image.jpg 1
41-
/opt/python/cp312-cp312/bin/python tests/test_all.py test_image.jpg 1
42-
43-
/opt/python/cp39-cp39/bin/pip install auditwheel
44-
mkdir wheelhouse
45-
mv dist/*.tar.gz wheelhouse
46-
auditwheel repair dist/*
47-
echo "Built dists:"
48-
ls wheelhouse
4941
- name: Publish to PyPI
5042
uses: pypa/gh-action-pypi-publish@v1.5.0
5143
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
5244
with:
5345
user: __token__
5446
password: ${{ secrets.PYPI_TOKEN }}
5547
packages_dir: wheelhouse
48+

tests/test_all.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,12 @@
2828

2929
rgba_to_hex = lambda rgba: "#{:02X}{:02X}{:02X}{:02X}".format(*map(round, rgba))
3030

31-
FILENAME = sys.argv[1]
32-
33-
if not os.path.isfile(FILENAME):
34-
print("Downloading test image file: ")
35-
with open(FILENAME, "wb") as file:
36-
file.write(
37-
requests.get(
38-
"https://unsplash.com/photos/u9tAl8WR3DI/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MDUyMDgwNjF8&force=true"
39-
).content
40-
)
41-
print("Downloaded: ", FILENAME, os.path.exists(FILENAME))
42-
4331
console = Console()
4432
quality = int(sys.argv[2])
4533

4634
########### PILLOW METHOD #############
4735
start = default_timer()
48-
image = Image.open(FILENAME)
36+
image = Image.open(sys.argv[1])
4937
pixel_len = image.width * image.height
5038
image_data = image.getdata()
5139
# start = default_timer()
@@ -57,7 +45,7 @@
5745
########## C++ Method ##########
5846
start = default_timer()
5947
# loading using c++ method
60-
colors = ImageQuantizeCelebi(FILENAME, quality, MAX_COLOR)
48+
colors = ImageQuantizeCelebi(sys.argv[1], quality, MAX_COLOR)
6149
end = default_timer()
6250
print(f"Color[stb_image] generation took {end-start:.4f} secs")
6351
######################
@@ -94,8 +82,6 @@
9482
)
9583
console.print(st)
9684

97-
exit()
98-
9985
def print_scheme(scheme_function, name):
10086
print()
10187
schemes = [scheme_function(rgb) for rgb in selected]

0 commit comments

Comments
 (0)