Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for setup.cfg configuration writer #1201

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Pylint 2.17.x configuration file
# Pylint 3.0.x configuration file
#
# This file is generated by l2tdevtools update-dependencies.py, any dependency
# related changes should be made in dependencies.ini.
Expand Down Expand Up @@ -85,15 +85,14 @@ limit-inference-results=100

# List of plugins (as comma separated values of python module names) to load,
# usually to register additional checkers.
# load-plugins=
load-plugins=pylint.extensions.docparams

# Pickle collected data for later comparisons.
persistent=yes

# Minimum Python version to use for version dependent checks. Will default to
# the version used to run pylint.
py-version=3.11
py-version=3.12

# Discover python modules and packages in the file system subtree.
# recursive=no
Expand Down Expand Up @@ -441,6 +440,7 @@ confidence=HIGH,
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use "--disable=all --enable=classes
# --disable=W".

disable=assignment-from-none,
bad-inline-option,
consider-using-f-string,
Expand Down Expand Up @@ -468,6 +468,8 @@ disable=assignment-from-none,
too-many-return-statements,
too-many-statements,
unsubscriptable-object,
use-implicit-booleaness-not-comparison-to-string,
use-implicit-booleaness-not-comparison-to-zero,
useless-object-inheritance,
useless-suppression,
use-symbolic-message-instead
Expand Down Expand Up @@ -522,8 +524,9 @@ evaluation=max(0, 0 if fatal else 10.0 - ((float(5 * error + warning + refactor
# used to format the message information. See doc for all details.
msg-template=

# Set the output format. Available formats are text, parseable, colorized, json
# and msvs (visual studio). You can also give a reporter class, e.g.
# Set the output format. Available formats are: text, parseable, colorized,
# json2 (improved json format), json (old json format) and msvs (visual
# studio). You can also give a reporter class, e.g.
# mypackage.mymodule.MyReporterClass.
#output-format=

Expand Down
3 changes: 3 additions & 0 deletions data/templates/setup.cfg/bdist_rpm
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[bdist_rpm]
release = 1
packager = ${maintainer}
doc_files =
${doc_files}
build_requires = python3-setuptools
requires =
${requires}

11 changes: 1 addition & 10 deletions data/templates/setup.cfg/metadata
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ${python_module_name}
version = 20230506
version = ${version}
description = ${description_short}
long_description = ${description_long}
long_description_content_type = text/plain
Expand All @@ -23,12 +23,3 @@ package_dir =
${python_module_name} = ${python_module_name}
packages = find:
python_requires = >=3.7

[options.packages.find]
exclude =
docs
tests
tests.*
utils
where = .

4 changes: 4 additions & 0 deletions data/templates/setup.cfg/options_package_data
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[options.package_data]
${python_module_name} =
${package_data}
9 changes: 9 additions & 0 deletions data/templates/setup.cfg/options_packages_find
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

[options.packages.find]
exclude =
docs
tests
tests.*
utils
where = .

2 changes: 2 additions & 0 deletions data/templates/setup.cfg/options_scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scripts =
${scripts}
57 changes: 50 additions & 7 deletions l2tdevtools/dependency_writers/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""Writer for setup configuration and script files."""

import datetime
import glob
import os

Expand Down Expand Up @@ -87,6 +88,9 @@ def _GenerateFromTemplate(self, template_filename, template_mappings):

def Write(self):
"""Writes a setup.cfg file."""
description_long = ' '.join(
self._project_definition.description_long.split('\n'))

if self._project_definition.status == 'experimental':
development_status = 'Development Status :: 2 - Pre-Alpha'
elif self._project_definition.status == 'alpha':
Expand All @@ -103,8 +107,6 @@ def Write(self):

formatted_doc_files = [
f' {doc_file:s}' for doc_file in sorted(doc_files)]
if formatted_doc_files:
formatted_doc_files.insert(0, 'doc_files =')

maintainer_name, _, maintainer_email = (
self._project_definition.maintainer.partition('<'))
Expand All @@ -120,28 +122,69 @@ def Write(self):

formatted_requires = [
f' {dependency:s}' for dependency in python3_dependencies]
if formatted_requires:
formatted_requires.insert(0, 'requires =')

formatted_requires.append('')
package_data = []
for data_file in glob.glob(
f'{python_module_name:s}/**/*.yaml', recursive=True):
data_file_directory = os.path.dirname(
data_file[len(f'{python_module_name:s}/'):])
data_file = f'{data_file_directory:s}/*.yaml'
if data_file not in package_data:
package_data.append(data_file)

formatted_package_data = [
f' {data_file:s}' for data_file in sorted(package_data)]

scripts_directory = None
if os.path.isdir('scripts'):
scripts_directory = 'scripts'
elif os.path.isdir('tools'):
scripts_directory = 'tools'

scripts = []
if scripts_directory:
scripts = glob.glob(f'{scripts_directory:s}/[a-z]*.py')

formatted_scripts = [
f' {script:s}' for script in sorted(scripts)]

date_time = datetime.datetime.now()
version = date_time.strftime('%Y%m%d')

template_mappings = {
'description_long': self._project_definition.description_long,
'description_long': description_long,
'description_short': self._project_definition.description_short,
'development_status': development_status,
'doc_files': '\n'.join(formatted_doc_files),
'homepage_url': self._project_definition.homepage_url,
'maintainer': self._project_definition.maintainer,
'maintainer_email': maintainer_email,
'maintainer_name': maintainer_name,
'package_data': '\n'.join(formatted_package_data),
'python_module_name': python_module_name,
'requires': '\n'.join(formatted_requires)}
'requires': '\n'.join(formatted_requires),
'scripts': '\n'.join(formatted_scripts),
'version': version}

file_content = []

template_data = self._GenerateFromTemplate('metadata', template_mappings)
file_content.append(template_data)

if scripts:
template_data = self._GenerateFromTemplate(
'options_scripts', template_mappings)
file_content.append(template_data)

if package_data:
template_data = self._GenerateFromTemplate(
'options_package_data', template_mappings)
file_content.append(template_data)

template_data = self._GenerateFromTemplate(
'options_packages_find', template_mappings)
file_content.append(template_data)

if self._project_definition.name in self._PROJECTS_WITH_SDIST_TEST_DATA:
template_data = self._GenerateFromTemplate(
'sdist_test_data', template_mappings)
Expand Down
25 changes: 12 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ package_dir =
l2tdevtools = l2tdevtools
packages = find:
python_requires = >=3.7

[options.package_data]
l2tdevtools =
data/*.ini
data/dpkg_templates/*
data/licenses/*
data/rpm_templates/*
data/templates/.pylintrc
data/templates/*.sh
data/templates/appveyor.yml/*
data/templates/setup.cfg/*
data/templates/setup.py/*
data/templates/tox.ini/*
scripts =
tools/build.py
tools/develop.py
tools/dpkg-generate.py
tools/manage.py
tools/review.py
tools/schema_extractor.py
tools/stats.py
tools/update-dependencies.py
tools/update.py

[options.packages.find]
exclude =
Expand All @@ -54,6 +51,8 @@ doc_files =
LICENSE
README
build_requires = python3-setuptools
requires =


[bdist_wheel]
universal = 1