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 2022-08-04 13:23:22 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-hatchling (Old) and /work/SRC/openSUSE:Factory/.python-hatchling.new.1521 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-hatchling" Thu Aug 4 13:23:22 2022 rev:4 rq:991960 version:1.6.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-hatchling/python-hatchling.changes 2022-07-09 16:58:55.532426015 +0200 +++ /work/SRC/openSUSE:Factory/.python-hatchling.new.1521/python-hatchling.changes 2022-08-04 13:23:35.728521131 +0200 @@ -1,0 +2,35 @@ +Sat Jul 30 20:38:56 UTC 2022 - Beno??t Monin <benoit.mo...@gmx.fr> + +- update to version 1.6.0: + * Changed: + + When no build targets are specified on the command line, now + default to sdist and wheel targets rather than what happens + to be defined in config + + The code version source now only supports files with known + extensions + + Global build hooks now run before target-specific build hooks + to better match expected behavior + * Added: + + The code version source now supports loading extension + modules + + Add search-paths option for the code version source + * Fixed: + + Fix removing sources using an empty string value in the + mapping + + The strict-naming option now also applies to the metadata + directory of wheel targets + +------------------------------------------------------------------- +Fri Jul 15 12:19:55 UTC 2022 - Beno??t Monin <benoit.mo...@gmx.fr> + +- update to version 1.5.0: + * Added: + + Support the final draft of PEP 639 + + Add strict-naming option for sdist and wheel targets + * Fixed: Project names are now stored in sdist and wheel target + core metadata exactly as defined in pyproject.toml without + normalization to allow control of how PyPI displays them +- require python 3.7 as minimum version to match upstream + requirement + +------------------------------------------------------------------- Old: ---- hatchling-1.4.1.tar.gz New: ---- hatchling-1.6.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-hatchling.spec ++++++ --- /var/tmp/diff_new_pack.50OD4y/_old 2022-08-04 13:23:36.200522471 +0200 +++ /var/tmp/diff_new_pack.50OD4y/_new 2022-08-04 13:23:36.204522481 +0200 @@ -19,12 +19,13 @@ %define skip_python2 1 %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-hatchling -Version: 1.4.1 +Version: 1.6.0 Release: 0 Summary: Build backend used by Hatch License: MIT URL: https://hatch.pypa.io/latest/ Source0: https://files.pythonhosted.org/packages/source/h/hatchling/hatchling-%{version}.tar.gz +BuildRequires: %{python_module devel >= 3.7} BuildRequires: %{python_module editables >= 0.3} BuildRequires: %{python_module importlib-metadata if %python-base < 3.8} BuildRequires: %{python_module packaging >= 21.3} ++++++ hatchling-1.4.1.tar.gz -> hatchling-1.6.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/PKG-INFO new/hatchling-1.6.0/PKG-INFO --- old/hatchling-1.4.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,9 +1,9 @@ Metadata-Version: 2.1 Name: hatchling -Version: 1.4.1 +Version: 1.6.0 Summary: Modern, extensible Python build backend Project-URL: Homepage, https://hatch.pypa.io/latest/ -Project-URL: Funding, https://github.com/sponsors/ofek +Project-URL: Sponsor, https://github.com/sponsors/ofek Project-URL: History, https://hatch.pypa.io/dev/history/ Project-URL: Tracker, https://github.com/pypa/hatch/issues Project-URL: Source, https://github.com/pypa/hatch/tree/master/backend diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/__about__.py new/hatchling-1.6.0/src/hatchling/__about__.py --- old/hatchling-1.4.1/src/hatchling/__about__.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/__about__.py 2020-02-02 01:00:00.000000000 +0100 @@ -1 +1 @@ -__version__ = '1.4.1' +__version__ = '1.6.0' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/builders/config.py new/hatchling-1.6.0/src/hatchling/builders/config.py --- old/hatchling-1.4.1/src/hatchling/builders/config.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/builders/config.py 2020-02-02 01:00:00.000000000 +0100 @@ -231,6 +231,16 @@ if self.__hook_config is None: hook_config = {} + global_hook_config = self.build_config.get('hooks', {}) + if not isinstance(global_hook_config, dict): + raise TypeError('Field `tool.hatch.build.hooks` must be a table') + + for hook_name, config in global_hook_config.items(): + if not isinstance(config, dict): + raise TypeError(f'Field `tool.hatch.build.hooks.{hook_name}` must be a table') + + hook_config.setdefault(hook_name, config) + target_hook_config = self.target_config.get('hooks', {}) if not isinstance(target_hook_config, dict): raise TypeError(f'Field `tool.hatch.build.targets.{self.plugin_name}.hooks` must be a table') @@ -243,16 +253,6 @@ hook_config[hook_name] = config - global_hook_config = self.build_config.get('hooks', {}) - if not isinstance(global_hook_config, dict): - raise TypeError('Field `tool.hatch.build.hooks` must be a table') - - for hook_name, config in global_hook_config.items(): - if not isinstance(config, dict): - raise TypeError(f'Field `tool.hatch.build.hooks.{hook_name}` must be a table') - - hook_config.setdefault(hook_name, config) - final_hook_config = {} if not env_var_enabled(BuildEnvVars.NO_HOOKS): all_hooks_enabled = env_var_enabled(BuildEnvVars.HOOKS_ENABLE) @@ -558,7 +558,9 @@ raise TypeError(f'Path for source `{source}` in field `{sources_location}` must be a string') normalized_path = normalize_relative_path(path) - if normalized_path: + if normalized_path == '.': + normalized_path = '' + else: normalized_path += os.sep sources[normalize_relative_directory(source)] = normalized_path @@ -688,12 +690,12 @@ # https://git-scm.com/docs/gitignore#_pattern_format for exclusion_file in self.vcs_exclusion_files['git']: - with open(exclusion_file, 'r', encoding='utf-8') as f: + with open(exclusion_file, encoding='utf-8') as f: patterns.extend(f.readlines()) # https://linux.die.net/man/5/hgignore for exclusion_file in self.vcs_exclusion_files['hg']: - with open(exclusion_file, 'r', encoding='utf-8') as f: + with open(exclusion_file, encoding='utf-8') as f: glob_mode = False for line in f: exact_line = line.strip() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/builders/hooks/version.py new/hatchling-1.6.0/src/hatchling/builders/hooks/version.py --- old/hatchling-1.4.1/src/hatchling/builders/hooks/version.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/builders/hooks/version.py 2020-02-02 01:00:00.000000000 +0100 @@ -17,9 +17,9 @@ if self.__config_path is None: path = self.config.get('path', '') if not isinstance(path, str): - raise TypeError('Option `path` for build hook `{}` must be a string'.format(self.PLUGIN_NAME)) + raise TypeError(f'Option `path` for build hook `{self.PLUGIN_NAME}` must be a string') elif not path: - raise ValueError('Option `path` for build hook `{}` is required'.format(self.PLUGIN_NAME)) + raise ValueError(f'Option `path` for build hook `{self.PLUGIN_NAME}` is required') self.__config_path = path @@ -30,7 +30,7 @@ if self.__config_template is None: template = self.config.get('template', '') if not isinstance(template, str): - raise TypeError('Option `template` for build hook `{}` must be a string'.format(self.PLUGIN_NAME)) + raise TypeError(f'Option `template` for build hook `{self.PLUGIN_NAME}` must be a string') self.__config_template = template @@ -41,9 +41,7 @@ if self.__config_pattern is None: pattern = self.config.get('pattern', '') if not isinstance(pattern, (str, bool)): - raise TypeError( - 'Option `pattern` for build hook `{}` must be a string or boolean'.format(self.PLUGIN_NAME) - ) + raise TypeError(f'Option `pattern` for build hook `{self.PLUGIN_NAME}` must be a string or boolean') self.__config_pattern = pattern @@ -57,4 +55,4 @@ else: version_file.write(self.metadata.version, self.config_template) - build_data['artifacts'].append('/{}'.format(self.config_path)) + build_data['artifacts'].append(f'/{self.config_path}') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/builders/plugin/interface.py new/hatchling-1.6.0/src/hatchling/builders/plugin/interface.py --- old/hatchling-1.4.1/src/hatchling/builders/plugin/interface.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/builders/plugin/interface.py 2020-02-02 01:00:00.000000000 +0100 @@ -163,14 +163,11 @@ - `distribution_path` - the path to be distributed as """ if self.config.only_include: - for explicit_file in self.recurse_explicit_files(self.config.only_include): - yield explicit_file + yield from self.recurse_explicit_files(self.config.only_include) else: - for project_file in self.recurse_project_files(): - yield project_file + yield from self.recurse_project_files() - for explicit_file in self.recurse_forced_files(self.config.get_force_include()): - yield explicit_file + yield from self.recurse_forced_files(self.config.get_force_include()) def recurse_project_files(self) -> Generator[IncludedFile, None, None]: for root, dirs, files in safe_walk(self.root): @@ -357,7 +354,6 @@ @property def project_id(self): if self.__project_id is None: - # https://discuss.python.org/t/clarify-naming-of-dist-info-directories/5565 self.__project_id = f'{self.normalize_file_name_component(self.metadata.core.name)}-{self.metadata.version}' return self.__project_id diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/builders/sdist.py new/hatchling-1.6.0/src/hatchling/builders/sdist.py --- old/hatchling-1.4.1/src/hatchling/builders/sdist.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/builders/sdist.py 2020-02-02 01:00:00.000000000 +0100 @@ -78,9 +78,10 @@ class SdistBuilderConfig(BuilderConfig): def __init__(self, *args, **kwargs): - super(SdistBuilderConfig, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.__core_metadata_constructor = None + self.__strict_naming = None self.__support_legacy = None @property @@ -105,6 +106,24 @@ return self.__core_metadata_constructor @property + def strict_naming(self): + if self.__strict_naming is None: + if 'strict-naming' in self.target_config: + strict_naming = self.target_config['strict-naming'] + if not isinstance(strict_naming, bool): + raise TypeError( + f'Field `tool.hatch.build.targets.{self.plugin_name}.strict-naming` must be a boolean' + ) + else: + strict_naming = self.build_config.get('strict-naming', True) + if not isinstance(strict_naming, bool): + raise TypeError('Field `tool.hatch.build.strict-naming` must be a boolean') + + self.__strict_naming = strict_naming + + return self.__strict_naming + + @property def support_legacy(self): if self.__support_legacy is None: self.__support_legacy = bool(self.target_config.get('support-legacy', False)) @@ -163,11 +182,19 @@ 'setup.py', ) - target = os.path.join(directory, f'{self.project_id}.tar.gz') + target = os.path.join(directory, f'{self.artifact_project_id}.tar.gz') replace_file(archive.path, target) return target + @property + def artifact_project_id(self): + return ( + self.project_id + if self.config.strict_naming + else f'{self.normalize_file_name_component(self.metadata.core.raw_name)}-{self.metadata.version}' + ) + def construct_setup_py_file(self, packages, extra_dependencies=()): contents = '# -*- coding: utf-8 -*-\nfrom setuptools import setup\n\n' @@ -273,17 +300,17 @@ return contents def get_default_build_data(self): - force_include = {} + force_include = { + os.path.join(self.root, 'pyproject.toml'): 'pyproject.toml', + os.path.join(self.root, DEFAULT_CONFIG_FILE): DEFAULT_CONFIG_FILE, + os.path.join(self.root, DEFAULT_BUILD_SCRIPT): DEFAULT_BUILD_SCRIPT, + } build_data = {'force_include': force_include, 'dependencies': []} for exclusion_files in self.config.vcs_exclusion_files.values(): for exclusion_file in exclusion_files: force_include[exclusion_file] = os.path.basename(exclusion_file) - force_include[os.path.join(self.root, 'pyproject.toml')] = 'pyproject.toml' - force_include[os.path.join(self.root, DEFAULT_BUILD_SCRIPT)] = DEFAULT_BUILD_SCRIPT - force_include[os.path.join(self.root, DEFAULT_CONFIG_FILE)] = DEFAULT_CONFIG_FILE - readme_path = self.metadata.core.readme_path if readme_path: readme_path = normalize_relative_path(readme_path) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/builders/wheel.py new/hatchling-1.6.0/src/hatchling/builders/wheel.py --- old/hatchling-1.4.1/src/hatchling/builders/wheel.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/builders/wheel.py 2020-02-02 01:00:00.000000000 +0100 @@ -122,7 +122,7 @@ class WheelBuilderConfig(BuilderConfig): def __init__(self, *args, **kwargs): - super(WheelBuilderConfig, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.__include_defined = bool( self.target_config.get('include', self.build_config.get('include')) @@ -136,6 +136,7 @@ self.__core_metadata_constructor = None self.__shared_data = None self.__extra_metadata = None + self.__strict_naming = None def set_default_file_selection(self): if self.__include or self.__exclude or self.__packages: @@ -255,6 +256,24 @@ return self.__extra_metadata + @property + def strict_naming(self): + if self.__strict_naming is None: + if 'strict-naming' in self.target_config: + strict_naming = self.target_config['strict-naming'] + if not isinstance(strict_naming, bool): + raise TypeError( + f'Field `tool.hatch.build.targets.{self.plugin_name}.strict-naming` must be a boolean' + ) + else: + strict_naming = self.build_config.get('strict-naming', True) + if not isinstance(strict_naming, bool): + raise TypeError('Field `tool.hatch.build.strict-naming` must be a boolean') + + self.__strict_naming = strict_naming + + return self.__strict_naming + class WheelBuilder(BuilderInterface): """ @@ -285,7 +304,9 @@ else: build_data['tag'] = self.get_default_tag() - with WheelArchive(self.project_id, self.config.reproducible) as archive, closing(StringIO()) as records: + with WheelArchive(self.artifact_project_id, self.config.reproducible) as archive, closing( + StringIO() + ) as records: for included_file in self.recurse_included_files(): record = archive.add_file(included_file) records.write(self.format_record(record)) @@ -295,7 +316,7 @@ records.write(f'{archive.metadata_directory}/RECORD,,\n') archive.write_metadata('RECORD', records.getvalue()) - target = os.path.join(directory, f"{self.project_id}-{build_data['tag']}.whl") + target = os.path.join(directory, f"{self.artifact_project_id}-{build_data['tag']}.whl") replace_file(archive.path, target) return target @@ -309,7 +330,9 @@ def build_editable_detection(self, directory, **build_data): build_data['tag'] = self.get_default_tag() - with WheelArchive(self.project_id, self.config.reproducible) as archive, closing(StringIO()) as records: + with WheelArchive(self.artifact_project_id, self.config.reproducible) as archive, closing( + StringIO() + ) as records: exposed_packages = {} for included_file in self.recurse_project_files(): if not included_file.path.endswith('.py'): @@ -366,7 +389,7 @@ records.write(f'{archive.metadata_directory}/RECORD,,\n') archive.write_metadata('RECORD', records.getvalue()) - target = os.path.join(directory, f"{self.project_id}-{build_data['tag']}.whl") + target = os.path.join(directory, f"{self.artifact_project_id}-{build_data['tag']}.whl") replace_file(archive.path, target) return target @@ -374,7 +397,9 @@ def build_editable_explicit(self, directory, **build_data): build_data['tag'] = self.get_default_tag() - with WheelArchive(self.project_id, self.config.reproducible) as archive, closing(StringIO()) as records: + with WheelArchive(self.artifact_project_id, self.config.reproducible) as archive, closing( + StringIO() + ) as records: directories = sorted( os.path.normpath(os.path.join(self.root, relative_directory)) for relative_directory in self.config.dev_mode_dirs @@ -392,7 +417,7 @@ records.write(f'{archive.metadata_directory}/RECORD,,\n') archive.write_metadata('RECORD', records.getvalue()) - target = os.path.join(directory, f"{self.project_id}-{build_data['tag']}.whl") + target = os.path.join(directory, f"{self.artifact_project_id}-{build_data['tag']}.whl") replace_file(archive.path, target) return target @@ -421,7 +446,7 @@ # entry_points.txt self.write_entry_points_file(archive, records) - # license_files/ + # licenses/ self.add_licenses(archive, records) # extra_metadata/ - write last @@ -458,7 +483,7 @@ for relative_path in self.metadata.core.license_files: license_file = os.path.normpath(os.path.join(self.root, relative_path)) with open(license_file, 'rb') as f: - record = archive.write_metadata(f'license_files/{relative_path}', f.read()) + record = archive.write_metadata(f'licenses/{relative_path}', f.read()) records.write(self.format_record(record)) def add_extra_metadata(self, archive, records): @@ -507,6 +532,14 @@ return normalize_inclusion_map(build_data['force_include_editable'], self.root) + @property + def artifact_project_id(self): + return ( + self.project_id + if self.config.strict_naming + else f'{self.normalize_file_name_component(self.metadata.core.raw_name)}-{self.metadata.version}' + ) + @classmethod def get_config_class(cls): return WheelBuilderConfig diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/cli/build/__init__.py new/hatchling-1.6.0/src/hatchling/cli/build/__init__.py --- old/hatchling-1.4.1/src/hatchling/cli/build/__init__.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/cli/build/__init__.py 2020-02-02 01:00:00.000000000 +0100 @@ -25,9 +25,8 @@ versions = version_data.split(',') if version_data else [] target_data.setdefault(target_name, []).extend(versions) else: # no cov - targets = metadata.hatch.build_targets or ['sdist', 'wheel'] - for target_name in targets: - target_data[target_name] = [] + target_data['sdist'] = [] + target_data['wheel'] = [] builders = {} unknown_targets = [] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/metadata/core.py new/hatchling-1.6.0/src/hatchling/metadata/core.py --- old/hatchling-1.4.1/src/hatchling/metadata/core.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/metadata/core.py 2020-02-02 01:00:00.000000000 +0100 @@ -12,7 +12,7 @@ def load_toml(path): - with open(path, 'r', encoding='utf-8') as f: + with open(path, encoding='utf-8') as f: return tomllib.loads(f.read()) @@ -251,6 +251,7 @@ self.hatch_metadata = hatch_metadata self.context = context + self._raw_name = None self._name = None self._version = None self._description = None @@ -279,30 +280,40 @@ self._dynamic = None @property - def name(self): + def raw_name(self): """ https://peps.python.org/pep-0621/#name """ - if self._name is None: + if self._raw_name is None: if 'name' in self.dynamic: raise ValueError('Static metadata field `name` cannot be present in field `project.dynamic`') elif 'name' in self.config: - name = self.config['name'] + raw_name = self.config['name'] else: - name = '' + raw_name = '' - if not name: + if not raw_name: raise ValueError('Missing required field `project.name`') - elif not isinstance(name, str): + elif not isinstance(raw_name, str): raise TypeError('Field `project.name` must be a string') - if not is_valid_project_name(name): + if not is_valid_project_name(raw_name): raise ValueError( 'Required field `project.name` must only contain ASCII letters/digits, underscores, ' 'hyphens, and periods, and must begin and end with ASCII letters/digits.' ) - self._name = normalize_project_name(name) + self._raw_name = raw_name + + return self._raw_name + + @property + def name(self): + """ + https://peps.python.org/pep-0621/#name + """ + if self._name is None: + self._name = normalize_project_name(self.raw_name) return self._name @@ -393,7 +404,7 @@ if not os.path.isfile(readme_path): raise OSError(f'Readme file does not exist: {readme}') - with open(readme_path, 'r', encoding='utf-8') as f: + with open(readme_path, encoding='utf-8') as f: self._readme = f.read() self._readme_content_type = content_type @@ -422,7 +433,7 @@ if not os.path.isfile(path): raise OSError(f'Readme file does not exist: {relative_path}') - with open(path, 'r', encoding=readme.get('charset', 'utf-8')) as f: + with open(path, encoding=readme.get('charset', 'utf-8')) as f: contents = f.read() readme_path = relative_path @@ -539,7 +550,7 @@ if not os.path.isfile(path): raise OSError(f'License file does not exist: {relative_path}') - with open(path, 'r', encoding='utf-8') as f: + with open(path, encoding='utf-8') as f: contents = f.read() elif 'text' in data: contents = data['text'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/metadata/spec.py new/hatchling-1.6.0/src/hatchling/metadata/spec.py --- old/hatchling-1.4.1/src/hatchling/metadata/spec.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/metadata/spec.py 2020-02-02 01:00:00.000000000 +0100 @@ -18,7 +18,7 @@ https://peps.python.org/pep-0345/ """ metadata_file = 'Metadata-Version: 1.2\n' - metadata_file += f'Name: {metadata.core.name}\n' + metadata_file += f'Name: {metadata.core.raw_name}\n' metadata_file += f'Version: {metadata.version}\n' if metadata.core.description: @@ -77,7 +77,7 @@ https://peps.python.org/pep-0566/ """ metadata_file = 'Metadata-Version: 2.1\n' - metadata_file += f'Name: {metadata.core.name}\n' + metadata_file += f'Name: {metadata.core.raw_name}\n' metadata_file += f'Version: {metadata.version}\n' if metadata.core.description: @@ -149,7 +149,7 @@ https://peps.python.org/pep-0643/ """ metadata_file = 'Metadata-Version: 2.2\n' - metadata_file += f'Name: {metadata.core.name}\n' + metadata_file += f'Name: {metadata.core.raw_name}\n' metadata_file += f'Version: {metadata.version}\n' if metadata.core.description: @@ -221,7 +221,7 @@ https://peps.python.org/pep-0639/ """ metadata_file = 'Metadata-Version: 2.3\n' - metadata_file += f'Name: {metadata.core.name}\n' + metadata_file += f'Name: {metadata.core.raw_name}\n' metadata_file += f'Version: {metadata.version}\n' if metadata.core.description: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/ouroboros.py new/hatchling-1.6.0/src/hatchling/ouroboros.py --- old/hatchling-1.4.1/src/hatchling/ouroboros.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/ouroboros.py 2020-02-02 01:00:00.000000000 +0100 @@ -10,7 +10,7 @@ 'authors': [{'name': 'Ofek Lev', 'email': 'o...@ofek.dev'}], 'urls': { 'Homepage': 'https://hatch.pypa.io/latest/', - 'Funding': 'https://github.com/sponsors/ofek', + 'Sponsor': 'https://github.com/sponsors/ofek', 'History': 'https://hatch.pypa.io/dev/history/', 'Tracker': 'https://github.com/pypa/hatch/issues', 'Source': 'https://github.com/pypa/hatch/tree/master/backend', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/version/core.py new/hatchling-1.6.0/src/hatchling/version/core.py --- old/hatchling-1.4.1/src/hatchling/version/core.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/version/core.py 2020-02-02 01:00:00.000000000 +0100 @@ -23,7 +23,7 @@ if not os.path.isfile(self.__path): raise OSError(f'file does not exist: {self.__relative_path}') - with open(self.__path, 'r', encoding='utf-8') as f: + with open(self.__path, encoding='utf-8') as f: contents = f.read() if not pattern or pattern is True: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/src/hatchling/version/source/code.py new/hatchling-1.6.0/src/hatchling/version/source/code.py --- old/hatchling-1.4.1/src/hatchling/version/source/code.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/src/hatchling/version/source/code.py 2020-02-02 01:00:00.000000000 +0100 @@ -7,6 +7,9 @@ PLUGIN_NAME = 'code' def get_version_data(self): + import importlib + import sys + relative_path = self.config.get('path') if not relative_path: raise ValueError('option `path` must be specified') @@ -21,18 +24,29 @@ if not isinstance(expression, str): raise TypeError('option `expression` must be a string') - with open(path, 'r', encoding='utf-8') as f: - contents = f.read() - - # Ensure predefined module attributes are available. - # https://docs.python.org/3/reference/datamodel.html#the-standard-type-hierarchy. - global_variables = {'__file__': path, '__annotations__': dict()} - - # Load the file - exec(contents, global_variables) + search_paths = self.config.get('search-paths', []) + if not isinstance(search_paths, list): + raise TypeError('option `search-paths` must be an array') + + absolute_search_paths = [] + for i, search_path in enumerate(search_paths, 1): + if not isinstance(search_path, str): + raise TypeError(f'entry #{i} of option `search-paths` must be a string') + + absolute_search_paths.append(os.path.normpath(os.path.join(self.root, search_path))) + + spec = importlib.util.spec_from_file_location(os.path.splitext(path)[0], path) + module = importlib.util.module_from_spec(spec) + + old_search_paths = list(sys.path) + try: + sys.path[:] = [*absolute_search_paths, *old_search_paths] + spec.loader.exec_module(module) + finally: + sys.path[:] = old_search_paths # Execute the expression to determine the version - version = eval(expression, global_variables) + version = eval(expression, vars(module)) return {'version': version} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hatchling-1.4.1/tests/downstream/integrate.py new/hatchling-1.6.0/tests/downstream/integrate.py --- old/hatchling-1.4.1/tests/downstream/integrate.py 2020-02-02 01:00:00.000000000 +0100 +++ new/hatchling-1.6.0/tests/downstream/integrate.py 2020-02-02 01:00:00.000000000 +0100 @@ -31,7 +31,7 @@ class EnvVars(dict): def __init__(self, env_vars=None, ignore=None): - super(EnvVars, self).__init__(os.environ) + super().__init__(os.environ) self.old_env = dict(self) if env_vars is not None: @@ -87,7 +87,7 @@ # Increment the minor version version_file = os.path.join(backend_path, 'src', 'hatchling', '__about__.py') - with open(version_file, 'r') as f: + with open(version_file) as f: lines = f.readlines() for i, line in enumerate(lines): @@ -136,14 +136,14 @@ # Not yet ported if os.path.isfile(potential_project_file): - with open(potential_project_file, 'r') as f: + with open(potential_project_file) as f: project_config.update(tomli.loads(f.read())) if not python_version_supported(project_config): print('--> Unsupported version of Python, skipping') continue - with open(os.path.join(project_dir, 'data.json'), 'r') as f: + with open(os.path.join(project_dir, 'data.json')) as f: test_data = json.loads(f.read()) with temp_dir() as d: @@ -171,7 +171,7 @@ if not os.path.isfile(project_file): sys.exit('--> Missing file: pyproject.toml') - with open(project_file, 'r') as f: + with open(project_file) as f: project_config.update(tomli.loads(f.read())) for requirement in project_config.get('build-system', {}).get('requires', []):