Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-hatchling for 
openSUSE:Factory checked in at 2023-05-10 16:17:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-hatchling (Old)
 and      /work/SRC/openSUSE:Factory/.python-hatchling.new.1533 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-hatchling"

Wed May 10 16:17:16 2023 rev:16 rq:1085808 version:1.15.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-hatchling/python-hatchling.changes        
2023-05-03 12:56:17.491484979 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-hatchling.new.1533/python-hatchling.changes  
    2023-05-10 16:17:19.574549419 +0200
@@ -1,0 +2,6 @@
+Tue May  9 19:19:08 UTC 2023 - Benoît Monin <benoit.mo...@gmx.fr>
+
+- update to version 1.15.0:
+  * Add app build target
+
+-------------------------------------------------------------------

Old:
----
  hatchling-1.14.1.tar.gz

New:
----
  hatchling-1.15.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-hatchling.spec ++++++
--- /var/tmp/diff_new_pack.6zPftw/_old  2023-05-10 16:17:20.046552211 +0200
+++ /var/tmp/diff_new_pack.6zPftw/_new  2023-05-10 16:17:20.050552234 +0200
@@ -18,7 +18,7 @@
 
 %{?sle15_python_module_pythons}
 Name:           python-hatchling
-Version:        1.14.1
+Version:        1.15.0
 Release:        0
 Summary:        Build backend used by Hatch
 License:        MIT

++++++ hatchling-1.14.1.tar.gz -> hatchling-1.15.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hatchling-1.14.1/PKG-INFO 
new/hatchling-1.15.0/PKG-INFO
--- old/hatchling-1.14.1/PKG-INFO       2020-02-02 01:00:00.000000000 +0100
+++ new/hatchling-1.15.0/PKG-INFO       2020-02-02 01:00:00.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: hatchling
-Version: 1.14.1
+Version: 1.15.0
 Summary: Modern, extensible Python build backend
 Project-URL: Homepage, https://hatch.pypa.io/latest/
 Project-URL: Sponsor, https://github.com/sponsors/ofek
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hatchling-1.14.1/src/hatchling/__about__.py 
new/hatchling-1.15.0/src/hatchling/__about__.py
--- old/hatchling-1.14.1/src/hatchling/__about__.py     2020-02-02 
01:00:00.000000000 +0100
+++ new/hatchling-1.15.0/src/hatchling/__about__.py     2020-02-02 
01:00:00.000000000 +0100
@@ -1 +1 @@
-__version__ = '1.14.1'
+__version__ = '1.15.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hatchling-1.14.1/src/hatchling/bridge/app.py 
new/hatchling-1.15.0/src/hatchling/bridge/app.py
--- old/hatchling-1.14.1/src/hatchling/bridge/app.py    2020-02-02 
01:00:00.000000000 +0100
+++ new/hatchling-1.15.0/src/hatchling/bridge/app.py    2020-02-02 
01:00:00.000000000 +0100
@@ -7,6 +7,13 @@
 
 
 class InvokedApplication:
+    def __init__(self) -> None:
+        self.__verbosity = int(os.environ.get('HATCH_VERBOSE', '0')) - 
int(os.environ.get('HATCH_QUIET', '0'))
+
+    @property
+    def verbosity(self) -> int:
+        return self.__verbosity
+
     def display(self, *args: Any, **kwargs: Any) -> None:
         send_app_command('display', *args, **kwargs)
 
@@ -51,6 +58,13 @@
     def __init__(self) -> None:
         self.__verbosity = int(os.environ.get('HATCH_VERBOSE', '0')) - 
int(os.environ.get('HATCH_QUIET', '0'))
 
+    @property
+    def verbosity(self) -> int:
+        """
+        The verbosity level of the application, with 0 as the default.
+        """
+        return self.__verbosity
+
     def display(self, message: str = '', **kwargs: Any) -> None:
         # Do not document
         print(message)
@@ -121,6 +135,7 @@
 class SafeApplication:
     def __init__(self, app: InvokedApplication | Application) -> None:
         self.abort = app.abort
