Skip to content

Commit

Permalink
Merge pull request #380 from melexis/build-module
Browse files Browse the repository at this point in the history
Modernize setup.py based build system
  • Loading branch information
Letme authored Jul 3, 2024
2 parents 3c633fe + a325d1b commit 89853c2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
42 changes: 27 additions & 15 deletions mlx/traceability/directives/item_pie_chart_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,31 @@ def _get_explode_values(labels, label_set):
explode[uncovered_index] = 0.05
return explode

def _determine_headings(self, app):
"""Determine the table headings with either custom titles and/or the regexp patterns from id_set.
Note: If not enough custom titles are provided, the regexp patterns are used for completion.
Return:
list[nodes.entry]: Header cells
bools: True to add a fourth column with relevant info about each nested target item, False otherwise
"""
add_result_column = bool(self.nested_target_regex.pattern) and \
(bool(self['attribute']) or bool(self['targettype']))
titles = []
for title, pattern in zip_longest(self['matrixtitles'], self['id_set'], fillvalue=None):
if title is not None:
titles.append(nodes.paragraph('', title))
else:
titles.append(nodes.paragraph('', pattern))
if add_result_column and len(titles) < 4:
if self['attribute']:
titles.append(self.make_attribute_ref(app, self['attribute']))
else:
titles.append(nodes.paragraph('', '')) # only targettype option used; cannot assume a suitable title
headings = [nodes.entry('', title) for title in titles]
return headings, add_result_column

def build_table(self, app):
""" Builds a table node for the 'matrix' option
Expand All @@ -419,21 +444,8 @@ def build_table(self, app):
if self.get('classes'):
table.get('classes').extend(self.get('classes'))
# Column and heading setup
add_result_column = bool(self.nested_target_regex.pattern) and \
(bool(self['attribute']) or bool(self['targettype']))
titles = []
for title, pattern in zip_longest(self['matrixtitles'], self['id_set'], fillvalue=None):
if title is not None:
titles.append(nodes.paragraph('', title))
else:
titles.append(nodes.paragraph('', pattern))
if add_result_column and len(titles) < 4:
if self['attribute']:
titles.append(self.make_attribute_ref(app, self['attribute']))
else:
titles.append(nodes.paragraph('', '')) # only targettype option used; cannot assume a suitable title
headings = [nodes.entry('', title) for title in titles]
number_of_columns = len(titles)
headings, add_result_column = self._determine_headings(app)
number_of_columns = len(headings)
tgroup = nodes.tgroup()
tgroup += [nodes.colspec(colwidth=5) for _ in range(number_of_columns)]
tgroup += nodes.thead('', nodes.row('', *headings))
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = ["setuptools>=61", "setuptools_scm>=7.1.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "mlx/traceability/__traceability_version__.py"
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

setup(
name='mlx.traceability',
use_scm_version={
'write_to': 'mlx/traceability/__traceability_version__.py'
},
setup_requires=['setuptools_scm'],
url=project_url,
license='GNU General Public License v3 (GPLv3)',
author='Melexis',
Expand Down Expand Up @@ -47,15 +43,16 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Topic :: Documentation',
'Topic :: Documentation :: Sphinx',
'Topic :: Utilities',
],
platforms='any',
packages=find_namespace_packages(include=['mlx.*']),
packages=find_namespace_packages(where="."),
package_dir={"": "."},
include_package_data=True,
install_requires=requires,
namespace_packages=['mlx'],
keywords=[
'traceability',
'requirements engineering',
Expand Down
9 changes: 6 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py37, py38, py39, py310, py311
py37, py38, py39, py310, py311, py312
clean,
check,
{sphinx2.4.5,sphinx-latest},
Expand All @@ -12,6 +12,7 @@ python =
3.9: py39
3.10: py310
3.11: py311
3.12: py312

[testenv]
basepython =
Expand All @@ -22,6 +23,7 @@ basepython =
py39: {env:TOXPYTHON:python3.9}
py310: {env:TOXPYTHON:python3.10}
py311: {env:TOXPYTHON:python3.11}
py312: {env:TOXPYTHON:python3.12}
{clean,check,report,coveralls,codecov}: python3
{sphinx2.4.5,sphinx-latest}: python3
setenv =
Expand All @@ -45,15 +47,16 @@ commands=

[testenv:check]
deps =
docutils
setuptools
twine
check-manifest
flake8
readme-renderer
pygments
build
skip_install = true
commands =
python setup.py sdist
python -m build
twine check dist/*
check-manifest {toxinidir} -u
flake8 mlx tests setup.py --per-file-ignores '\
Expand Down

0 comments on commit 89853c2

Please sign in to comment.