Skip to content

Commit

Permalink
Merge pull request #276 from zopefoundation/dataflake/pyproject.toml
Browse files Browse the repository at this point in the history
Add ``pyproject.toml`` to the list of managed files
  • Loading branch information
dataflake authored Sep 4, 2024
2 parents e881775 + 1453d98 commit 4f2eaaf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 11 deletions.
23 changes: 12 additions & 11 deletions config/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,27 @@ See ``--help`` for details.

The script does the following steps:

1. Add the package name to ``packages.txt`` of the selected configuration type
#. Add the package name to ``packages.txt`` of the selected configuration type
if it is not yet added.
2. Copy ``setup.cfg``, ``tox.ini``, ``tests.yml``, ``MANIFEST.in``,
#. Copy ``setup.cfg``, ``tox.ini``, ``tests.yml``, ``MANIFEST.in``,
``.readthedocs.yaml`` (if needed), and ``.gitignore`` to the repository.
3. Remove a possibly existing ``.coveragerc`` and ``bootstrap.py``. (Coverage
#. Create or update a ``pyproject.toml`` project configuration file.
#. Remove a possibly existing ``.coveragerc`` and ``bootstrap.py``. (Coverage
is now configured in ``tox.ini`` for packages which are no buildout
recipes.)
4. Run the tests via: ``tox``. The ``tox`` script may be either on the current
#. Run the tests via: ``tox``. The ``tox`` script may be either on the current
``$PATH`` or in the ``bin`` subfolder of the current working directory.
5. Create a branch and a pull request. (Prevent an automatic commit of all
#. Create a branch and a pull request. (Prevent an automatic commit of all
changes with the command line switch ``--no-commit``, or an automatic push
to GitHub using the command line switch ``--no-push``.)

After running the script you should manually do the following steps:

1. Check for changes in the updated repository and for the need of a change log
#. Check for changes in the updated repository and for the need of a change log
entry over there.
2. Make sure the package is activated on https://coveralls.io by trying to add
#. Make sure the package is activated on https://coveralls.io by trying to add
the repository name and making it active.
3. Check in possible changes in the zopefoundation/meta repository.
#. Check in possible changes in the zopefoundation/meta repository.


CLI arguments
Expand Down Expand Up @@ -693,12 +694,12 @@ See ``--help`` for details.

The script does the following steps:

1. It does the following steps for each line in the given ``packages.txt``
#. It does the following steps for each line in the given ``packages.txt``
which does not start with ``#``.
2. Check if there is a repository in ``<path-to-clones>`` with the name of the
#. Check if there is a repository in ``<path-to-clones>`` with the name of the
repository. If it does not exist: clone it. If it exists: clean the clone
from changes, switch to ``master`` branch and pull from origin.
3. Call the given script with the package name and arguments for the script.
#. Call the given script with the package name and arguments for the script.

.. caution::

Expand Down
35 changes: 35 additions & 0 deletions config/config-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,39 @@ def manifest_in(self):
manifest_additional_rules=manifest_additional_rules,
with_docs=self.with_docs)

def pyproject_toml(self):
"""Modify pyproject.toml with meta options."""
pyproject_toml_path = self.path / 'pyproject.toml'
if pyproject_toml_path.exists():
with open(pyproject_toml_path, 'rb') as fp:
pyproject_data = tomlkit.load(fp)
pyproject_toml = collections.defaultdict(dict, **pyproject_data)
else:
pyproject_toml = collections.defaultdict(dict)

buildsystem_cfg = pyproject_toml['build-system']

# Insert sane default for build-system:requires
requires = buildsystem_cfg.get('requires', [])
setuptools_requirement = [
x for x in requires if x.startswith('setuptools')]
for setuptools_req in setuptools_requirement:
requires.remove(setuptools_req)
requires.append(f'setuptools{SETUPTOOLS_VERSION_SPEC}')
buildsystem_cfg['requires'] = sorted(requires)

# Insert sane default for build-system:build-backend
build_backend = buildsystem_cfg.get('build-backend', '')
if not build_backend:
buildsystem_cfg['build-backend'] = 'setuptools.build_meta'

# Remove empty sections before writing to disk
pyproject_toml = {k: v for k, v in pyproject_toml.items() if v}
with open(pyproject_toml_path, 'w') as fp:
fp.write(META_HINT.format(config_type=self.config_type))
fp.write('\n')
tomlkit.dump(pyproject_toml, fp, sort_keys=True)

def copy_with_meta(
self, template_name, destination, config_type,
meta_hint=META_HINT, **kw):
Expand Down Expand Up @@ -580,6 +613,7 @@ def configure(self):
if self.with_docs:
self.readthedocs()

self.pyproject_toml()
self.setup_cfg()
self.gitignore()
self.pre_commit_config_yaml()
Expand All @@ -595,6 +629,7 @@ def configure(self):
early_add = [
'.pre-commit-config.yaml',
'CONTRIBUTING.md',
'pyproject.toml',
]
if self.args.commit:
call('git', 'add', *early_add)
Expand Down

0 comments on commit 4f2eaaf

Please sign in to comment.