Skip to content

Commit

Permalink
Merge pull request #117 from supermihi/modernize-tooling
Browse files Browse the repository at this point in the history
Modernize tooling
  • Loading branch information
supermihi authored Nov 17, 2023
2 parents 4fee8e6 + 11322ef commit ec7bdfe
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 55 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@ jobs:
- name: install pip dependencies (Linux)
if: ${{ runner.os == 'Linux' }}
run: |
python -m pip install --upgrade pip
pip install setuptools pytest Cython wheel
python -m pip install --upgrade pip build
- name: sdist (Linux)
if: ${{ runner.os == 'Linux' }}
run: python setup.py sdist
run: python -m build --sdist
- name: upload sdist (Linux)
uses: actions/upload-artifact@v3
if: ${{ runner.os == 'Linux' }}
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

## NEXT
- [!117](https://github.com/supermihi/pytaglib/pull/117): modernize packaging / tooling
- [!116](https://github.com/supermihi/pytaglib/pull/116): fix Python 3.12 build
## pytaglib 2.0.0 (2023-03-26)

- update Taglib version for binary wheels to 1.13
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include src/*.pxd
include src/*.pyx
include src/*.pyx
include tests/data/*
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ from the file.
Things are a bit more complicated than usual with Python because pytaglib requires the native (C++) TagLib library.

If there are no binary wheels for your platform, or you want to manually
compile pytaglib, you will need to have Taglib installed with development headers,and also development tools for Python.
compile pytaglib, you will need to have Taglib installed with development headers,
and also development tools for Python.

On Ubuntu, Mint and other Debian-Based distributions, install
the `libtag1-dev` and `python-dev` packages. On Fedora and friends, these are called `taglib-devel` and `python-devel`, respectively. On a Mac, use HomeBrew to install the `taglib` package. For Windows, see below.
Expand All @@ -81,9 +82,14 @@ You can download or checkout the sources and compile manually:

pip install .
# if you want to run the unit tests, use these commands instead
# pip install .[tests]
# pip install '.[tests]'
# python -m pytest

If you just want to create a binary wheel for your platform, use [build](https://github.com/pypa/build):

pip install --upgrade build # ensure build is installed
python -m build
which will place the wheel inside the `dist` directory.
### Compilation: Windows

Install MS Visual Studio Build Tools (or the complete IE) and include the correct compiler version as detailed [here](https://wiki.python.org/moin/WindowsCompilers). Also enable _cmake_ in the Visual Studio Installer.
Expand Down
39 changes: 37 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,43 @@
[build-system]
requires = ["setuptools", "wheel", "cython"]
requires = ["setuptools", "cython==3.0.*"]
build-backend = "setuptools.build_meta"

[project]
name = "pytaglib"
version = "2.0.0"
requires-python = ">=3.6"
description = "cross-platform, Python audio metadata (\"tagging\") library based on TagLib"
authors = [
{ name = "Michael Helmling", email = "[email protected]" }
]
readme = "Readme.md"
license = { text = "GPLv3+" }
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Cython",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules", ]

[project.urls]
Repository = "https://github.com/supermihi/pytaglib"
Issues = "https://github.com/supermihi/pytaglib/issues"
Changelog = "https://github.com/supermihi/pytaglib/blob/main/CHANGELOG.md"

[project.optional-dependencies]
tests = ["pytest~=7.4.3"]

[project.scripts]
pyprinttags = "pyprinttags:script"

[tool.setuptools]
package-dir = { "" = "src" }

[tool.cibuildwheel]
test-requires = "pytest"
test-extras = ["tests"]
test-command = "pytest {project}/tests"
before-build = "python build_taglib.py --clean"
48 changes: 2 additions & 46 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,25 @@
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation
#
"""Setup file for pytaglib. Type <python setup.py install> to install this package."""

import os
import platform
import re
import sys
from pathlib import Path

from Cython.Build import cythonize
from setuptools import setup, Extension

is_x64 = sys.maxsize > 2**32
is_x64 = sys.maxsize > 2 ** 32
arch = "x64" if is_x64 else "x32"
system = platform.system()
python_version = platform.python_version()
here = Path(__file__).resolve().parent
default_taglib_path = here / "build" / "taglib" / f"{system}-{arch}-py{python_version}"

CLASSIFIERS = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Cython",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Software Development :: Libraries :: Python Modules",
]

src = Path("src")


def readme():
readme_file = here / "README.md"
return readme_file.read_text("utf-8")


def extension_kwargs():
taglib_install_dir = Path(os.environ.get("TAGLIB_HOME", str(default_taglib_path)))
if sys.platform.startswith("win"):
Expand All @@ -69,34 +50,9 @@ def extension_kwargs():
)


def version():
taglib_pyx = here / src / "taglib.pyx"
version_match = re.search(
r"^version = ['\"]([^'\"]*)['\"]", taglib_pyx.read_text(), re.M
)
return version_match.group(1)


setup(
name="pytaglib",
description='cross-platform, Python audio metadata ("tagging") library based on TagLib',
long_description=readme(),
long_description_content_type="text/markdown",
classifiers=CLASSIFIERS,
version=version(),
license="GPLv3+",
author="Michael Helmling",
author_email="[email protected]",
url="http://github.com/supermihi/pytaglib",
ext_modules=cythonize(
[Extension("taglib", [str(src / "taglib.pyx")], **extension_kwargs())],
force=True,
),
package_dir={"": "src"},
py_modules=["pytaglib", "pyprinttags"],
entry_points={"console_scripts": ["pyprinttags=pyprinttags:script"]},
extras_require={
"tests": ["pytest"],
},
python_requires=">=3.6",
)
)

0 comments on commit ec7bdfe

Please sign in to comment.