From efe15dfdd63b09150a9db2742ac0c415adc75da3 Mon Sep 17 00:00:00 2001 From: Jonas Weich Date: Sat, 2 Nov 2024 00:06:24 +0100 Subject: [PATCH] [TOOL] Migrate build backend from setuptools to hatchling (#146) * Move project config to pyproject.toml * Avoid double maintenance of dependencies * Pin minimal dependency versions * Update gh workflows --- .github/workflows/mypy.yml | 2 +- .github/workflows/pypi-publish.yml | 4 +- .github/workflows/test-coverage.yml | 4 +- .github/workflows/test.yml | 2 +- README.md | 2 +- chatminer/__init__.py | 2 +- pyproject.toml | 80 ++++++++++++++++++++++++++++- requirements.txt | 7 --- setup.cfg | 52 ------------------- setup.py | 16 ------ 10 files changed, 86 insertions(+), 85 deletions(-) delete mode 100644 requirements.txt delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 0b75182..2398564 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -17,7 +17,7 @@ jobs: run: | python -m pip install --upgrade pip pip install mypy - pip install -r requirements.txt + pip install . - name: Run MyPy run: | mypy chatminer/ --install-types --non-interactive --ignore-missing-imports \ No newline at end of file diff --git a/.github/workflows/pypi-publish.yml b/.github/workflows/pypi-publish.yml index dcd82d8..d1d8d64 100644 --- a/.github/workflows/pypi-publish.yml +++ b/.github/workflows/pypi-publish.yml @@ -21,9 +21,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install build + pip install hatch - name: Build package - run: python -m build + run: hatch build - name: Publish package uses: pypa/gh-action-pypi-publish@f7600683efdcb7656dec5b29656edb7bc586e597 with: diff --git a/.github/workflows/test-coverage.yml b/.github/workflows/test-coverage.yml index 22cfabd..695aa6e 100644 --- a/.github/workflows/test-coverage.yml +++ b/.github/workflows/test-coverage.yml @@ -13,12 +13,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt + pip install . - name: Generate coverage report run: | pip install pytest pip install pytest-cov - pytest --cov=chatminer --cov-config=setup.cfg --cov-report=xml test/ + pytest --cov=chatminer --cov-report=xml test/ - name: Upload coverage to Codecov uses: codecov/codecov-action@v4 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3d5d440..548775f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt + pip install . - name: Test with pytest run: | pip install pytest diff --git a/README.md b/README.md index dba438d..58fb7d1 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ If you're interested in contributing, running the latest source code, or just li ```sh git clone https://github.com/joweich/chat-miner.git cd chat-miner -pip install -r requirements.txt +pip install . ``` ## 2. Exporting chat logs diff --git a/chatminer/__init__.py b/chatminer/__init__.py index fa984fe..e278e5d 100644 --- a/chatminer/__init__.py +++ b/chatminer/__init__.py @@ -14,4 +14,4 @@ # Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer. # 'X.Y.dev0' is the canonical version of 'X.Y.dev' # -__version__ = "0.5.3" +__version__ = "0.5.4" diff --git a/pyproject.toml b/pyproject.toml index 638dd9c..eac44fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,79 @@ [build-system] -requires = ["setuptools>=61.0"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "chat-miner" +dynamic = ["version"] +description = "Lean parsers and visualizations for chat data." +readme = "README.md" +license = "MIT" +requires-python = ">=3.8" +authors = [ + { name = "Jonas Weich", email = "jns.wch@gmail.com" }, +] +maintainers = [ + { name = "Jonas Weich", email = "jns.wch@gmail.com" }, +] +keywords = [ + "chat", + "chatdata", + "messenger", + "parser", + "wordcloud", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Science/Research", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "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", +] +dependencies = [ + "argparse", + "polars[pandas]>=1.0", + "numpy>=1.6.1", + "matplotlib>=3.4", + "wordcloud>=1.9.3", + "python-dateutil>=2.8.2", + "tqdm>=4.66.0", +] + +[project.optional-dependencies] +nlp = [ + "transformers>=4.40", +] + +[project.scripts] +chatminer = "chatminer.cli:main" + +[project.urls] +"Bug Tracker" = "https://github.com/joweich/chat-miner/issues" +"Source Code" = "https://github.com/joweich/chat-miner" + +[tool.hatch.version] +path = "chatminer/__init__.py" + +[tool.hatch.build.targets.sdist] +include = ["/chatminer"] + +[tool.hatch.build.targets.wheel] +packages = ["/chatminer"] + +[tool.coverage.run] +source = ["chatminer"] +omit = [ + "chatminer/cli.py", + "chatminer/nlp.py", + "chatminer/visualizations.py", + "chatminer/__init__.py", +] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index c6ae03d..0000000 --- a/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -polars[pandas]>=1.0 -numpy -matplotlib -wordcloud -python-dateutil -tqdm -transformers \ No newline at end of file diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 493d767..0000000 --- a/setup.cfg +++ /dev/null @@ -1,52 +0,0 @@ -[metadata] -name = chat-miner -version = attr: chatminer.__version__ -license = MIT -license_files = LICENSE -long_description = file: README.md -long_description_content_type = text/markdown; charset=UTF-8; variant=GFM -description = Lean parsers and visualizations for chat data -maintainer = Jonas Weich -maintainer_email = jns.wch@gmail.com -author = Jonas Weich -author_email = jns.wch@gmail.com -platforms = any -classifiers = - Development Status :: 4 - Beta - Environment :: Console - Intended Audience :: Science/Research - Intended Audience :: End Users/Desktop - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - 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 -project_urls = - Bug Tracker = https://github.com/joweich/chat-miner/issues - Source Code = https://github.com/joweich/chat-miner - -[options] -python_requires = >=3.8 -install_requires = - polars[pandas] - numpy - matplotlib - wordcloud - python-dateutil - tqdm - -[options.extras_require] -NLP = - transformers - -[coverage:run] -omit = - chatminer/cli.py - chatminer/nlp.py - chatminer/visualizations.py - chatminer/__init__.py diff --git a/setup.py b/setup.py deleted file mode 100755 index b20fe40..0000000 --- a/setup.py +++ /dev/null @@ -1,16 +0,0 @@ -from setuptools import find_packages, setup - -setup( - name="chat-miner", - description="chat-miner provides lean parsers for every major platform transforming chats into dataframes.\ - Artistic visualizations allow you to explore your data and create artwork from your chats.", - packages=find_packages(), - install_requires=[ - "argparse", - ], - entry_points={ - "console_scripts": [ - "chatminer = chatminer.cli:main", - ], - }, -)