From 20540f8fb12cd63d7c6db0a5bc7d3d2c73863e0a Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Thu, 5 Jan 2023 14:07:55 +0100 Subject: [PATCH 1/2] tasks, packaging: switch to pyproject.toml, remove setup.py Closes #753 Related: #803 --- .github/workflows/ci-windows-powershell.yml | 3 +- .github/workflows/ci-windows.yml | 3 +- .gitignore | 3 +- check_environment.py | 12 +- pyproject.toml | 126 ++++++++++++++++++++ requirements.development.txt | 27 ----- requirements.txt | 28 ----- setup.py | 82 ------------- strictdoc/__init__.py | 2 +- tasks.py | 26 ++-- 10 files changed, 154 insertions(+), 158 deletions(-) create mode 100644 pyproject.toml delete mode 100644 requirements.development.txt delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/ci-windows-powershell.yml b/.github/workflows/ci-windows-powershell.yml index a58ecdb19..2f0bc80ab 100644 --- a/.github/workflows/ci-windows-powershell.yml +++ b/.github/workflows/ci-windows-powershell.yml @@ -34,8 +34,7 @@ jobs: - name: Install dependencies run: | - pip install -r requirements.txt - pip install -r requirements.development.txt + pip install .[development] - name: Run tests (Powershell) run: | diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 3210ee473..f2d4c3313 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -34,8 +34,7 @@ jobs: - name: Install dependencies run: | - pip install -r requirements.txt - pip install -r requirements.development.txt + pip install .[development] - name: Run Lint tasks run: | diff --git a/.gitignore b/.gitignore index 37ba19ce2..9c430e205 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,8 @@ output.zip .vscode ### StrictDoc's default export path -**/output/** +output/** +developer/**/output/** tests/unit_server/**/output/** ### LIT/FileCheck integration tests' artifacts. ### diff --git a/check_environment.py b/check_environment.py index 53a19d5f6..518b7902b 100644 --- a/check_environment.py +++ b/check_environment.py @@ -1,6 +1,8 @@ +import pathlib import sys import pkg_resources +import toml print( "check_environment.py: " @@ -12,8 +14,14 @@ # Quicker way of checking if an environment has all packages installed. # It is faster than running pip install ... every time. # https://stackoverflow.com/a/65606063/598057 - pkg_resources.require(open("requirements.txt", mode="r")) - pkg_resources.require(open("requirements.development.txt", mode="r")) + # Modified to read from pyproject.toml, not requirements.txt file. + pyproject_content = toml.load("pyproject.toml") + dependencies = pyproject_content["project"]["dependencies"] + dependencies_development = pyproject_content["project"][ + "optional-dependencies" + ]["development"] + pkg_resources.require(dependencies) + pkg_resources.require(dependencies_development) except pkg_resources.DistributionNotFound as exception: print(f"check_environment.py: {exception}") sys.exit(11) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..25b692965 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,126 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.version] +path = "strictdoc/__init__.py" + +#[tool.hatch.build.targets.sdist] +#include = [ +# "/uvicorn", +#] + +[project] +name = "strictdoc" +dynamic = ["version"] +description = "Open-source software for writing technical requirements specifications." +readme = "README.md" +license = "Apache-2.0" +requires-python = ">=3.7" +authors = [ + { name = "Stanislav Pankevich", email = "s.pankevich@gmail.com" }, + { name = "Maryna Balioura", email = "mettta@gmail.com" }, +] +classifiers = [ + # "Development Status :: 4 - Beta", + # "Environment :: Web Environment", + # "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + # "Topic :: Internet :: WWW/HTTP", +] +dependencies = [ + "textx >= 3.0.0, == 3.*", + "jinja2 >= 2.11.2", + # FIXME: This might be not relevant anymore. + # https://github.com/aws/aws-sam-cli/issues/3661#issuecomment-1044340547 + "MarkupSafe == 2.0.1", + + "docutils >= 0.16, == 0.*", + "python-datauri >= 0.2.9, == 0.*", + "beautifulsoup4 >= 4.9.3, == 4.*", + "pygments >= 2.10.0, == 2.*", + + "lxml >= 4.6.2, == 4.*", + + # Excel + "XlsxWriter >= 1.3.7, == 1.*", + "xlrd >= 2.0.1, == 2.*", + + # reqif and strictdoc share the same development cycle and both still stay + # within their 0.0.* versions. Hardcoding until both projects start to track the + # backward incompatible API updates by MAJOR and MINOR version components. + "reqif == 0.0.21, == 0.*", + + # Bibtex + "pybtex >= 0.23.0, == 0.*", + + # Web server dependencies + "fastapi >= 0.83.0", + # FastAPI: To receive uploaded files and/or form data, first install python-multipart. + "python-multipart", + "uvicorn[standard] >= 0.14.0", + "WebSockets", +] + +[project.optional-dependencies] +development = [ + # Development tasks + "invoke>=1.4.1", + "toml", + # Reload files when changed + "watchdog>=2.1.7", + + # Packaging + "build", + "twine", + + # Linters and static analysis + "black>=21.9b0", + "mypy>=0.910", + "pylint>=2.11.1", + "flake8>=3.9.2", + + # Tests + "pytest>=6.2.2", + "pyfakefs>=4.5.5", + "coverage>=5.4", + "lit>=0.11.0.post1", + "filecheck>=0.0.20", + # Tests: Validating content + "html5lib>=1.1", + "pytidylib>=0.3.2", + "openpyxl>=3.0.5", + + # Documentation + "sphinx>=3.2.1", + "guzzle_sphinx_theme~=0.7.11", + + # Used by the dead links checker + "requests>=2.27.1", + + # Server-related + "seleniumbase", + # httpx is needed for running server-related unit tests. + "httpx", + # psutil is needed to reap Uvicorn's zombie processes when running end2end + # tests. One day someone finds a better solution. + "psutil", +] + +[project.scripts] +strictdoc = "strictdoc.cli.main:main" + +[project.urls] +Changelog = "https://github.com/strictdoc-project/strictdoc/blob/main/CHANGELOG.md" +# Funding = "https://..." +Homepage = "https://strictdoc.readthedocs.io/en/stable/" +Source = "https://github.com/strictdoc-project/strictdoc" diff --git a/requirements.development.txt b/requirements.development.txt deleted file mode 100644 index 1c5774dc9..000000000 --- a/requirements.development.txt +++ /dev/null @@ -1,27 +0,0 @@ -wheel -twine -coverage>=5.4 -invoke>=1.4.1 -pytest>=6.2.2 -lit>=0.11.0.post1 -mypy>=0.910 -filecheck>=0.0.20 -black>=21.9b0 -pylint>=2.11.1 -flake8>=3.9.2 -sphinx>=3.2.1 -guzzle_sphinx_theme~=0.7.11 -html5lib>=1.1 -pytidylib>=0.3.2 -openpyxl>=3.0.5 -pyfakefs>=4.5.5 -requests>=2.27.1 -watchdog>=2.1.7 - -# Server-related -seleniumbase -# httpx is needed for running server-related unit tests. -httpx -# psutil is needed to reap Uvicorn's zombie processes when running end2end -# tests. One day someone finds a better solution. -psutil diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5213af6b0..000000000 --- a/requirements.txt +++ /dev/null @@ -1,28 +0,0 @@ -dataclasses == 0.7; python_version >= "3.6" and python_version < "3.7" and python_full_version >= "3.6.2" or python_version >= "3.6" and python_version < "3.7" -textx >= 3.0.0, == 3.* -jinja2 >= 2.11.2 - -# Web server dependencies -fastapi >= 0.83.0 -# FastAPI: To receive uploaded files and/or form data, first install python-multipart. -python-multipart -uvicorn[standard] >= 0.14.0 -WebSockets - -# https://github.com/aws/aws-sam-cli/issues/3661#issuecomment-1044340547 -MarkupSafe == 2.0.1 - -docutils >= 0.16, == 0.* -XlsxWriter >= 1.3.7, == 1.* -python-datauri >= 0.2.9, == 0.* -beautifulsoup4 >= 4.9.3, == 4.* -pygments >= 2.10.0, == 2.* -lxml >= 4.6.2, == 4.* - -# reqif and strictdoc share the same development cycle and both still stay -# within their 0.0.* versions. Hardcoding until both projects start to track the -# backward incompatible API updates by MAJOR and MINOR version components. -reqif == 0.0.21, == 0.* - -xlrd >= 2.0.1, == 2.* -pybtex >= 0.23.0, == 0.* diff --git a/setup.py b/setup.py deleted file mode 100644 index 006440c35..000000000 --- a/setup.py +++ /dev/null @@ -1,82 +0,0 @@ -# -*- coding: utf-8 -*- - -from setuptools import find_packages, setup - -import strictdoc - -package_data = { - "": ["requirements.txt", "requirements.development.txt"], - # It looks like the package data in setup.py does not support globbing - # (see pypa/setuptools#1806, https://github.com/pypa/setuptools/issues/1806) - # Doing the globbing manually for now. - # https://stackoverflow.com/questions/27664504/how-to-add-package-data-recursively-in-python-setup-py - # TODO: Can be better. - "strictdoc.export.html": [ - "*", - "*/*", - "*/*/*", - "*/*/*/*", - "*/*/*/*/*", - "*/*/*/*/*/*", - ], - "strictdoc.export.rst": [ - "*", - "*/*", - "*/*/*", - "*/*/*/*", - "*/*/*/*/*", - "*/*/*/*/*/*", - ], -} - -with open("requirements.txt") as fp: - REQUIREMENTS = fp.read() - -with open("requirements.development.txt") as fp: - REQUIREMENTS_DEVELOPMENT = {"development": fp.read()} - -REQUIREMENTS_SETUP = [ - "wheel", -] - - -extras_require = { - ':python_version >= "3.6" and python_version < "3.7"': [ - "dataclasses>=0.7,<0.8" - ] -} - -entry_points = {"console_scripts": ["strictdoc = strictdoc.cli.main:main"]} - -setup_kwargs = { - "name": "strictdoc", - "version": strictdoc.__version__, - "description": "Software for writing technical requirements and specifications.", - "long_description": "Software for writing technical requirements and specifications.", - "author": "Stanislav Pankevich", - "author_email": "s.pankevich@gmail.com", - "maintainer": "Stanislav Pankevich", - "maintainer_email": "s.pankevich@gmail.com", - "url": "https://github.com/stanislaw/strictdoc", - "packages": find_packages( - where=".", - exclude=[ - "tests*", - ], - ), - # 'package_dir': {"": "strictdoc"}, - # package_data - defines files related to the python package, e.g., - # documentation, static image files, configurations. - # data_files - defines files that will be installed system-wise, not in - # site-package directory. eg. desktop icons, fonts. - # https://stackoverflow.com/a/66370532/598057 - "package_data": package_data, - "data_files": [], - "install_requires": REQUIREMENTS, - "extras_require": REQUIREMENTS_DEVELOPMENT, - "setup_requires": REQUIREMENTS_SETUP, - "entry_points": entry_points, - "python_requires": ">=3.6.2,<4.0.0", -} - -setup(**setup_kwargs) diff --git a/strictdoc/__init__.py b/strictdoc/__init__.py index c20e73aef..3ed170888 100644 --- a/strictdoc/__init__.py +++ b/strictdoc/__init__.py @@ -1,6 +1,6 @@ import os -__version__ = "0.0.30" +__version__ = "0.0.31-alpha.2" STRICTDOC_ROOT_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), "..") diff --git a/tasks.py b/tasks.py index ce4d96029..585edeb1b 100644 --- a/tasks.py +++ b/tasks.py @@ -19,11 +19,7 @@ # only once independently of which task or a sequence of tasks is executed. VENV_DEPS_CHECK_PASSED = "VENV_DEPS_CHECK_PASSED" -COMMAND_SETUP_DEPS = """ - pip install --upgrade pip setuptools && - pip install -r requirements.txt && - pip install -r requirements.development.txt -""" +COMMAND_SETUP_DEPS = "pip install .[development]" def one_line_command(string): @@ -82,6 +78,7 @@ def run_invoke_cmd( result = context.run( one_line_command( """ + pip install toml && python3 check_environment.py """ ), @@ -440,9 +437,10 @@ def release_local(context): context[VENV_FOLDER] = VenvFolderType.RELEASE_LOCAL command = """ rm -rfv dist/ build/ && - python3 -m pip uninstall strictdoc -y && - python3 setup.py check && - python3 setup.py install + pip uninstall strictdoc -y && + python3 -m build && + twine check dist/* && + pip install dist/*.tar.gz """ run_invoke_cmd(context, command) test_integration(context, strictdoc="strictdoc") @@ -455,8 +453,8 @@ def release(context, username=None, password=None): context[VENV_FOLDER] = VenvFolderType.RELEASE_PYPI command = f""" rm -rfv dist/ && - python3 setup.py check && - python3 setup.py sdist --verbose && + python3 -m build && + twine check dist/* && twine upload dist/strictdoc-*.tar.gz {user_password} """ @@ -470,9 +468,11 @@ def release_test(context): command = """ rm -rfv dist/ && - python3 setup.py check && - python3 setup.py sdist --verbose && - twine upload --repository-url https://test.pypi.org/legacy/ dist/strictdoc-*.tar.gz + python3 -m build && + twine check dist/* && + twine upload + --repository-url + https://test.pypi.org/legacy/ dist/strictdoc-*.tar.gz """ run_invoke_cmd(context, command) From f89ba14c9521d83aa713b83beeaae2886b809565 Mon Sep 17 00:00:00 2001 From: Stanislav Pankevich Date: Thu, 5 Jan 2023 18:47:05 +0100 Subject: [PATCH 2/2] Bump version to 0.0.31 --- strictdoc/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strictdoc/__init__.py b/strictdoc/__init__.py index 3ed170888..48081f261 100644 --- a/strictdoc/__init__.py +++ b/strictdoc/__init__.py @@ -1,6 +1,6 @@ import os -__version__ = "0.0.31-alpha.2" +__version__ = "0.0.31" STRICTDOC_ROOT_PATH = os.path.abspath( os.path.join(os.path.dirname(__file__), "..")