]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
chore: adapt development tools to toml files
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 22 Dec 2024 01:37:44 +0000 (02:37 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 23 Dec 2024 12:44:13 +0000 (13:44 +0100)
README.rst
docs/release.rst
psycopg_c/MANIFEST.in
tools/build/copy_to_binary.py
tools/bump_version.py

index 68b4458595cfdd01bd266409002fb83ddb54e281..b29e83952e2938311f600d7e1f128b2188d066bb 100644 (file)
@@ -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
index 14176756be80b893cf72cb8fba2fca47e018658b..d6a44f7fffb7b49206cdc437ff51041e3389e301 100644 (file)
@@ -104,7 +104,8 @@ When a new Python major version is released
   versions.
 
 - Add the ``Programming Language :: Python :: 3.<X>`` 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
index 117298e0d19d972c8e51def68ce7502c8059e6c8..e9404c7d7f42d4644d2db4045a4ba82c684c8412 100644 (file)
@@ -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
index 4834d6b8045721ab868c6892513856bf25eb6b0f..154d4a37b1d431ec1d4df62fe8f74521b451ef2b 100755 (executable)
@@ -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:
index 3e14b8d7d267ff231099281e273d079b6c482b3c..37dae36d31811c047f79b056c8aecb733c91f6ca 100755 (executable)
@@ -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<pre> version \s* = \s*)
-            (?P<ver> [^\s]+)
-            (?P<post> \s*)
+            (?P<pre> version \s* = \s* ")
+            (?P<ver> [^\s"]+)
+            (?P<post> \s*)
             \s* $
             """
         )
         self._extra_regex = re.compile(
             r"""(?ix)
             ^
-            (?P<pre> \s* )
+            (?P<pre> \s* ")
             (?P<package> [^\s]+)
             (?P<op> \s* == \s*)
             (?P<ver> [^\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)