From 5cb351abfd8445ad7834c4e7faeeecff9e584a85 Mon Sep 17 00:00:00 2001 From: karlicoss Date: Mon, 2 Oct 2023 23:29:38 +0100 Subject: [PATCH] general: switch to use pyproject.toml --- .ci/release | 2 +- .github/workflows/main.yml | 4 +-- pyproject.toml | 59 ++++++++++++++++++++++++++++++++++++++ setup.py | 55 ----------------------------------- 4 files changed, 62 insertions(+), 58 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/.ci/release b/.ci/release index 95e41f4..6cff663 100755 --- a/.ci/release +++ b/.ci/release @@ -42,7 +42,7 @@ def main() -> None: if dist.exists(): shutil.rmtree(dist) - check_call('python3 setup.py sdist bdist_wheel', shell=True) + check_call(['python3', '-m', 'build']) TP = 'TWINE_PASSWORD' password = os.environ.get(TP) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 89338bd..271624d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,7 +80,7 @@ jobs: if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/master' env: TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD_TEST }} - run: pip3 install --user wheel twine && .ci/release --test + run: pip3 install --user --upgrade build twine && .ci/release --test - name: 'release to pypi' # always deploy tags to release pypi @@ -88,4 +88,4 @@ jobs: if: github.event_name != 'pull_request' && startsWith(github.event.ref, 'refs/tags') env: TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} - run: pip3 install --user wheel twine && .ci/release + run: pip3 install --user --upgrade build twine && .ci/release diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7fae398 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,59 @@ +[project] +dynamic = ["version"] # version is managed by setuptools_scm +name = "orgparse" +description = "orgparse - Emacs org-mode parser in Python" +license = {file = "LICENSE"} +authors = [ + {name = "Takafumi Arakaki (@tkf)", email = "aka.tkf@gmail.com"}, + {name = "Dmitrii Gerasimov (@karlicoss)", email = "karlicoss@gmail.com"}, +] +maintainers = [ + {name = "Dmitrii Gerasimov (@karlicoss)", email = "karlicoss@gmail.com"}, +] +keywords = ["org", "org-mode", "emacs"] +# see: http://pypi.python.org/pypi?%3Aaction=list_classifiers +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: BSD License", + "Topic :: Text Processing :: Markup", +] +# TODO add it back later, perhaps via ast? +# long_description=orgparse.__doc__, + +[project.urls] +Homepage = "https://github.com/karlicoss/orgparse" + +[project.optional-dependencies] +testing = [ + "pytest", +] +linting = [ + "pytest", + "mypy", + "lxml", # for mypy html coverage +] + + +[build-system] +requires = ["setuptools", "setuptools-scm"] +build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] +version_scheme = "python-simplified-semver" +local_scheme = "dirty-tag" + + +# nice things about pyproject.toml +# - zip_safe=False isn't neccessary anymore +# - correctly discovers namespace packages by defuilt? +# - correctly handles py.typed by default? +# - handles src layout automatically https://setuptools.pypa.io/en/latest/userguide/package_discovery.html#src-layout + +# things I'm not sure about yet +# - avoiding dupliation/variable reuse? +# - file/git dependencies? +# - unclear how to specify namespace package order https://github.com/seanbreckenridge/reorder_editable/issues/2 + +# TODO +# - maybe it has a nicer pypi upload system? not sure +# e.g. possibly use hatch/flit/pdb/poetry -- but not sure what's the benefit tbh diff --git a/setup.py b/setup.py deleted file mode 100644 index 5d500b1..0000000 --- a/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -# see https://github.com/karlicoss/pymplate for up-to-date reference -# -from setuptools import setup, find_namespace_packages # type: ignore - - -def main(): - pkgs = find_namespace_packages('src') - pkg = min(pkgs) - - setup( - name=pkg, - use_scm_version={ - 'version_scheme': 'python-simplified-semver', - 'local_scheme': 'dirty-tag', - }, - setup_requires=['setuptools_scm'], - - zip_safe=False, - - packages=pkgs, - package_dir={'': 'src'}, - package_data={ - pkg: ['py.typed'], # todo need the rest as well?? - 'orgparse.tests.data': ['*.org'], - }, - - author='Takafumi Arakaki, Dmitrii Gerasimov', - author_email='aka.tkf@gmail.com', - maintainer='Dima Gerasimov (@karlicoss)', - maintainer_email='karlicoss@gmail.com', - - url='https://github.com/karlicoss/orgparse', - license='BSD License', - - description='orgparse - Emacs org-mode parser in Python', - # TODO add it back later, perhaps via ast? - # long_description=orgparse.__doc__, - - keywords='org org-mode emacs', - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'License :: OSI Approved :: BSD License', - 'Topic :: Text Processing :: Markup', - # see: http://pypi.python.org/pypi?%3Aaction=list_classifiers - ], - - extras_require={ - 'testing': ['pytest'], - 'linting': ['pytest', 'mypy', 'lxml'], # lxml for mypy coverage report - }, - ) - - -if __name__ == '__main__': - main()