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 2021-10-25 15:17:01
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-flit-core (Old)
and /work/SRC/openSUSE:Factory/.python-flit-core.new.1890 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-flit-core"
Mon Oct 25 15:17:01 2021 rev:7 rq:925548 version:3.4.0
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-flit-core/python-flit-core.changes
2021-04-18 21:44:28.096656680 +0200
+++
/work/SRC/openSUSE:Factory/.python-flit-core.new.1890/python-flit-core.changes
2021-10-25 15:17:33.165680110 +0200
@@ -1,0 +2,43 @@
+Fri Oct 15 19:27:43 UTC 2021 - Ben Greiner <[email protected]>
+
+- Break build cycle by using upstream recommended bootstrap method
+ https://flit.readthedocs.io/en/latest/bootstrap.html
+
+-------------------------------------------------------------------
+Fri Oct 15 17:32:51 UTC 2021 - Ben Greiner <[email protected]>
+
+- Update to Version 3.4
+ * Python 3.6 or above is now required, both for flit and
+ flit_core.
+ * Add a --setup-py option to flit build and flit publish,
+ and a warning when neither this nor --no-setup-py are
+ specified (PR #431). A future version will stop
+ generating setup.py files in sdists by default.
+ * Add support for standardised editable installs - pip
+ install -e - according to PEP 660 (PR #400).
+ * Add a --pypirc option for flit publish to specify an
+ alternative path to a .pypirc config file describing
+ package indexes (PR #434).
+ * Fix installing dependencies specified in a [project]
+ table (PR #433)
+ * Fix building wheels when SOURCE_DATE_EPOCH (see
+ Reproducible builds) is set to a date before 1980 (PR
+ #448).
+ * Switch to using the tomli TOML parser, in common with
+ other packaging projects (PR #438). This supports TOML
+ version 1.0.
+ * Add a document on Bootstrapping (PR #441).
+- Release Version 3.3
+ * PKG-INFO files in sdists are now generated the same way
+ as METADATA in wheels, fixing some issues with sdists
+ (PR #410).
+ * flit publish now sends SHA-256 hashes, fixing uploads
+ to GitLab package repositories (PR #416).
+ * The [project] metadata table from PEP 621 is now fully
+ supported and documented. Projects using this can now
+ specify requires = ["flit_core >=3.2,<4"] in the
+ [build-system] table.
+- Multibuild: break another depcycle with
+ pytest/importlib-metadata/tomli
+
+-------------------------------------------------------------------
Old:
----
flit_core-3.2.0.tar.gz
New:
----
_multibuild
flit_core-3.4.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-flit-core.spec ++++++
--- /var/tmp/diff_new_pack.q1ZjZd/_old 2021-10-25 15:17:33.709680449 +0200
+++ /var/tmp/diff_new_pack.q1ZjZd/_new 2021-10-25 15:17:33.713680453 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package python-flit-core
+# spec file
#
# Copyright (c) 2021 SUSE LLC
#
@@ -16,21 +16,33 @@
#
+%global flavor @BUILD_FLAVOR@%{nil}
+%if "%{flavor}" == "test"
+%define psuffix -test
+%bcond_without test
+%else
+%define psuffix %{nil}
+%bcond_with test
+%endif
+%{?!python_module:%define python_module() python3-%{**}}
%define skip_python2 1
-Name: python-flit-core
-Version: 3.2.0
+Name: python-flit-core%{psuffix}
+Version: 3.4.0
Release: 0
Summary: Distribution-building parts of Flit
License: BSD-3-Clause
URL: https://github.com/takluyver/flit
Source:
https://files.pythonhosted.org/packages/source/f/flit-core/flit_core-%{version}.tar.gz
-BuildRequires: %{python_module pip}
+BuildRequires: %{python_module base >= 3.6}
+%if %{with test}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module testpath}
-BuildRequires: %{python_module toml}
+BuildRequires: %{python_module tomli}
+%endif
BuildRequires: fdupes
BuildRequires: python-rpm-macros
-Requires: python-toml
+BuildRequires: unzip
+Requires: python-tomli
BuildArch: noarch
%python_subpackages
@@ -41,19 +53,29 @@
%setup -q -n flit_core-%{version}
%build
-%pyproject_wheel
+# https://flit.readthedocs.io/en/latest/bootstrap.html
+python3 build_dists.py
+%if !%{with test}
%install
-%pyproject_install
-%{python_expand rm -r %{buildroot}%{$python_sitelib}/flit_core/tests
-%fdupes %{buildroot}%{$python_sitelib}
+%{python_expand # do manually what pip would do
+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_compileall
+%python_expand %fdupes %{buildroot}%{$python_sitelib}
+%endif
+%if %{with test}
%check
%pytest
+%endif
+%if !%{with test}
%files %{python_files}
%{python_sitelib}/flit_core
%{python_sitelib}/flit_core-%{version}*-info
+%endif
%changelog
++++++ _multibuild ++++++
<multibuild>
<package>test</package>
</multibuild>
++++++ flit_core-3.2.0.tar.gz -> flit_core-3.4.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/PKG-INFO new/flit_core-3.4.0/PKG-INFO
--- old/flit_core-3.2.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.4.0/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
@@ -1,7 +1,11 @@
-Metadata-Version: 1.1
+Metadata-Version: 2.1
Name: flit_core
-Version: 3.2.0
+Version: 3.4.0
Summary: Distribution-building parts of Flit. See flit package for more
information
Home-page: https://github.com/takluyver/flit
Author: Thomas Kluyver & contributors
Author-email: [email protected]
+Requires-Python: >=3.6
+Classifier: License :: OSI Approved :: BSD License
+Classifier: Topic :: Software Development :: Libraries :: Python Modules
+Requires-Dist: tomli
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/build_dists.py
new/flit_core-3.4.0/build_dists.py
--- old/flit_core-3.2.0/build_dists.py 1970-01-01 01:00:00.000000000 +0100
+++ new/flit_core-3.4.0/build_dists.py 2021-05-09 17:40:19.105348300 +0200
@@ -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 build_thyself
+
+os.chdir(os.path.dirname(os.path.abspath(__file__)))
+
+print("Building sdist")
+sdist_fname = build_thyself.build_sdist('dist/')
+print(os.path.join('dist', sdist_fname))
+
+print("\nBuilding wheel")
+whl_fname = build_thyself.build_wheel('dist/')
+print(os.path.join('dist', whl_fname))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/__init__.py
new/flit_core-3.4.0/flit_core/__init__.py
--- old/flit_core-3.2.0/flit_core/__init__.py 2021-03-15 23:45:58.347866000
+0100
+++ new/flit_core-3.4.0/flit_core/__init__.py 2021-10-10 11:29:14.143066200
+0200
@@ -4,4 +4,4 @@
All the convenient development features live in the main 'flit' package.
"""
-__version__ = '3.2.0'
+__version__ = '3.4.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/build_thyself.py
new/flit_core-3.4.0/flit_core/build_thyself.py
--- old/flit_core-3.2.0/flit_core/build_thyself.py 2021-01-23
13:24:58.122672800 +0100
+++ new/flit_core-3.4.0/flit_core/build_thyself.py 2021-10-10
11:14:23.714307800 +0200
@@ -25,9 +25,9 @@
'summary': ('Distribution-building parts of Flit. '
'See flit package for more information'),
'requires_dist': [
- 'toml',
+ 'tomli',
],
- 'requires_python': '>=3.4',
+ 'requires_python': '>=3.6',
'classifiers': [
"License :: OSI Approved :: BSD License",
"Topic :: Software Development :: Libraries :: Python Modules",
@@ -88,7 +88,7 @@
sb = SdistBuilder(
module, metadata, cwd, reqs_by_extra, entrypoints={},
- extra_files=['pyproject.toml']
+ extra_files=['pyproject.toml', 'build_dists.py']
)
path = sb.build(Path(sdist_directory))
return path.name
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/buildapi.py
new/flit_core-3.4.0/flit_core/buildapi.py
--- old/flit_core-3.2.0/flit_core/buildapi.py 2021-03-15 23:45:58.348866200
+0100
+++ new/flit_core-3.4.0/flit_core/buildapi.py 2021-10-01 10:16:09.849773200
+0200
@@ -39,6 +39,9 @@
# Requirements to build an sdist are the same as for a wheel
get_requires_for_build_sdist = get_requires_for_build_wheel
+# Requirements to build an editable are the same as for a wheel
+get_requires_for_build_editable = get_requires_for_build_wheel
+
def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None):
"""Creates {metadata_directory}/foo-1.2.dist-info"""
ini_info = read_flit_config(pyproj_toml)
@@ -61,11 +64,19 @@
return osp.basename(dist_info)
+# Metadata for editable are the same as for a wheel
+prepare_metadata_for_build_editable = prepare_metadata_for_build_wheel
+
def build_wheel(wheel_directory, config_settings=None,
metadata_directory=None):
"""Builds a wheel, places it in wheel_directory"""
info = make_wheel_in(pyproj_toml, Path(wheel_directory))
return info.file.name
+def build_editable(wheel_directory, config_settings=None,
metadata_directory=None):
+ """Builds an "editable" wheel, places it in wheel_directory"""
+ info = make_wheel_in(pyproj_toml, Path(wheel_directory), editable=True)
+ return info.file.name
+
def build_sdist(sdist_directory, config_settings=None):
"""Builds an sdist, places it in sdist_directory"""
path = SdistBuilder.from_ini_path(pyproj_toml).build(Path(sdist_directory))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/config.py
new/flit_core-3.4.0/flit_core/config.py
--- old/flit_core-3.2.0/flit_core/config.py 2021-03-21 22:16:35.799428000
+0100
+++ new/flit_core-3.4.0/flit_core/config.py 2021-10-01 10:16:06.493757700
+0200
@@ -5,7 +5,7 @@
import os
import os.path as osp
from pathlib import Path
-import toml
+import tomli
import re
from .versionno import normalise_version
@@ -66,8 +66,7 @@
def read_flit_config(path):
"""Read and check the `pyproject.toml` file with data about the package.
"""
- with path.open('r', encoding='utf-8') as f:
- d = toml.load(f)
+ d = tomli.loads(path.read_text('utf-8'))
return prep_toml_config(d, path)
@@ -551,7 +550,9 @@
if 'dependencies' in proj:
_check_list_of_str(proj, 'dependencies')
- md_dict['requires_dist'] = proj['dependencies']
+ reqs_noextra = proj['dependencies']
+ else:
+ reqs_noextra = []
if 'optional-dependencies' in proj:
_check_type(proj, 'optional-dependencies', dict)
@@ -566,16 +567,14 @@
'Expected a string list for optional-dependencies
({})'.format(e)
)
- reqs_noextra = md_dict.pop('requires_dist', [])
lc.reqs_by_extra = optdeps.copy()
-
- # Add optional-dependencies into requires_dist
- md_dict['requires_dist'] = \
- reqs_noextra + list(_expand_requires_extra(lc.reqs_by_extra))
-
md_dict['provides_extra'] = sorted(lc.reqs_by_extra.keys())
- # For internal use, record the main requirements as a '.none' extra.
+ md_dict['requires_dist'] = \
+ reqs_noextra + list(_expand_requires_extra(lc.reqs_by_extra))
+
+ # For internal use, record the main requirements as a '.none' extra.
+ if reqs_noextra:
lc.reqs_by_extra['.none'] = reqs_noextra
if 'dynamic' in proj:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/sdist.py
new/flit_core-3.4.0/flit_core/sdist.py
--- old/flit_core-3.2.0/flit_core/sdist.py 2021-01-23 13:24:58.122672800
+0100
+++ new/flit_core-3.4.0/flit_core/sdist.py 2021-07-23 00:17:40.038788000
+0200
@@ -15,17 +15,6 @@
log = logging.getLogger(__name__)
-PKG_INFO = """\
-Metadata-Version: 1.1
-Name: {name}
-Version: {version}
-Summary: {summary}
-Home-page: {home_page}
-Author: {author}
-Author-email: {author_email}
-"""
-
-
def clean_tarinfo(ti, mtime=None):
"""Clean metadata from a TarInfo object to make it more reproducible.
@@ -195,14 +184,9 @@
if gen_setup_py:
self.add_setup_py(files_to_add, tf)
- pkg_info = PKG_INFO.format(
- name=self.metadata.name,
- version=self.metadata.version,
- summary=self.metadata.summary,
- home_page=self.metadata.home_page,
- author=self.metadata.author,
- author_email=self.metadata.author_email,
- ).encode('utf-8')
+ stream = io.StringIO()
+ self.metadata.write_metadata_file(stream)
+ pkg_info = stream.getvalue().encode()
ti = tarfile.TarInfo(pjoin(self.dir_name, 'PKG-INFO'))
ti.size = len(pkg_info)
tf.addfile(ti, io.BytesIO(pkg_info))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/.gitignore
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/.gitignore
---
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/.gitignore
2021-02-27 14:14:47.680864800 +0100
+++
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/.gitignore
1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-# Created by pytest automatically.
-*
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/CACHEDIR.TAG
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/CACHEDIR.TAG
---
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/CACHEDIR.TAG
2021-02-27 14:14:47.680864800 +0100
+++
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/CACHEDIR.TAG
1970-01-01 01:00:00.000000000 +0100
@@ -1,4 +0,0 @@
-Signature: 8a477f597d28d172789f06886806bc55
-# This file is a cache directory tag created by pytest.
-# For information about cache directory tags, see:
-# http://www.bford.info/cachedir/spec.html
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/README.md
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/README.md
---
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/README.md
2021-02-27 14:14:47.680864800 +0100
+++
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/README.md
1970-01-01 01:00:00.000000000 +0100
@@ -1,8 +0,0 @@
-# pytest cache directory #
-
-This directory contains data from the pytest's cache plugin,
-which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
-
-**Do not** commit this to version control.
-
-See [the docs](https://docs.pytest.org/en/stable/cache.html) for more
information.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/nodeids
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/nodeids
---
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/nodeids
2021-02-27 14:14:52.008859600 +0100
+++
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/nodeids
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/stepwise
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/stepwise
---
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/stepwise
2021-02-27 14:14:52.007859700 +0100
+++
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/.pytest_cache/v/cache/stepwise
1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-[]
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/pyproject.toml
new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/pyproject.toml
--- old/flit_core-3.2.0/flit_core/tests/samples/pep621_nodynamic/pyproject.toml
2021-03-15 23:45:58.354866300 +0100
+++ new/flit_core-3.4.0/flit_core/tests/samples/pep621_nodynamic/pyproject.toml
2021-08-19 19:07:06.144217700 +0200
@@ -16,7 +16,7 @@
dependencies = [
"requests >= 2.18",
"docutils",
-]
+] # N.B. Using this to check behaviour with dependencies but no optional deps
[project.urls]
homepage = "http://github.com/sirrobin/module1"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/tests/test_buildapi.py
new/flit_core-3.4.0/flit_core/tests/test_buildapi.py
--- old/flit_core-3.2.0/flit_core/tests/test_buildapi.py 2021-03-15
23:45:58.355866200 +0100
+++ new/flit_core-3.4.0/flit_core/tests/test_buildapi.py 2021-10-01
10:16:09.850773000 +0200
@@ -24,6 +24,7 @@
# importing it, so there are no build dependencies.
with cwd(osp.join(samples_dir,'pep517')):
assert buildapi.get_requires_for_build_wheel() == []
+ assert buildapi.get_requires_for_build_editable() == []
assert buildapi.get_requires_for_build_sdist() == []
def test_get_build_requires_pep621_nodynamic():
@@ -31,6 +32,7 @@
# as static metadata in pyproject.toml, so there are no build dependencies
with cwd(osp.join(samples_dir, 'pep621_nodynamic')):
assert buildapi.get_requires_for_build_wheel() == []
+ assert buildapi.get_requires_for_build_editable() == []
assert buildapi.get_requires_for_build_sdist() == []
def test_get_build_requires_import():
@@ -39,6 +41,7 @@
expected = ["numpy >=1.16.0"]
with cwd(osp.join(samples_dir, 'constructed_version')):
assert buildapi.get_requires_for_build_wheel() == expected
+ assert buildapi.get_requires_for_build_editable() == expected
assert buildapi.get_requires_for_build_sdist() == expected
def test_build_wheel():
@@ -47,6 +50,9 @@
assert filename.endswith('.whl'), filename
assert_isfile(osp.join(td, filename))
assert zipfile.is_zipfile(osp.join(td, filename))
+ with zipfile.ZipFile(osp.join(td, filename)) as zip:
+ assert "module1.py" in zip.namelist()
+ assert "module1.pth" not in zip.namelist()
def test_build_wheel_pep621():
with TemporaryDirectory() as td, cwd(osp.join(samples_dir, 'pep621')):
@@ -55,6 +61,16 @@
assert_isfile(osp.join(td, filename))
assert zipfile.is_zipfile(osp.join(td, filename))
+def test_build_editable():
+ with TemporaryDirectory() as td, cwd(osp.join(samples_dir,'pep517')):
+ filename = buildapi.build_editable(td)
+ assert filename.endswith('.whl'), filename
+ assert_isfile(osp.join(td, filename))
+ assert zipfile.is_zipfile(osp.join(td, filename))
+ with zipfile.ZipFile(osp.join(td, filename)) as zip:
+ assert "module1.py" not in zip.namelist()
+ assert "module1.pth" in zip.namelist()
+
def test_build_sdist():
with TemporaryDirectory() as td, cwd(osp.join(samples_dir,'pep517')):
filename = buildapi.build_sdist(td)
@@ -68,3 +84,10 @@
assert dirname.endswith('.dist-info'), dirname
assert_isdir(osp.join(td, dirname))
assert_isfile(osp.join(td, dirname, 'METADATA'))
+
+def test_prepare_metadata_for_build_editable():
+ with TemporaryDirectory() as td, cwd(osp.join(samples_dir,'pep517')):
+ dirname = buildapi.prepare_metadata_for_build_editable(td)
+ assert dirname.endswith('.dist-info'), dirname
+ assert_isdir(osp.join(td, dirname))
+ assert_isfile(osp.join(td, dirname, 'METADATA'))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/tests/test_config.py
new/flit_core-3.4.0/flit_core/tests/test_config.py
--- old/flit_core-3.2.0/flit_core/tests/test_config.py 2021-03-21
22:14:40.833671800 +0100
+++ new/flit_core-3.4.0/flit_core/tests/test_config.py 2021-08-19
19:07:06.144217700 +0200
@@ -39,6 +39,10 @@
assert inf.metadata['summary'] == 'Statically specified description'
assert set(inf.dynamic_metadata) == set()
+ # Filling reqs_by_extra when dependencies were specified but no optional
+ # dependencies was a bug.
+ assert inf.reqs_by_extra == {'.none': ['requests >= 2.18', 'docutils']}
+
def test_misspelled_key():
with pytest.raises(config.ConfigError) as e_info:
config.read_flit_config(samples_dir / 'misspelled-key.toml')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/tests/test_wheel.py
new/flit_core-3.4.0/flit_core/tests/test_wheel.py
--- old/flit_core-3.2.0/flit_core/tests/test_wheel.py 2021-03-21
11:25:46.340291500 +0100
+++ new/flit_core-3.4.0/flit_core/tests/test_wheel.py 2021-10-06
21:26:07.727812800 +0200
@@ -1,4 +1,5 @@
from pathlib import Path
+from zipfile import ZipFile
from testpath import assert_isfile
@@ -10,3 +11,21 @@
# Smoketest for https://github.com/takluyver/flit/issues/399
info = make_wheel_in(samples_dir / 'inclusion' / 'pyproject.toml',
tmp_path)
assert_isfile(info.file)
+
+
+def test_source_date_epoch(tmp_path, monkeypatch):
+ monkeypatch.setenv('SOURCE_DATE_EPOCH', '1633007882')
+ info = make_wheel_in(samples_dir / 'pep621' / 'pyproject.toml', tmp_path)
+ assert_isfile(info.file)
+ # Minimum value for zip timestamps is 1980-1-1
+ with ZipFile(info.file, 'r') as zf:
+ assert zf.getinfo('module1a.py').date_time[:3] == (2021, 9, 30)
+
+
+def test_zero_timestamp(tmp_path, monkeypatch):
+ monkeypatch.setenv('SOURCE_DATE_EPOCH', '0')
+ info = make_wheel_in(samples_dir / 'pep621' / 'pyproject.toml', tmp_path)
+ assert_isfile(info.file)
+ # 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)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/flit_core-3.2.0/flit_core/wheel.py
new/flit_core-3.4.0/flit_core/wheel.py
--- old/flit_core-3.2.0/flit_core/wheel.py 2021-03-21 11:25:46.340291500
+0100
+++ new/flit_core-3.4.0/flit_core/wheel.py 2021-10-06 21:26:07.728812700
+0200
@@ -2,28 +2,15 @@
import contextlib
from datetime import datetime
import hashlib
-from glob import glob
import io
import logging
import os
import os.path as osp
import stat
-import sys
import tempfile
-try:
- from types import SimpleNamespace # Python 3
-except ImportError:
- from argparse import Namespace as SimpleNamespace # Python 2
-
-HAVE_ZIPFILE36 = True
-if sys.version_info >= (3, 6):
- import zipfile
-else:
- try:
- import zipfile36 as zipfile
- except ImportError:
- import zipfile
- HAVE_ZIPFILE36 = False
+from types import SimpleNamespace
+from typing import Optional
+import zipfile
from flit_core import __version__
from . import common
@@ -48,6 +35,27 @@
zinfo.external_attr = mode << 16
+def zip_timestamp_from_env() -> Optional[tuple]:
+ """Prepare a timestamp from $SOURCE_DATE_EPOCH, if set"""
+ try:
+ # If SOURCE_DATE_EPOCH is set (e.g. by Debian), it's used for
+ # timestamps inside the zip file.
+ d = datetime.utcfromtimestamp(int(os.environ['SOURCE_DATE_EPOCH']))
+ except (KeyError, ValueError):
+ # Otherwise, we'll use the mtime of files, and generated files will
+ # default to 2016-1-1 00:00:00
+ return None
+
+ if d.year >= 1980:
+ log.info("Zip timestamps will be from SOURCE_DATE_EPOCH: %s", d)
+ # zipfile expects a 6-tuple, not a datetime object
+ return d.year, d.month, d.day, d.hour, d.minute, d.second
+ else:
+ log.info("SOURCE_DATE_EPOCH is below the minimum for zip file
timestamps")
+ log.info("Zip timestamps will be 1980-01-01 00:00:00")
+ return 1980, 1, 1, 0, 0, 0
+
+
class WheelBuilder:
def __init__(self, directory, module, metadata, entrypoints, target_fp):
"""Build a wheel from a module/package
@@ -58,23 +66,7 @@
self.entrypoints = entrypoints
self.records = []
- try:
- # If SOURCE_DATE_EPOCH is set (e.g. by Debian), it's used for
- # timestamps inside the zip file.
- d = datetime.utcfromtimestamp(int(os.environ['SOURCE_DATE_EPOCH']))
- if HAVE_ZIPFILE36:
- log.info("Zip timestamps will be from SOURCE_DATE_EPOCH: %s",
d)
- else:
- log.warning(
- "Can't use timestamp from SOURCE_DATE_EPOCH: "
- "Need Python >= 3.6 or the zipfile36 backport for this."
- )
- # zipfile expects a 6-tuple, not a datetime object
- self.source_time_stamp = (d.year, d.month, d.day, d.hour,
d.minute, d.second)
- except (KeyError, ValueError):
- # Otherwise, we'll use the mtime of files, and generated files will
- # default to 2016-1-1 00:00:00
- self.source_time_stamp = None
+ self.source_time_stamp = zip_timestamp_from_env()
# Open the zip file ready to write
self.wheel_zip = zipfile.ZipFile(target_fp, 'w',
@@ -101,30 +93,7 @@
tag = ('py2.' if self.metadata.supports_py2 else '') + 'py3-none-any'
return '{}-{}.whl'.format(dist_name, tag)
- def _add_file_old(self, full_path, rel_path):
- log.debug("Adding %s to zip file", full_path)
- full_path, rel_path = str(full_path), str(rel_path)
- if os.sep != '/':
- # We always want to have /-separated paths in the zip file and in
- # RECORD
- rel_path = rel_path.replace(os.sep, '/')
-
- self.wheel_zip.write(full_path, arcname=rel_path)
-
- hashsum = hashlib.sha256()
- with open(full_path, 'rb') as src:
- while True:
- buf = src.read(1024 * 8)
- if not buf:
- break
- hashsum.update(buf)
-
- size = os.stat(full_path).st_size
- hash_digest = urlsafe_b64encode(hashsum.digest()).decode(
- 'ascii').rstrip('=')
- self.records.append((rel_path, hash_digest, size))
-
- def _add_file_zf36(self, full_path, rel_path):
+ def _add_file(self, full_path, rel_path):
log.debug("Adding %s to zip file", full_path)
full_path, rel_path = str(full_path), str(rel_path)
if os.sep != '/':
@@ -161,8 +130,6 @@
hash_digest =
urlsafe_b64encode(hashsum.digest()).decode('ascii').rstrip('=')
self.records.append((rel_path, hash_digest, size))
- _add_file = _add_file_zf36 if HAVE_ZIPFILE36 else _add_file_old
-
@contextlib.contextmanager
def _write_to_zip(self, rel_path, mode=0o644):
sio = io.StringIO()
@@ -189,6 +156,10 @@
rel_path = osp.relpath(full_path, source_dir)
self._add_file(full_path, rel_path)
+ def add_pth(self):
+ with self._write_to_zip(self.module.name + ".pth") as f:
+ f.write(str(self.module.source_dir.resolve()))
+
def write_metadata(self):
log.info('Writing metadata files')
@@ -216,22 +187,25 @@
# RECORD itself is recorded with no hash or size
f.write(self.dist_info + '/RECORD,,\n')
- def build(self):
+ def build(self, editable=False):
try:
- self.copy_module()
+ if editable:
+ self.add_pth()
+ else:
+ self.copy_module()
self.write_metadata()
self.write_record()
finally:
self.wheel_zip.close()
-def make_wheel_in(ini_path, wheel_directory):
+def make_wheel_in(ini_path, wheel_directory, editable=False):
# We don't know the final filename until metadata is loaded, so write to
# a temporary_file, and rename it afterwards.
(fd, temp_path) = tempfile.mkstemp(suffix='.whl', dir=str(wheel_directory))
try:
with io.open(fd, 'w+b') as fp:
wb = WheelBuilder.from_ini_path(ini_path, fp)
- wb.build()
+ wb.build(editable)
wheel_path = wheel_directory / wb.wheel_filename
os.replace(temp_path, str(wheel_path))