From 8f89d741d6d549c64471823d2bd0ef236a9993a8 Mon Sep 17 00:00:00 2001 From: Oscar Vasquez Leiton Date: Tue, 30 Jul 2024 20:22:02 -0600 Subject: [PATCH] Fixed dependency on deprecated distutils package + Updated project to use pyproject.toml instead of setup.py --- LICENSE | 2 +- README.md | 11 +++--- docs/index.md | 11 +++--- mkdocsmerge/__init__.py | 2 +- mkdocsmerge/merge.py | 7 ++-- pyproject.toml | 46 ++++++++++++++++++++++++ setup.py | 77 ----------------------------------------- 7 files changed, 65 insertions(+), 91 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/LICENSE b/LICENSE index e456345..6306592 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Oscar Vasquez +Copyright (c) 2024 Oscar Vasquez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index f8ad0e5..3af3585 100644 --- a/README.md +++ b/README.md @@ -72,12 +72,11 @@ nav: ### Dev Install Clone the repository and specify the `dev` dependencies on the install command. - -Check this [StackOverflow answer](https://stackoverflow.com/a/28842733/2313246) for more details about the `dev` -dependencies +Project has been updated to use `pyproject.toml` so the version has to be manually synchronized in both `__init__.py` and `pyproject.toml`. ```bash -$ pip install -e .[dev] +# Using quotes for zsh compatibility +$ pip install -e '.[dev]' ``` ### Test @@ -88,6 +87,10 @@ The tests can be run using `tox` from the root directory. `tox` is part of the d $ tox ``` +### Publishing + +The publishing process was updated to use GitHub Actions. + ## Project Status Very basic implementation. The code works but doesn't allow to specify options for the merging. diff --git a/docs/index.md b/docs/index.md index df49778..76baa98 100644 --- a/docs/index.md +++ b/docs/index.md @@ -69,12 +69,11 @@ nav: ### Dev Install Clone the repository and specify the `dev` dependencies on the install command. - -Check this [StackOverflow answer](https://stackoverflow.com/a/28842733/2313246) for more details about the `dev` -dependencies +Project has been updated to use `pyproject.toml` so the version has to be manually synchronized. ```bash -$ pip install -e .[dev] +# Using quotes for zsh compatibility +$ pip install -e '.[dev]' ``` ### Test @@ -85,6 +84,10 @@ The tests can be run using `tox` from the root directory. `tox` is part of the d $ tox ``` +### Publishing + +The publishing process was updated to use GitHub Actions. + ## Project Status Very basic implementation. The code works but doesn't allow to specify options for the merging. diff --git a/mkdocsmerge/__init__.py b/mkdocsmerge/__init__.py index 1cab40f..a0aebdb 100644 --- a/mkdocsmerge/__init__.py +++ b/mkdocsmerge/__init__.py @@ -2,4 +2,4 @@ """Init module of MkDocs Merge""" -__version__ = '0.8.0' +__version__ = '0.9.0' diff --git a/mkdocsmerge/merge.py b/mkdocsmerge/merge.py index 279b9d4..949b10e 100644 --- a/mkdocsmerge/merge.py +++ b/mkdocsmerge/merge.py @@ -1,8 +1,7 @@ import os.path from ruamel.yaml import YAML -# Both imports are needed to avoid errors in Windows -import distutils -from distutils import dir_util +# Using the setuptools version because of the deprecation of the distutils package +import setuptools._distutils.dir_util as dir_util MKDOCS_YML = 'mkdocs.yml' CONFIG_NAVIGATION = 'nav' @@ -52,7 +51,7 @@ def merge_sites(sites, master_docs_root, unify_sites, print_func): # NOTE: need to do this otherwise subsequent distutil.copy_tree will fail if # mkdocs-merge is used as a module (https://stackoverflow.com/a/28055993/920464) - distutils.dir_util._path_created = {} + dir_util._path_created.clear() new_navs = [] for site in sites: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..0136a57 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,46 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "mkdocs-merge" +version = "0.9.0" +description = "Tool to merge multiple MkDocs sites into a single directory" +readme = "README.md" +license = { text = "MIT" } +authors = [ + { name = "Oscar Vasquez", email = "oscar@vasquezcr.com" } +] +keywords = ["mkdocs", "documentation", "merge", "multiple"] +classifiers = [ + "Development Status :: 4 - Beta", + "Topic :: Documentation", + "Topic :: Text Processing", + "Environment :: Console", + "Environment :: Web Environment", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10" +] +dependencies = [ + "click>=5.0", + "mkdocs>=1.0", + "ruamel.yaml>=0.17" +] + +[project.urls] +homepage = "https://github.com/ovasquez/mkdocs-merge" +repository = "https://github.com/ovasquez/mkdocs-merge" +download = "https://github.com/ovasquez/mkdocs-merge/archive/main.zip" + +[project.optional-dependencies] +dev = [ + "tox>=3.0", + "pytest", + "pytest-cov" +] + +[project.scripts] +mkdocs-merge = "mkdocsmerge.__main__:cli" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 3379a5a..0000000 --- a/setup.py +++ /dev/null @@ -1,77 +0,0 @@ -"""A simple setup module for MkDocs-Merge, based on the pip setup.py file. -See: -https://github.com/pypa/pip/blob/1.5.6/setup.py -""" - -import codecs -import os -import re -from setuptools import setup, find_packages - -HERE = os.path.abspath(os.path.dirname(__file__)) - - -def read(*parts): - # intentionally *not* adding an encoding option to open - # see: https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690 - return codecs.open(os.path.join(HERE, *parts), 'r').read() - - -def find_version(*file_paths): - version_file = read(*file_paths) - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", - version_file, re.M) - if version_match: - return version_match.group(1) - raise RuntimeError("Unable to find version string.") - - -REQUIREMENTS = ['click>=5.0', - 'mkdocs>=1.0', - 'ruamel.yaml>=0.17'] - -EXTRA_REQUIREMENTS = ['tox>=3.0', - 'pytest', - 'pytest-cov'] - -# Package description -setup( - name='mkdocs-merge', - version=find_version('mkdocsmerge', '__init__.py'), - description='Tool to merge multiple MkDocs sites into a single directory', - long_description=open('README.md', 'r').read(), - long_description_content_type='text/markdown', - url='https://github.com/ovasquez/mkdocs-merge', - download_url='https://github.com/ovasquez/mkdocs-merge/archive/main.zip', - license='MIT', - author='Oscar Vasquez', - author_email='oscar@vasquezcr.com', - keywords=['mkdocs', 'documentation', 'merge', 'multiple'], - packages=find_packages(), - include_package_data=True, - install_requires=REQUIREMENTS, - extras_require={ - 'dev': EXTRA_REQUIREMENTS - }, - entry_points={ - "console_scripts": [ - "mkdocs-merge = mkdocsmerge.__main__:cli" - ] - }, - classifiers=[ - # 3 - Alpha - # 4 - Beta - # 5 - Production/Stable - 'Development Status :: 4 - Beta', - 'Topic :: Documentation', - 'Topic :: Text Processing', - 'Environment :: Console', - 'Environment :: Web Environment', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - ], - zip_safe=False -)