Skip to content

Commit

Permalink
ci: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Dynamos committed Jan 9, 2025
1 parent 147ea14 commit d41f7b8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 49 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, macos-latest, macos-14]
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
dist: [bdist_wheel]
exclude:
- os: macos-14
Expand All @@ -22,6 +22,10 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Download test image file
run: |
# Photo by Dillon Hunt (https://unsplash.com/@dillon_hunt) on https://unsplash.com/photos/an-aerial-view-of-the-ocean-and-rocks-zQLd8RXbenw
curl -L -o test_image.jpg "https://unsplash.com/photos/zQLd8RXbenw/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MzY0MDA3NTd8&force=true&w=2400"
- name: Install dependencies
run: |
pip install --upgrade pip setuptools rich wheel requests pillow
Expand All @@ -30,7 +34,7 @@ jobs:
python setup.py ${{ matrix.dist }}
- name: Run tests
run: |
pip install --find-links=dist materialyoucolor
pip install --find-links=dist materialyoucolor --no-index
python tests/test_all.py test_image.jpg 1
- name: Upload artifacts
uses: actions/upload-artifact@v3
Expand Down
55 changes: 24 additions & 31 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,39 @@ jobs:
container:
image: quay.io/pypa/manylinux_2_28_x86_64
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
/opt/python/cp39-cp39/bin/pip install --upgrade pip setuptools rich wheel requests pillow
/opt/python/cp310-cp310/bin/pip install --upgrade pip setuptools rich wheel requests pillow
/opt/python/cp311-cp311/bin/pip install --upgrade pip setuptools rich wheel requests pillow
/opt/python/cp312-cp312/bin/pip install --upgrade pip setuptools rich wheel requests pillow
- name: Build wheel
- name: Download test image file
run: |
/opt/python/cp39-cp39/bin/python setup.py bdist_wheel
/opt/python/cp310-cp310/bin/python setup.py bdist_wheel
/opt/python/cp311-cp311/bin/python setup.py bdist_wheel
/opt/python/cp312-cp312/bin/python setup.py bdist_wheel sdist
- name: Run tests
# Photo by Dillon Hunt (https://unsplash.com/@dillon_hunt) on https://unsplash.com/photos/an-aerial-view-of-the-ocean-and-rocks-zQLd8RXbenw
curl -L -o test_image.jpg "https://unsplash.com/photos/zQLd8RXbenw/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MzY0MDA3NTd8&force=true&w=2400"
- name: Setup, Build, Test and Audit
run: |
/opt/python/cp39-cp39/bin/pip install --find-links=dist materialyoucolor
/opt/python/cp310-cp310/bin/pip install --find-links=dist materialyoucolor
/opt/python/cp311-cp311/bin/pip install --find-links=dist materialyoucolor
/opt/python/cp312-cp312/bin/pip install --find-links=dist materialyoucolor
python_versions=("cp39" "cp310" "cp311" "cp312" "cp313")
for version in "${python_versions[@]}"; do
/opt/python/$version-$version/bin/pip install --upgrade pip setuptools rich wheel requests pillow
/opt/python/$version-$version/bin/python setup.py bdist_wheel
/opt/python/$version-$version/bin/pip install --find-links=dist materialyoucolor --no-index
/opt/python/$version-$version/bin/python tests/test_all.py test_image.jpg 1 &> /dev/null
if [ "$version" == "cp39" ]; then
/opt/python/$version-$version/bin/python setup.py sdist
/opt/python/$version-$version/bin/pip install auditwheel
mkdir wheelhouse
mv dist/*.tar.gz wheelhouse
auditwheel repair dist/*
echo "Built dists for Python $version:"
ls wheelhouse
fi
done
/opt/python/cp39-cp39/bin/python tests/test_all.py test_image.jpg 1
/opt/python/cp310-cp310/bin/python tests/test_all.py test_image.jpg 1
/opt/python/cp311-cp311/bin/python tests/test_all.py test_image.jpg 1
/opt/python/cp312-cp312/bin/python tests/test_all.py test_image.jpg 1
/opt/python/cp39-cp39/bin/pip install auditwheel
mkdir wheelhouse
mv dist/*.tar.gz wheelhouse
auditwheel repair dist/*
echo "Built dists:"
ls wheelhouse
- name: Publish to PyPI
uses: pypa/[email protected]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: wheelhouse

18 changes: 2 additions & 16 deletions tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,12 @@

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

FILENAME = sys.argv[1]

if not os.path.isfile(FILENAME):
print("Downloading test image file: ")
with open(FILENAME, "wb") as file:
file.write(
requests.get(
"https://unsplash.com/photos/u9tAl8WR3DI/download?ixid=M3wxMjA3fDB8MXx0b3BpY3x8NnNNVmpUTFNrZVF8fHx8fDJ8fDE3MDUyMDgwNjF8&force=true"
).content
)
print("Downloaded: ", FILENAME, os.path.exists(FILENAME))

console = Console()
quality = int(sys.argv[2])

########### PILLOW METHOD #############
start = default_timer()
image = Image.open(FILENAME)
image = Image.open(sys.argv[1])
pixel_len = image.width * image.height
image_data = image.getdata()
# start = default_timer()
Expand All @@ -57,7 +45,7 @@
########## C++ Method ##########
start = default_timer()
# loading using c++ method
colors = ImageQuantizeCelebi(FILENAME, quality, MAX_COLOR)
colors = ImageQuantizeCelebi(sys.argv[1], quality, MAX_COLOR)
end = default_timer()
print(f"Color[stb_image] generation took {end-start:.4f} secs")
######################
Expand Down Expand Up @@ -94,8 +82,6 @@
)
console.print(st)

exit()

def print_scheme(scheme_function, name):
print()
schemes = [scheme_function(rgb) for rgb in selected]
Expand Down

0 comments on commit d41f7b8

Please sign in to comment.