+        self.verbosity = app.verbosity
         self.display = app.display
         self.display_info = app.display_info
         self.display_error = app.display_error
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/hatchling-1.14.1/src/hatchling/builders/app.py 
new/hatchling-1.15.0/src/hatchling/builders/app.py
--- old/hatchling-1.14.1/src/hatchling/builders/app.py  1970-01-01 
01:00:00.000000000 +0100
+++ new/hatchling-1.15.0/src/hatchling/builders/app.py  2020-02-02 
01:00:00.000000000 +0100
@@ -0,0 +1,171 @@
+from __future__ import annotations
+
+import os
+import sys
+from typing import Any, Callable
+
+from hatchling.builders.config import BuilderConfig
+from hatchling.builders.plugin.interface import BuilderInterface
+
+
+class AppBuilderConfig(BuilderConfig):
+    SUPPORTED_VERSIONS = ('3.11', '3.10', '3.9', '3.8', '3.7')
+
+    def __init__(self, *args: Any, **kwargs: Any) -> None:
+        super().__init__(*args, **kwargs)
+
+        self.__scripts: list[str] | None = None
+        self.__python_version: str | None = None
+        self.__pyapp_version: str | None = None
+
+    @property
+    def scripts(self) -> list[str]:
+        if self.__scripts is None:
+            known_scripts = self.builder.metadata.core.scripts
+            scripts = self.target_config.get('scripts', [])
+
+            if not isinstance(scripts, list):
+                message = f'Field 
`tool.hatch.build.targets.{self.plugin_name}.scripts` must be an array'
+                raise TypeError(message)
+
+            for i, script in enumerate(scripts, 1):
+                if not isinstance(script, str):
+                    message = (
+                        f'Script #{i} of field 
`tool.hatch.build.targets.{self.plugin_name}.scripts` must be a string'
+                    )
+                    raise TypeError(message)
+                elif script not in known_scripts:
+                    message = f'Unknown script in field 
`tool.hatch.build.targets.{self.plugin_name}.scripts`: {script}'
+                    raise ValueError(message)
+
+            self.__scripts = sorted(set(scripts)) if scripts else 
list(known_scripts)
+
+        return self.__scripts
+
+    @property
+    def python_version(self) -> str:
+        if self.__python_version is None:
+            python_version = self.target_config.get('python-version', '')
+
+            if not isinstance(python_version, str):
+                message = f'Field 
`tool.hatch.build.targets.{self.plugin_name}.python-version` must be a string'
+                raise TypeError(message)
+
+            if not python_version and 'PYAPP_DISTRIBUTION_SOURCE' not in 
os.environ:
+                for supported_version in self.SUPPORTED_VERSIONS:
+                    if 
self.builder.metadata.core.python_constraint.contains(supported_version):
+                        python_version = supported_version
+                        break
+                else:
+                    message = 'Field `project.requires-python` is incompatible 
with the known distributions'
+                    raise ValueError(message)
+
+            self.__python_version = python_version
+
+        return self.__python_version
+
+    @property
+    def pyapp_version(self) -> str:
+        if self.__pyapp_version is None:
+            pyapp_version = self.target_config.get('pyapp-version', '')
+
+            if not isinstance(pyapp_version, str):
+                message = f'Field 
`tool.hatch.build.targets.{self.plugin_name}.pyapp-version` must be a string'
+                raise TypeError(message)
+
+            self.__pyapp_version = pyapp_version
+
+        return self.__pyapp_version
+
+
+class AppBuilder(BuilderInterface):
+    """
+    Build applications
+    """
+
+    PLUGIN_NAME = 'app'
+
+    def get_version_api(self) -> dict[str, Callable]:
+        return {'bootstrap': self.build_bootstrap}
+
+    def get_default_versions(self) -> list[str]:
+        return ['bootstrap']
+
+    def clean(self, directory: str, versions: list[str]) -> None:
+        import shutil
+
+        app_dir = os.path.join(directory, 'app')
+        if os.path.isdir(app_dir):
+            shutil.rmtree(app_dir)
+
+    def build_bootstrap(self, directory: str, **build_data: Any) -> str:
+        import shutil
+        import tempfile
+
+        cargo_path = os.environ.get('CARGO', '')
+        if not cargo_path:
+            if not shutil.which('cargo'):
+                message = 'Executable `cargo` could not be found on PATH'
+                raise OSError(message)
+
+            cargo_path = 'cargo'
+
+        app_dir = os.path.join(directory, 'app')
+        if not os.path.isdir(app_dir):
+            os.makedirs(app_dir)
+
+        on_windows = sys.platform == 'win32'
+        base_env = dict(os.environ)
+        base_env['PYAPP_PROJECT_NAME'] = self.metadata.name
+        base_env['PYAPP_PROJECT_VERSION'] = self.metadata.version
+
+        if self.config.python_version:
+            base_env['PYAPP_PYTHON_VERSION'] = self.config.python_version
+
+        # https://doc.rust-lang.org/cargo/reference/config.html#buildtarget
+        build_target = os.environ.get('CARGO_BUILD_TARGET', '')
+
+        with tempfile.TemporaryDirectory() as temp_dir:
+            temp_exe_path = os.path.join(temp_dir, 'bin', 'pyapp.exe' if 
on_windows else 'pyapp')
+
+            install_command = [cargo_path, 'install', 'pyapp', '--force', 
'--root', temp_dir]
+            if self.config.pyapp_version:
+                install_command.extend(['--version', 
self.config.pyapp_version])
+
+            if self.config.scripts:
+                for script in self.config.scripts:
+                    env = dict(base_env)
+                    env['PYAPP_EXEC_SPEC'] = self.metadata.core.scripts[script]
+
+                    self.cargo_build(install_command, cwd=temp_dir, env=env)
+
+                    exe_stem = f'{script}-{build_target}' if build_target else 
script
+                    exe_path = os.path.join(app_dir, f'{exe_stem}.exe' if 
on_windows else exe_stem)
+                    shutil.move(temp_exe_path, exe_path)
+            else:
+                self.cargo_build(install_command, cwd=temp_dir, env=base_env)
+
+                exe_stem = f'{self.metadata.name}-{build_target}' if 
build_target else self.metadata.name
+                exe_path = os.path.join(app_dir, f'{exe_stem}.exe' if 
on_windows else exe_stem)
+                shutil.move(temp_exe_path, exe_path)
+
+        return app_dir
+
+    def cargo_build(self, *args: Any, **kwargs: Any) -> None:
+        import subprocess
+
+        if not self.app.verbosity:
+            kwargs['stdout'] = subprocess.PIPE
+            kwargs['stderr'] = subprocess.STDOUT
+
+        process = subprocess.run(*args, **kwargs)
+        if process.returncode:
+            message = f'Compilation of failed (code {process.returncode})'
+            if not self.app.verbosity:
+                message = f'{process.stdout.decode("utf-8")}\n{message}'
+
+            raise OSError(message)
+
+    @classmethod
+    def get_config_class(cls) -> type[AppBuilderConfig]:
+        return AppBuilderConfig
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/hatchling-1.14.1/src/hatchling/builders/plugin/hooks.py 
new/hatchling-1.15.0/src/hatchling/builders/plugin/hooks.py
--- old/hatchling-1.14.1/src/hatchling/builders/plugin/hooks.py 2020-02-02 
01:00:00.000000000 +0100
+++ new/hatchling-1.15.0/src/hatchling/builders/plugin/hooks.py 2020-02-02 
01:00:00.000000000 +0100
@@ -2,6 +2,7 @@
 
 import typing
 
+from hatchling.builders.app import AppBuilder
 from hatchling.builders.custom import CustomBuilder
 from hatchling.builders.sdist import SdistBuilder
 from hatchling.builders.wheel import WheelBuilder
@@ -13,4 +14,4 @@
 
 @hookimpl
 def hatch_register_builder() -> list[type[BuilderInterface]]:
-    return [CustomBuilder, SdistBuilder, WheelBuilder]  # type: ignore
+    return [AppBuilder, CustomBuilder, SdistBuilder, WheelBuilder]  # type: 
ignore

Reply via email to