Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-flit-core for 
openSUSE:Factory checked in at 2022-03-28 17:00:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flit-core (Old)
 and      /work/SRC/openSUSE:Factory/.python-flit-core.new.1900 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-flit-core"

Mon Mar 28 17:00:11 2022 rev:9 rq:964842 version:3.7.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-flit-core/python-flit-core.changes        
2022-01-09 22:49:55.635270832 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-flit-core.new.1900/python-flit-core.changes  
    2022-03-28 17:00:55.668999259 +0200
@@ -1,0 +2,20 @@
+Fri Mar 25 12:10:11 UTC 2022 - Ben Greiner <[email protected]>
+
+- Update to version 3.7.1
+  * Support for external data files such as man pages or Jupyter
+    extension support files (PR #510).
+  * Project names are now lowercase in wheel filenames and
+    .dist-info folder names, in line with the specifications (PR
+    #498).
+  * Improved support for bootstrapping a Python environment, e.g.
+    for downstream packagers (PR #511). flit_core.wheel is usable
+    with python -m to create wheels before the build tool is
+    available, and flit_core sdists also include a script to
+    install itself from a wheel before installer is available.
+  * Use newer importlib APIs, fixing some deprecation warnings (PR
+    #499).
+  * Fix building packages which need execution to get the version
+    number, and have a relative import in __init__.py (PR #531).
+- Update bootstrapping process
+
+-------------------------------------------------------------------

Old:
----
  build_dists.py
  flit_core-3.6.0.tar.gz

New:
----
  flit_core-3.7.1.tar.gz

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

Other differences:
------------------
++++++ python-flit-core.spec ++++++
--- /var/tmp/diff_new_pack.B6LWS4/_old  2022-03-28 17:00:56.241000036 +0200
+++ /var/tmp/diff_new_pack.B6LWS4/_new  2022-03-28 17:00:56.245000042 +0200
@@ -27,13 +27,12 @@
 %{?!python_module:%define python_module() python3-%{**}}
 %define skip_python2 1
 Name:           python-flit-core%{psuffix}
-Version:        3.6.0
+Version:        3.7.1
 Release:        0
 Summary:        Distribution-building parts of Flit
 License:        BSD-3-Clause
 URL:            https://github.com/pypa/flit
 Source0:        
https://files.pythonhosted.org/packages/source/f/flit-core/flit_core-%{version}.tar.gz
-Source1:        
https://github.com/pypa/flit/raw/%{version}/flit_core/build_dists.py
 BuildRequires:  %{python_module base >= 3.6}
 %if %{with test}
 BuildRequires:  %{python_module flit-core = %{version}}
@@ -52,22 +51,21 @@
 
 %prep
 %setup -q -n flit_core-%{version}
-cp %{SOURCE1} .
 
 %build
 # https://flit.readthedocs.io/en/latest/bootstrap.html
-python3 build_dists.py
+python3 -m flit_core.wheel
 
 %if !%{with test}
 %install
-%{python_expand # do manually what pip would do
+%{python_expand #
 mkdir -p %{buildroot}%{$python_sitelib}
-unzip dist/flit_core-%{version}-py3-none-any.whl -d 
%{buildroot}%{$python_sitelib}
-rm -r  %{buildroot}%{$python_sitelib}/flit_core/tests
-}
-%{python_expand # debundle after the bootstrap. See vendor/README
+$python bootstrap_install.py dist/flit_core-%{version}-py3-none-any.whl -i 
%{buildroot}%{$python_sitelib}
+# debundle after the bootstrap. See vendor/README
 sed -i 's/from .vendor import tomli/import tomli/'  
%{buildroot}%{$python_sitelib}/flit_core/config.py
 rm -r %{buildroot}%{$python_sitelib}/flit_core/vendor
+# Don't package the tests
+rm -r  %{buildroot}%{$python_sitelib}/flit_core/tests
 }
 %{?python_compileall}
 %python_expand %fdupes %{buildroot}%{$python_sitelib}

++++++ flit_core-3.6.0.tar.gz -> flit_core-3.7.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/PKG-INFO new/flit_core-3.7.1/PKG-INFO
--- old/flit_core-3.6.0/PKG-INFO        1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/PKG-INFO        1970-01-01 01:00:00.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: flit_core
-Version: 3.6.0
+Version: 3.7.1
 Summary: Distribution-building parts of Flit. See flit package for more 
information
 Author-email: Thomas Kluyver & contributors <[email protected]>
 Requires-Python: >=3.6
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/README.rst 
new/flit_core-3.7.1/README.rst
--- old/flit_core-3.6.0/README.rst      1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/README.rst      2021-11-14 15:34:30.346272500 +0100
@@ -0,0 +1,6 @@
+flit_core
+---------
+
+This provides a PEP 517 build backend for packages using Flit.
+The only public interface is the API specified by PEP 517, at 
``flit_core.buildapi``.
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/bootstrap_install.py 
new/flit_core-3.7.1/bootstrap_install.py
--- old/flit_core-3.6.0/bootstrap_install.py    1970-01-01 01:00:00.000000000 
+0100
+++ new/flit_core-3.7.1/bootstrap_install.py    2022-02-21 20:04:37.818999300 
+0100
@@ -0,0 +1,48 @@
+"""Install flit_core without using any other tools.
+
+Normally, you would install flit_core with pip like any other Python package.
+This script is meant to help with 'bootstrapping' other packaging
+systems, where you may need flit_core to build other packaging tools.
+
+Use 'python -m flit_core.wheel' to make a wheel, then:
+
+    python bootstrap_install.py flit_core-3.6.0-py3-none-any.whl
+
+To install for something other than the Python running the script, pass a
+site-packages or equivalent directory with the --installdir option.
+"""
+import argparse
+import sys
+import sysconfig
+from pathlib import Path
+from zipfile import ZipFile
+
+def extract_wheel(whl_path, dest):
+    print("Installing to", dest)
+    with ZipFile(whl_path) as zf:
+        zf.extractall(dest)
+
+if __name__ == "__main__":
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        'wheel',
+        type=Path,
+        help=f'flit_core wheel to install (.whl file)',
+    )
+    purelib = Path(sysconfig.get_path('purelib')).resolve()
+    parser.add_argument(
+        '--installdir',
+        '-i',
+        type=Path,
+        default=purelib,
+        help=f'installdir directory (defaults to {purelib})',
+    )
+
+    args = parser.parse_args()
+
+    if not args.wheel.name.startswith('flit_core-'):
+        sys.exit("Use this script only for flit_core wheels")
+    if not args.installdir.is_dir():
+        sys.exit(f"{args.installdir} is not a directory")
+
+    extract_wheel(args.wheel, args.installdir)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/build_dists.py 
new/flit_core-3.7.1/build_dists.py
--- old/flit_core-3.6.0/build_dists.py  1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/build_dists.py  2022-01-15 14:08:55.114355800 +0100
@@ -0,0 +1,17 @@
+"""Build flit_core to upload to PyPI.
+
+Normally, this should only be used by me when making a release.
+"""
+import os
+
+from flit_core import buildapi
+
+os.chdir(os.path.dirname(os.path.abspath(__file__)))
+
+print("Building sdist")
+sdist_fname = buildapi.build_sdist('dist/')
+print(os.path.join('dist', sdist_fname))
+
+print("\nBuilding wheel")
+whl_fname = buildapi.build_wheel('dist/')
+print(os.path.join('dist', whl_fname))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/__init__.py 
new/flit_core-3.7.1/flit_core/__init__.py
--- old/flit_core-3.6.0/flit_core/__init__.py   2021-12-27 14:38:33.710516700 
+0100
+++ new/flit_core-3.7.1/flit_core/__init__.py   2022-02-23 12:35:47.109032400 
+0100
@@ -4,4 +4,4 @@
 All the convenient development features live in the main 'flit' package.
 """
 
-__version__ = '3.6.0'
+__version__ = '3.7.1'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/common.py 
new/flit_core-3.7.1/flit_core/common.py
--- old/flit_core-3.6.0/flit_core/common.py     2021-11-23 12:08:18.530732200 
+0100
+++ new/flit_core-3.7.1/flit_core/common.py     2022-02-23 12:35:15.232898500 
+0100
@@ -3,6 +3,7 @@
 import hashlib
 import logging
 import os
+import sys
 
 from pathlib import Path
 import re
@@ -163,10 +164,21 @@
     _import_i += 1
 
     log.debug("Loading module %s", target.file)
-    from importlib.machinery import SourceFileLoader
-    sl = SourceFileLoader('flit_core.dummy.import%d' % _import_i, 
str(target.file))
+    from importlib.util import spec_from_file_location, module_from_spec
+    mod_name = 'flit_core.dummy.import%d' % _import_i
+    spec = spec_from_file_location(mod_name, target.file)
     with _module_load_ctx():
-        m = sl.load_module()
+        m = module_from_spec(spec)
+        # Add the module to sys.modules to allow relative imports to work.
+        # importlib has more code around this to handle the case where two
+        # threads are trying to load the same module at the same time, but Flit
+        # should always be running a single thread, so we won't duplicate that.
+        sys.modules[mod_name] = m
+        try:
+            spec.loader.exec_module(m)
+        finally:
+            sys.modules.pop(mod_name, None)
+
     docstring = m.__dict__.get('__doc__', None)
     version = m.__dict__.get('__version__', None)
     return docstring, version
@@ -407,7 +419,7 @@
 
     See 
https://packaging.python.org/specifications/binary-distribution-format/#escaping-and-unicode
     """
-    normalized_name = re.sub(r'[-_.]+', '_', name, flags=re.UNICODE)
+    normalized_name = re.sub(r'[-_.]+', '_', name, flags=re.UNICODE).lower()
     assert check_version(version) == version
     assert '-' not in version, 'Normalized versions can???t have dashes'
     return '{}-{}'.format(normalized_name, version)
@@ -416,3 +428,20 @@
 def dist_info_name(distribution, version):
     """Get the correct name of the .dist-info folder"""
     return normalize_dist_name(distribution, version) + '.dist-info'
+
+
+def walk_data_dir(data_directory):
+    """Iterate over the files in the given data directory.
+
+    Yields paths prefixed with data_directory - caller may want to make them
+    relative to that. Excludes any __pycache__ subdirectories.
+    """
+    if data_directory is None:
+        return
+
+    for dirpath, dirs, files in os.walk(data_directory):
+        for file in sorted(files):
+            full_path = os.path.join(dirpath, file)
+            yield full_path
+
+        dirs[:] = [d for d in sorted(dirs) if d != '__pycache__']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/config.py 
new/flit_core-3.7.1/flit_core/config.py
--- old/flit_core-3.6.0/flit_core/config.py     2021-12-27 14:04:58.924610600 
+0100
+++ new/flit_core-3.7.1/flit_core/config.py     2022-02-21 19:53:07.976436100 
+0100
@@ -120,7 +120,7 @@
         )
 
     unknown_sections = set(dtool) - {
-        'metadata', 'module', 'scripts', 'entrypoints', 'sdist'
+        'metadata', 'module', 'scripts', 'entrypoints', 'sdist', 
'external-data'
     }
     unknown_sections = [s for s in unknown_sections if not 
s.lower().startswith('x-')]
     if unknown_sections:
@@ -142,6 +142,27 @@
             dtool['sdist'].get('exclude', []), 'exclude'
         )
 
+    data_dir = dtool.get('external-data', {}).get('directory', None)
+    if data_dir is not None:
+        toml_key = "tool.flit.external-data.directory"
+        if not isinstance(data_dir, str):
+            raise ConfigError(f"{toml_key} must be a string")
+
+        normp = osp.normpath(data_dir)
+        if osp.isabs(normp):
+            raise ConfigError(f"{toml_key} cannot be an absolute path")
+        if normp.startswith('..' + os.sep):
+            raise ConfigError(
+                f"{toml_key} cannot point outside the directory containing 
pyproject.toml"
+            )
+        if normp == '.':
+            raise ConfigError(
+                f"{toml_key} cannot refer to the directory containing 
pyproject.toml"
+            )
+        loaded_cfg.data_directory = path.parent / data_dir
+        if not loaded_cfg.data_directory.is_dir():
+            raise ConfigError(f"{toml_key} must refer to a directory")
+
     return loaded_cfg
 
 def flatten_entrypoints(ep):
@@ -207,7 +228,7 @@
             raise ConfigError(
                 '{} pattern {!r} is an absolute path'.format(clude, p)
             )
-        if osp.normpath(p).startswith('..' + os.sep):
+        if normp.startswith('..' + os.sep):
             raise ConfigError(
                 '{} pattern {!r} points out of the directory containing 
pyproject.toml'
                 .format(clude, p)
@@ -227,6 +248,7 @@
         self.sdist_include_patterns = []
         self.sdist_exclude_patterns = []
         self.dynamic_metadata = []
+        self.data_directory = None
 
     def add_scripts(self, scripts_dict):
         if scripts_dict:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/sdist.py 
new/flit_core-3.7.1/flit_core/sdist.py
--- old/flit_core-3.6.0/flit_core/sdist.py      2021-11-22 20:09:49.595885300 
+0100
+++ new/flit_core-3.7.1/flit_core/sdist.py      2022-02-21 19:53:07.977436000 
+0100
@@ -72,13 +72,14 @@
     which is what should normally be published to PyPI.
     """
     def __init__(self, module, metadata, cfgdir, reqs_by_extra, entrypoints,
-                 extra_files, include_patterns=(), exclude_patterns=()):
+                 extra_files, data_directory, include_patterns=(), 
exclude_patterns=()):
         self.module = module
         self.metadata = metadata
         self.cfgdir = cfgdir
         self.reqs_by_extra = reqs_by_extra
         self.entrypoints = entrypoints
         self.extra_files = extra_files
+        self.data_directory = data_directory
         self.includes = FilePatterns(include_patterns, str(cfgdir))
         self.excludes = FilePatterns(exclude_patterns, str(cfgdir))
 
@@ -93,8 +94,8 @@
         extra_files = [ini_path.name] + ini_info.referenced_files
         return cls(
             module, metadata, srcdir, ini_info.reqs_by_extra,
-            ini_info.entrypoints, extra_files, ini_info.sdist_include_patterns,
-            ini_info.sdist_exclude_patterns,
+            ini_info.entrypoints, extra_files, ini_info.data_directory,
+            ini_info.sdist_include_patterns, ini_info.sdist_exclude_patterns,
         )
 
     def prep_entry_points(self):
@@ -115,6 +116,8 @@
         cfgdir_s = str(self.cfgdir)
         return [
             osp.relpath(p, cfgdir_s) for p in self.module.iter_files()
+        ] + [
+            osp.relpath(p, cfgdir_s) for p in 
common.walk_data_dir(self.data_directory)
         ] + self.extra_files
 
     def apply_includes_excludes(self, files):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/imported_version/package1/__init__.py
 
new/flit_core-3.7.1/flit_core/tests/samples/imported_version/package1/__init__.py
--- 
old/flit_core-3.6.0/flit_core/tests/samples/imported_version/package1/__init__.py
   1970-01-01 01:00:00.000000000 +0100
+++ 
new/flit_core-3.7.1/flit_core/tests/samples/imported_version/package1/__init__.py
   2022-02-23 12:35:15.232898500 +0100
@@ -0,0 +1,3 @@
+"""This module has a __version__ that requires a relative import"""
+
+from ._version import __version__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/imported_version/package1/_version.py
 
new/flit_core-3.7.1/flit_core/tests/samples/imported_version/package1/_version.py
--- 
old/flit_core-3.6.0/flit_core/tests/samples/imported_version/package1/_version.py
   1970-01-01 01:00:00.000000000 +0100
+++ 
new/flit_core-3.7.1/flit_core/tests/samples/imported_version/package1/_version.py
   2022-02-23 12:35:15.232898500 +0100
@@ -0,0 +1 @@
+__version__ = '0.5.8'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/imported_version/pyproject.toml 
new/flit_core-3.7.1/flit_core/tests/samples/imported_version/pyproject.toml
--- old/flit_core-3.6.0/flit_core/tests/samples/imported_version/pyproject.toml 
1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/flit_core/tests/samples/imported_version/pyproject.toml 
2022-02-23 12:35:15.233898400 +0100
@@ -0,0 +1,10 @@
+[build-system]
+requires = ["flit_core >=3.2,<4"]
+build-backend = "flit_core.buildapi"
+
+[project]
+name = "package1"
+authors = [
+    {name = "Sir R??bin", email = "[email protected]"}
+]
+dynamic = ["version", "description"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/LICENSE 
new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/LICENSE
--- old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/LICENSE   
1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/LICENSE   
2022-02-21 19:53:07.977436000 +0100
@@ -0,0 +1 @@
+This file should be added to wheels
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/README.rst 
new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/README.rst
--- old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/README.rst        
1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/README.rst        
2022-02-21 19:53:07.978436000 +0100
@@ -0,0 +1 @@
+This contains a n??n-ascii character
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/data/share/man/man1/foo.1
 
new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/data/share/man/man1/foo.1
--- 
old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/data/share/man/man1/foo.1
 1970-01-01 01:00:00.000000000 +0100
+++ 
new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/data/share/man/man1/foo.1
 2022-02-21 19:53:07.978436000 +0100
@@ -0,0 +1 @@
+Example data file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/module1.py 
new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/module1.py
--- old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/module1.py        
1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/module1.py        
2022-02-21 19:53:07.978436000 +0100
@@ -0,0 +1,3 @@
+"""Example module"""
+
+__version__ = '0.1'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/pyproject.toml 
new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/pyproject.toml
--- old/flit_core-3.6.0/flit_core/tests/samples/with_data_dir/pyproject.toml    
1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/flit_core/tests/samples/with_data_dir/pyproject.toml    
2022-02-21 19:53:07.978436000 +0100
@@ -0,0 +1,26 @@
+[build-system]
+requires = ["flit_core >=3.2,<4"]
+build-backend = "flit_core.buildapi"
+
+[project]
+name = "module1"
+authors = [
+    {name = "Sir R??bin", email = "[email protected]"}
+]
+readme = "README.rst"
+license = {file = "LICENSE"}
+requires-python = ">=3.7"
+dependencies = [
+    "requests >= 2.18",
+    "docutils",
+]
+dynamic = [
+    "version",
+    "description",
+]
+
+[project.scripts]
+foo = "module1:main"
+
+[tool.flit.external-data]
+directory = "data"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/tests/test_common.py 
new/flit_core-3.7.1/flit_core/tests/test_common.py
--- old/flit_core-3.6.0/flit_core/tests/test_common.py  2021-11-18 
23:10:43.577393000 +0100
+++ new/flit_core-3.7.1/flit_core/tests/test_common.py  2022-02-23 
12:35:15.233898400 +0100
@@ -75,6 +75,11 @@
                                 'version': '1.2.3'}
                          )
 
+        info = get_info_from_module(Module('package1', samples_dir / 
'imported_version'))
+        self.assertEqual(info, {'summary': 'This module has a __version__ that 
requires a relative import',
+                                'version': '0.5.8'}
+                         )
+
         with self.assertRaises(InvalidVersion):
             get_info_from_module(Module('invalid_version1', samples_dir))
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/tests/test_sdist.py 
new/flit_core-3.7.1/flit_core/tests/test_sdist.py
--- old/flit_core-3.6.0/flit_core/tests/test_sdist.py   2021-11-14 
15:34:30.350272400 +0100
+++ new/flit_core-3.7.1/flit_core/tests/test_sdist.py   2022-02-21 
19:53:07.978436000 +0100
@@ -49,3 +49,12 @@
     assert osp.join('doc', 'test.rst') in files
     assert osp.join('doc', 'test.txt') not in files
     assert osp.join('doc', 'subdir', 'test.txt') in files
+
+
+def test_data_dir():
+    builder = sdist.SdistBuilder.from_ini_path(
+        samples_dir / 'with_data_dir' / 'pyproject.toml'
+    )
+    files = builder.apply_includes_excludes(builder.select_files())
+
+    assert osp.join('data', 'share', 'man', 'man1', 'foo.1') in files
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/tests/test_wheel.py 
new/flit_core-3.7.1/flit_core/tests/test_wheel.py
--- old/flit_core-3.6.0/flit_core/tests/test_wheel.py   2021-12-06 
15:34:44.137786100 +0100
+++ new/flit_core-3.7.1/flit_core/tests/test_wheel.py   2022-02-21 
20:04:37.819999200 +0100
@@ -3,7 +3,7 @@
 
 from testpath import assert_isfile
 
-from flit_core.wheel import make_wheel_in
+from flit_core.wheel import make_wheel_in, main
 
 samples_dir = Path(__file__).parent / 'samples'
 
@@ -29,3 +29,19 @@
     # Minimum value for zip timestamps is 1980-1-1
     with ZipFile(info.file, 'r') as zf:
         assert zf.getinfo('module1a.py').date_time == (1980, 1, 1, 0, 0, 0)
+
+
+def test_main(tmp_path):
+    main(['--outdir', str(tmp_path), str(samples_dir / 'pep621')])
+    wheels = list(tmp_path.glob('*.whl'))
+    assert len(wheels) == 1
+    # Minimum value for zip timestamps is 1980-1-1
+    with ZipFile(wheels[0], 'r') as zf:
+        assert 'module1a.py' in zf.namelist()
+
+        
+def test_data_dir(tmp_path):
+    info = make_wheel_in(samples_dir / 'with_data_dir' / 'pyproject.toml', 
tmp_path)
+    assert_isfile(info.file)
+    with ZipFile(info.file, 'r') as zf:
+        assert 'module1-0.1.data/data/share/man/man1/foo.1' in zf.namelist()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/flit_core/wheel.py 
new/flit_core-3.7.1/flit_core/wheel.py
--- old/flit_core-3.6.0/flit_core/wheel.py      2021-11-14 15:34:30.350272400 
+0100
+++ new/flit_core-3.7.1/flit_core/wheel.py      2022-02-21 20:04:37.819999200 
+0100
@@ -1,3 +1,4 @@
+import argparse
 from base64 import urlsafe_b64encode
 import contextlib
 from datetime import datetime
@@ -8,6 +9,7 @@
 import os.path as osp
 import stat
 import tempfile
+from pathlib import Path
 from types import SimpleNamespace
 from typing import Optional
 import zipfile
@@ -57,13 +59,16 @@
 
 
 class WheelBuilder:
-    def __init__(self, directory, module, metadata, entrypoints, target_fp):
+    def __init__(
+            self, directory, module, metadata, entrypoints, target_fp, 
data_directory
+    ):
         """Build a wheel from a module/package
         """
         self.directory = directory
         self.module = module
         self.metadata = metadata
         self.entrypoints = entrypoints
+        self.data_directory = data_directory
 
         self.records = []
         self.source_time_stamp = zip_timestamp_from_env()
@@ -74,14 +79,15 @@
 
     @classmethod
     def from_ini_path(cls, ini_path, target_fp):
-        # Local import so bootstrapping doesn't try to load toml
         from .config import read_flit_config
         directory = ini_path.parent
         ini_info = read_flit_config(ini_path)
         entrypoints = ini_info.entrypoints
         module = common.Module(ini_info.module, directory)
         metadata = common.make_metadata(module, ini_info)
-        return cls(directory, module, metadata, entrypoints, target_fp)
+        return cls(
+            directory, module, metadata, entrypoints, target_fp, 
ini_info.data_directory
+        )
 
     @property
     def dist_info(self):
@@ -160,6 +166,14 @@
         with self._write_to_zip(self.module.name + ".pth") as f:
             f.write(str(self.module.source_dir.resolve()))
 
+    def add_data_directory(self):
+        dir_in_whl = '{}.data/data/'.format(
+            common.normalize_dist_name(self.metadata.name, 
self.metadata.version)
+        )
+        for full_path in common.walk_data_dir(self.data_directory):
+            rel_path = os.path.relpath(full_path, self.data_directory)
+            self._add_file(full_path, dir_in_whl + rel_path)
+
     def write_metadata(self):
         log.info('Writing metadata files')
 
@@ -193,6 +207,7 @@
                 self.add_pth()
             else:
                 self.copy_module()
+            self.add_data_directory()
             self.write_metadata()
             self.write_record()
         finally:
@@ -215,3 +230,30 @@
 
     log.info("Built wheel: %s", wheel_path)
     return SimpleNamespace(builder=wb, file=wheel_path)
+
+
+def main(argv=None):
+    parser = argparse.ArgumentParser()
+    parser.add_argument(
+        'srcdir',
+        type=Path,
+        nargs='?',
+        default=Path.cwd(),
+        help='source directory (defaults to current directory)',
+    )
+
+    parser.add_argument(
+        '--outdir',
+        '-o',
+        help='output directory (defaults to {srcdir}/dist)',
+    )
+    args = parser.parse_args(argv)
+    outdir = args.srcdir / 'dist' if args.outdir is None else Path(args.outdir)
+    print("Building wheel from", args.srcdir)
+    pyproj_toml = args.srcdir / 'pyproject.toml'
+    outdir.mkdir(parents=True, exist_ok=True)
+    info = make_wheel_in(pyproj_toml, outdir)
+    print("Wheel built", outdir / info.file.name)
+
+if __name__ == "__main__":
+    main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/pyproject.toml 
new/flit_core-3.7.1/pyproject.toml
--- old/flit_core-3.6.0/pyproject.toml  2021-12-27 14:04:58.928610600 +0100
+++ new/flit_core-3.7.1/pyproject.toml  2022-02-21 20:04:37.819999200 +0100
@@ -19,3 +19,6 @@
 
 [project.urls]
 Source = "https://github.com/pypa/flit";
+
+[tool.flit.sdist]
+include = ["bootstrap_install.py", "build_dists.py"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/flit_core-3.6.0/update-vendored-tomli.sh 
new/flit_core-3.7.1/update-vendored-tomli.sh
--- old/flit_core-3.6.0/update-vendored-tomli.sh        1970-01-01 
01:00:00.000000000 +0100
+++ new/flit_core-3.7.1/update-vendored-tomli.sh        2022-01-15 
14:08:55.118355800 +0100
@@ -0,0 +1,18 @@
+#!/bin/bash
+# Update the vendored copy of tomli
+set -euo pipefail
+
+version=$1
+echo "Bundling tomli version $version"
+
+rm -rf flit_core/vendor/tomli*
+pip install --target flit_core/vendor/ "tomli==$version"
+
+# Convert absolute imports to relative (from tomli.foo -> from .foo)
+for file in flit_core/vendor/tomli/*.py; do
+  sed -i -E 's/((from|import)[[:space:]]+)tomli\./\1\./' "$file"
+done
+
+# Delete some files that aren't useful in this context.
+# Leave LICENSE & METADATA present.
+rm flit_core/vendor/tomli*.dist-info/{INSTALLER,RECORD,REQUESTED,WHEEL}

Reply via email to