Skip to content

Commit

Permalink
tasks, packaging: switch to pyproject.toml, remove setup.py
Browse files Browse the repository at this point in the history
Closes #753

Related: #803
  • Loading branch information
stanislaw committed Jan 5, 2023
1 parent 7369a35 commit 20540f8
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 158 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci-windows-powershell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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. ###
Expand Down
12 changes: 10 additions & 2 deletions check_environment.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pathlib
import sys

import pkg_resources
import toml

print(
"check_environment.py: "
Expand All @@ -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)
Expand Down
126 changes: 126 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
{ name = "Maryna Balioura", email = "[email protected]" },
]
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"
27 changes: 0 additions & 27 deletions requirements.development.txt

This file was deleted.

28 changes: 0 additions & 28 deletions requirements.txt

This file was deleted.

82 changes: 0 additions & 82 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion strictdoc/__init__.py
Original file line number Diff line number Diff line change
@@ -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__), "..")
Expand Down
26 changes: 13 additions & 13 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -82,6 +78,7 @@ def run_invoke_cmd(
result = context.run(
one_line_command(
"""
pip install toml &&
python3 check_environment.py
"""
),
Expand Down Expand Up @@ -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")
Expand All @@ -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}
"""
Expand All @@ -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)

Expand Down

0 comments on commit 20540f8

Please sign in to comment.