Skip to content

Commit

Permalink
build: switch from setup.py to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
eginhard committed Jun 27, 2024
1 parent 64fec32 commit 2ca76cf
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 83 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ jobs:
run: python3 -m pip install --upgrade pip
- name: Install Coqpit
run: |
pip install -r requirements_dev.txt
pip install -e .
pip install -e .[dev]
- name: Lint check
run: make lint
- name: Unit tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Verify tag matches version
run: |
set -ex
version=$(cat VERSION)
version=$(grep -m 1 version pyproject.toml | grep -P '\d+\.\d+\.\d+' -o)
tag="${GITHUB_REF/refs\/tags\/}"
if [[ "v$version" != "$tag" ]]; then
exit 1
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include VERSION
include README.md
include LICENSE.txt
include requirements*.txt
recursive-include coqpit *.json
recursive-include coqpit *.html
recursive-include coqpit *.png
Expand Down
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

4 changes: 4 additions & 0 deletions coqpit/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
import importlib.metadata

from coqpit.coqpit import MISSING, Coqpit, check_argument, dataclass # noqa: F401

__version__ = importlib.metadata.version("coqpit")
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,50 @@
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.setuptools.packages.find]
include = ["coqpit*"]

[project]
name = "coqpit"
version = "0.0.17"
description = "Simple (maybe too simple), light-weight config management through python data-classes."
readme = "README.md"
requires-python = ">=3.9"
license = {text = "MIT"}
authors = [
{name = "Eren Gölge", email = "[email protected]"}
]
maintainers = [
{name = "Enno Hermann", email = "[email protected]"}
]
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
]
dependencies = []

[project.optional-dependencies]
# Development dependencies
dev = [
"coverage",
"pre-commit",
"pytest",
"ruff==0.4.2",
]

[project.urls]
Repository = "https://github.com/idiap/coqui-ai-coqpit"
Issues = "https://github.com/idiap/coqui-ai-coqpit/issues"

[tool.ruff]
target-version = "py39"
line-length = 120
Expand Down
4 changes: 0 additions & 4 deletions requirements_dev.txt

This file was deleted.

75 changes: 2 additions & 73 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,5 @@
#!/usr/bin/env python

import os
from setuptools import setup

import setuptools.command.build_py
import setuptools.command.develop
from setuptools import find_packages, setup

cwd = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(cwd, "VERSION")) as fin:
version = fin.read().strip()


class build_py(setuptools.command.build_py.build_py): # pylint: disable=too-many-ancestors
def run(self):
self.create_version_file()
setuptools.command.build_py.build_py.run(self)

@staticmethod
def create_version_file():
print("-- Building version " + version)
version_path = os.path.join(cwd, "version.py")
with open(version_path, "w") as f:
f.write(f"__version__ = '{version}'\n")


class develop(setuptools.command.develop.develop):
def run(self):
build_py.create_version_file()
setuptools.command.develop.develop.run(self)


with open("README.md", encoding="utf-8") as readme_file:
README = readme_file.read()


setup(
name="coqpit",
version=version,
url="https://github.com/erogol/coqpit",
author="Eren Gölge",
author_email="[email protected]",
maintainer="Enno Hermann",
maintainer_email="[email protected]",
description="Simple (maybe too simple), light-weight config management through python data-classes.",
long_description=README,
long_description_content_type="text/markdown",
license="",
include_package_data=True,
packages=find_packages(include=["coqpit*"]),
project_urls={
"Tracker": "https://github.com/idiap/coqui-ai-coqpit/issues",
"Repository": "https://github.com/idiap/coqui-ai-coqpit",
"Discussions": "https://github.com/idiap/coqui-ai-coqpit/discussions",
},
cmdclass={
"build_py": build_py,
"develop": develop,
},
install_requires=[],
python_requires=">=3.9.0",
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
],
zip_safe=False,
)
setup()

0 comments on commit 2ca76cf

Please sign in to comment.