From b3624b3a54976cc0deb66cdc686988d76a3f1c4e Mon Sep 17 00:00:00 2001 From: Bomme <13520622+Bomme@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:12:14 +0100 Subject: [PATCH 1/3] switch to uv to build project - Updated pyproject.toml with project metadata, dependencies, and build system configuration. - Removed setup.py as it is no longer needed with the new configuration. - Modified GitHub Actions workflow to support multiple Python versions and updated installation steps. --- .github/workflows/python-smoke-test.yml | 22 ++- .gitignore | 195 ++++++++++++++++++++++++ .python-version | 1 + pyproject.toml | 37 +++++ setup.py | 9 -- 5 files changed, 248 insertions(+), 16 deletions(-) create mode 100644 .python-version delete mode 100644 setup.py diff --git a/.github/workflows/python-smoke-test.yml b/.github/workflows/python-smoke-test.yml index a3da3e2..3d1213e 100644 --- a/.github/workflows/python-smoke-test.yml +++ b/.github/workflows/python-smoke-test.yml @@ -13,19 +13,27 @@ jobs: build: runs-on: ubuntu-latest + + strategy: + max-parallel: 1 + fail-fast: true + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v3 - - name: Set up Python 3.10 - uses: actions/setup-python@v4 + - name: Install uv + uses: astral-sh/setup-uv@v5 with: - python-version: "3.10" + version: "latest" + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e . + run: uv sync - name: Run smoke test env: FREESOUND_API_KEY: ${{ secrets.FREESOUND_API_KEY }} run: | - python examples.py + uv run python examples.py diff --git a/.gitignore b/.gitignore index 17a8d54..f110c92 100755 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,198 @@ build *.pyc *.bak + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# uv +uv.lock + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +.idea/ + + +tmp/ diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/pyproject.toml b/pyproject.toml index 5bf0d9b..7486065 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,40 @@ +[project] +name = "freesound" +version = "1.1" +description = "A Python client for the Freesound APIv2" +readme = "Readme.md" +requires-python = ">=3.7" +license = {file = "COPYING.txt"} +dependencies = [ + "requests>=2.27,<3.0", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "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", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Topic :: Multimedia :: Sound/Audio", +] + +[project.urls] +Homepage = "https://github.com/MTG/freesound-python" +Repository = "https://github.com/MTG/freesound-python.git" + + +[build-system] +requires = ["hatchling >= 1.26"] +build-backend = "hatchling.build" + +[tool.hatch.build] +include = ["freesound.py"] + [tool.yapf] based_on_style = "google" spaces_before_comment = 4 diff --git a/setup.py b/setup.py deleted file mode 100644 index b2f6273..0000000 --- a/setup.py +++ /dev/null @@ -1,9 +0,0 @@ -from distutils.core import setup - -setup( - name="freesound-python", - version="1.1", - py_modules=["freesound"], - install_requires=["requests<3.0,>2.27"], - python_requires=">=3.6", -) From 4753660528dfde7a9738593b260e6d18fa09fa35 Mon Sep 17 00:00:00 2001 From: Bomme <13520622+Bomme@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:12:45 +0100 Subject: [PATCH 2/3] Update installation instructions in Readme.md and add GitHub Actions workflow for publishing to PyPI --- .github/workflows/publish.yml | 48 +++++++++++++++++++++++++++++++++++ Readme.md | 15 ++++++++--- 2 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f00fb4c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,48 @@ +name: Publish to PyPI + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v5 + + - name: Install uv + uses: astral-sh/setup-uv@v7 + with: + version: "latest" + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Build package + run: uv build + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + publish: + needs: build + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write # Required for trusted publishing + + steps: + - name: Download artifacts + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/Readme.md b/Readme.md index 982776c..c7658bd 100644 --- a/Readme.md +++ b/Readme.md @@ -29,18 +29,25 @@ for sound in results: ``` ## Installation -1) clone or download -2) run: +The easiest way to install is using pip: + ``` -python setup.py install +pip install freesound ``` -Alternatively you should also be able to install directly from GitHub with: +Alternatively, you can install directly from GitHub: + ``` pip install git+https://github.com/MTG/freesound-python ``` +Or clone the repository and install manually: + +``` +python -m pip install . +``` + ## Advanced usage ### Modifying the requests' session: From 2e5f4c5fa68719662b2e35a01a9d42517d38282f Mon Sep 17 00:00:00 2001 From: Bomme <13520622+Bomme@users.noreply.github.com> Date: Sun, 2 Nov 2025 21:22:53 +0100 Subject: [PATCH 3/3] Update GitHub Actions workflow to use Ubuntu 22.04 for smoke tests python 3.7 is no longer supported in ubuntu-latest --- .github/workflows/python-smoke-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-smoke-test.yml b/.github/workflows/python-smoke-test.yml index 3d1213e..c484b5a 100644 --- a/.github/workflows/python-smoke-test.yml +++ b/.github/workflows/python-smoke-test.yml @@ -12,7 +12,7 @@ permissions: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: max-parallel: 1