From: Daniele Varrazzo Date: Sun, 22 Dec 2024 01:37:44 +0000 (+0100) Subject: chore: adapt development tools to toml files X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=c058c520c2c28015d18be6385155558c1dc86b69;p=thirdparty%2Fpsycopg.git chore: adapt development tools to toml files --- diff --git a/README.rst b/README.rst index 68b445859..b29e83952 100644 --- a/README.rst +++ b/README.rst @@ -43,8 +43,7 @@ You can then clone this repository to develop Psycopg:: cd psycopg Please note that the repository contains the source code of several Python -packages: that's why you don't see a ``setup.py`` here. The packages may have -different requirements: +packages, which may have different requirements: - The ``psycopg`` directory contains the pure python implementation of ``psycopg``. The package has only a runtime dependency on the ``libpq``, the diff --git a/docs/release.rst b/docs/release.rst index 14176756b..d6a44f7ff 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -104,7 +104,8 @@ When a new Python major version is released versions. - Add the ``Programming Language :: Python :: 3.`` classifier to - ``psycopg/setup.cfg``, ``psycopg_c/setup.cfg`` and ``psycopg_pool/setup.cfg``. + ``psycopg/pyproject.toml``, ``psycopg_c/pyproject.toml``, and + ``psycopg_pool/pyproject.toml``. - Update the list of versions in ``tools/build/build_macos_arm64.sh`` to include the new version. Look for both the ``python_versions`` variable and the diff --git a/psycopg_c/MANIFEST.in b/psycopg_c/MANIFEST.in index 117298e0d..e9404c7d7 100644 --- a/psycopg_c/MANIFEST.in +++ b/psycopg_c/MANIFEST.in @@ -1,3 +1,3 @@ # Include the build backend in the distributed files. -# It doesn't seem it can be specified in setup.cfg +# It doesn't seem it can be specified in pyproject.toml include build_backend/*.py diff --git a/tools/build/copy_to_binary.py b/tools/build/copy_to_binary.py index 4834d6b80..154d4a37b 100755 --- a/tools/build/copy_to_binary.py +++ b/tools/build/copy_to_binary.py @@ -29,7 +29,8 @@ def sed_i(pattern: str, repl: str, filename: str | Path) -> None: shutil.copytree(pdir / "psycopg_c", target) shutil.move(str(target / "psycopg_c"), str(target / "psycopg_binary")) shutil.move(str(target / "README-binary.rst"), str(target / "README.rst")) -sed_i("psycopg-c", "psycopg-binary", target / "setup.cfg") +sed_i("psycopg-c", "psycopg-binary", target / "pyproject.toml") +sed_i(r'"psycopg_c([\./][^"]+)?"', r'"psycopg_binary\1"', target / "pyproject.toml") sed_i(r"__impl__\s*=.*", '__impl__ = "binary"', target / "psycopg_binary/pq.pyx") for dirpath, dirnames, filenames in os.walk(target): for filename in filenames: diff --git a/tools/bump_version.py b/tools/bump_version.py index 3e14b8d7d..37dae36d3 100755 --- a/tools/bump_version.py +++ b/tools/bump_version.py @@ -25,7 +25,7 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(mess @dataclass class Package: name: str - ini_files: list[Path] + toml_files: list[Path] history_file: Path tag_format: str extras: list[str] @@ -38,9 +38,9 @@ packages: dict[str, Package] = {} Package( name="psycopg", - ini_files=[ - PROJECT_DIR / "psycopg/setup.cfg", - PROJECT_DIR / "psycopg_c/setup.cfg", + toml_files=[ + PROJECT_DIR / "psycopg/pyproject.toml", + PROJECT_DIR / "psycopg_c/pyproject.toml", ], history_file=PROJECT_DIR / "docs/news.rst", tag_format="{version}", @@ -49,7 +49,7 @@ Package( Package( name="psycopg_pool", - ini_files=[PROJECT_DIR / "psycopg_pool/setup.cfg"], + toml_files=[PROJECT_DIR / "psycopg_pool/pyproject.toml"], history_file=PROJECT_DIR / "docs/news_pool.rst", tag_format="pool-{version}", extras=[], @@ -64,16 +64,16 @@ class Bumper: self._ini_regex = re.compile( r"""(?ix) ^ - (?P
 version \s* = \s*)
-            (?P [^\s]+)
-            (?P \s*)
+            (?P
 version \s* = \s* ")
+            (?P [^\s"]+)
+            (?P " \s*)
             \s* $
             """
         )
         self._extra_regex = re.compile(
             r"""(?ix)
             ^
-            (?P
 \s* )
+            (?P
 \s* ")
             (?P [^\s]+)
             (?P \s* == \s*)
             (?P [^\s]+)
@@ -84,11 +84,11 @@ class Bumper:
 
     @cached_property
     def current_version(self) -> Version:
-        versions = {self._parse_version_from_file(f) for f in self.package.ini_files}
+        versions = {self._parse_version_from_file(f) for f in self.package.toml_files}
         if len(versions) > 1:
             raise ValueError(
                 f"inconsistent versions ({', '.join(map(str, sorted(versions)))})"
-                f" in {self.package.ini_files}"
+                f" in {self.package.toml_files}"
             )
 
         return versions.pop()
@@ -134,7 +134,7 @@ class Bumper:
         return Version(".".join(sparts))
 
     def update_files(self) -> None:
-        for f in self.package.ini_files:
+        for f in self.package.toml_files:
             self._update_version_in_file(f, self.want_version)
 
         if self.bump_level != BumpLevel.DEV:
@@ -145,7 +145,7 @@ class Bumper:
         msg = f"""\
 chore: bump {self.package.name} package version to {self.want_version}
 """
-        files = self.package.ini_files + [self.package.history_file]
+        files = self.package.toml_files + [self.package.history_file]
         cmdline = ["git", "commit", "-m", msg] + list(map(str, files))
         sp.check_call(cmdline)