Mercurial > hgrepos > Python > apps > py-cutils
changeset 409:8809d79777c3 build-2.7 tip
MERGE: IGNORE: with current trunk
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 17 Feb 2026 17:18:10 +0100 |
| parents | d3429477cd55 (diff) 3e28e5aacb8a (current diff) |
| children | |
| files | pyproject.toml |
| diffstat | 4 files changed, 97 insertions(+), 127 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Tue Feb 17 17:16:27 2026 +0100 +++ b/Makefile Tue Feb 17 17:18:10 2026 +0100 @@ -17,13 +17,13 @@ hg kwarchive __arch build: - python -m build - # NOTE: Postprocessing is now done by the intree build backend - # in intree-build-helper/cutils_build.py. + python setup.py sdist bdist_wheel + python _postprocess-sdist.py + gzip --best dist/*tar distclean: clean # package build information - rm -rf dist/ *.egg-info + rm -rf build/ dist/ *.egg-info # Full clean build for sdist, wheel and docs dist: distclean build
--- a/_postprocess-sdist.py Tue Feb 17 17:16:27 2026 +0100 +++ b/_postprocess-sdist.py Tue Feb 17 17:18:10 2026 +0100 @@ -1,90 +1,77 @@ # -*- coding: utf-8 -*- # :- -# SPDX-FileCopyrightText: © 2025-2026 Franz Glasner +# SPDX-FileCopyrightText: © 2025 Franz Glasner # SPDX-License-Identifier: BSD-3-Clause # :- -"""Postprocress a .tar.gz-sdist to include tests/data with symlinks as symlinks. +"""Postprocress a .tar-sdist to include tests/data with symlinks as symlinks. Produce an sdist with all the data in :file:`tests/data/`:: rm -rf dist py_cutils.egg-info - python -m build + python setup.py sdist python _postprocess-sdist.py + gzip dist/*.tar """ from __future__ import print_function, absolute_import try: - import tomllib + from configparser import ConfigParser except ImportError: - import tomli as tomllib + from ConfigParser import SafeConfigParser as ConfigParser import importlib +import io import os -import io import tarfile -import gzip def main(): - with open("pyproject.toml", "rb") as cfgfile: - cfg = tomllib.load(cfgfile) - project_name = cfg["project"]["name"] - normalized_project_name = project_name.replace("-", "_") - project_version = cfg["project"].get("version") - if project_version is None: - assert "version" in cfg["project"]["dynamic"] - project_version = cfg["tool"]["setuptools"]["dynamic"]["version"] - if "attr" in project_version: - vermodname, dummy, vermodattr = (project_version["attr"] - .strip() - .rpartition('.')) - assert dummy is not None and vermodattr is not None - vermod = importlib.import_module(vermodname) - project_version = getattr(vermod, vermodattr) + with io.open("setup.cfg", "rt", encoding="utf-8") as cfgfile: + cp = ConfigParser() + if hasattr(cp, "read_file"): + cp.read_file(cfgfile, "setup.cfg") else: - assert False - # - # PEP 625 requires that sdists are of the form - # <normalized_project_name>-<project_version>.tar.gz + cp.readfp(cfgfile, "setup.cfg") + project_name = cp.get("metadata", "name") + project_version = cp.get("metadata", "version") + if project_version.startswith("attr:"): + vermodname, dummy, vermodattr = (project_version[5:] + .strip() + .rpartition('.')) + assert dummy is not None and vermodattr is not None + vermod = importlib.import_module(vermodname) + project_version = getattr(vermod, vermodattr) + elif project_version.startswith("file:"): + assert False # - archive_name = "{}-{}.tar.gz".format( - normalized_project_name, project_version) - uncompressed_archive_name = "{}-{}.tar".format( - normalized_project_name, project_version) + # Compressed tar files cannot be modified by Python: make sure the + # originally generated archive is uncompressed. + # + assert cp.get("sdist", "formats") == "tar" + + archive_name = "{}-{}.tar".format(project_name, project_version) archive_path = "dist/" + archive_name - uncompressed_archive_path = "dist/" + uncompressed_archive_name assert os.path.isfile(archive_path) - assert not os.path.isfile(uncompressed_archive_path) # the directory within the archive - archive_path_prefix = "{}-{}".format( - normalized_project_name, project_version) + archive_path_prefix = "{}-{}".format(project_name, project_version) - egg_directory = "{}.egg-info".format(normalized_project_name) + egg_directory = "{}.egg-info".format(project_name.replace("-", "_")) assert os.path.isdir(egg_directory) sources_txt_path = "{}/SOURCES.txt".format(egg_directory) sources_txt_arcname = "{}/{}/SOURCES.txt".format( archive_path_prefix, egg_directory) - # Uncompress - with gzip.GzipFile(filename=archive_path, mode="rb") as ca: - with open(uncompressed_archive_path, "wb") as uca: - while True: - data = ca.read(64*1024) - if not data: - break - uca.write(data) - - with tarfile.TarFile(uncompressed_archive_path, "r") as tf: + with tarfile.TarFile(archive_path, "r") as tf: sf = tf.extractfile(sources_txt_arcname) try: sources_txt = sf.read() finally: sf.close() - with tarfile.TarFile(uncompressed_archive_path, "a") as tf: + with tarfile.TarFile(archive_path, "a") as tf: arcname = "{}/tests/data".format(archive_path_prefix) try: info = tf.getmember(arcname) @@ -126,18 +113,6 @@ # tf.addfile(sources_info, sf) - # Compress - with open(uncompressed_archive_path, "rb") as uca: - with open(archive_path, "wb") as ca: - with gzip.GzipFile(filename=uncompressed_archive_name, - fileobj=ca, - mode="wb") as gzfile: - while True: - data = uca.read(64*1024) - if not data: - break - gzfile.write(data) - def b(buf, encoding="ascii"): if isinstance(buf, bytes):
--- a/pyproject.toml Tue Feb 17 17:16:27 2026 +0100 +++ b/pyproject.toml Tue Feb 17 17:18:10 2026 +0100 @@ -1,66 +1,4 @@ -# Pure-Python-Build +# Pure-Python-Build for Python2.7 and older Python3 versions [build-system] -requires = ["setuptools>=77.0"] -# This is a intree wrapper for setuptools.build_meta -build-backend = "cutils_build" -backend-path = ["intree-build-helper"] - -[project] -name = "py-cutils" -description = "Pure Python implementation of some coreutils with some extensions" -# -# NOTE: This is the *distribution* license (e.g. includes vendored stuff). -# There is no such thing here as a "project" license. -# -license = "BSD-3-Clause AND MIT" -license-files = [ - "LICENSES/BSD-3-Clause.txt", - "LICENSES/MIT.txt" -] -authors = [ - {name = "Franz Glasner", email = "fzglas.hg@dom66.de"}, -] -classifiers = [ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: End Users/Desktop", - "Intended Audience :: System Administrators", - "Operating System :: OS Independent", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Topic :: System", - "Topic :: Utilities" -] -requires-python = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*" -dynamic = ["version", "readme"] - -[project.urls] -homepage = "https://hg2.dom66.de/hgrepos/Python/apps/py-cutils" -download = "https://pypi2.dom66.de/simple/py-cutils/" -source = "https://hg2.dom66.de/hgrepos/Python/apps/py-cutils" - -[project.scripts] -py-dos2unix = "cutils.dos2unix:main" -py-genpwd = "cutils.genpwd:main" -py-shasum = "cutils.shasum:main" -py-treesum = "cutils.treesum:main" - -[tool.setuptools] -include-package-data = false -platforms = ["any"] -zip-safe = true -packages = [ - "cutils", - "cutils.util", - "cutils.crcmod", - "cutils.crcmod.python2", - "cutils.crcmod.python3" -] - -[tool.setuptools.dynamic] -version = {attr = "cutils.__version__"} -readme = {file = ["README.txt"], content-type = "text/x-rst"} - -[tool.setuptools.package-data] -"cutils.crcmod" = ["REUSE.toml"] +requires = ["setuptools>=43.0", "wheel>=0.33"] +build-backend = "setuptools.build_meta"
--- a/setup.cfg Tue Feb 17 17:16:27 2026 +0100 +++ b/setup.cfg Tue Feb 17 17:18:10 2026 +0100 @@ -1,3 +1,5 @@ +# Build configuration for Python2.7 and older Python3 versions + [egg_info] tag_build = tag_date = 0 @@ -6,6 +8,61 @@ [bdist_wheel] universal = 1 +[sdist] +formats = tar + +[metadata] +name = py-cutils +version = attr: cutils.__version__ +description = Pure Python implementation of some coreutils with some extensions +author = Franz Glasner +author_email = fzglas.hg@dom66.de +license = BSD 3-Clause "New" or "Revised" License +url = https://pypi.dom66.de/simple/py-cutils/ +download_url = https://pypi.dom66.de/simple/py-cutils/ +license_files = + LICENSES/BSD-3-Clause.txt + LICENSES/MIT.txt +long_description = file: README.txt +long_description_content_type = text/x-rst +platforms = any +classifiers = + Development Status :: 5 - Production/Stable + Environment :: Console + Intended Audience :: Developers + Intended Audience :: End Users/Desktop + Intended Audience :: System Administrators + License :: OSI Approved :: BSD License + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Programming Language :: Python :: 2.7 + Programming Language :: Python :: 3 + Topic :: System + Topic :: Utilities + +[options] +include_package_data = False +zip_safe = True +python_requires = >=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.* +packages = + cutils + cutils.util + cutils.crcmod + cutils.crcmod.python2 + cutils.crcmod.python3 + +[options.package_data] +cutils.crcmod = + REUSE.toml + +[options.entry_points] +console_scripts = + py-dos2unix = cutils.dos2unix:main + py-genpwd = cutils.genpwd:main + py-shasum = cutils.shasum:main + py-treesum = cutils.treesum:main + + [flake8] exclude = # Ignore the vendored crcmod2/crcmod sub-package
