Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ build-backend = "setuptools.build_meta"
name = "aexpect"
description = "Python library used to control interactive programs"
readme = "README.rst"
dynamic = ["version"]
license = "GPL-2.0-or-later"
version = "1.8.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep away from hardcoded versions as much as possible. As I'm not really a spec-file person, I asked AI and it came-up with this:

diff --git a/aexpect/__init__.py b/aexpect/__init__.py
index 3e32262..6d714d1 100644
--- a/aexpect/__init__.py
+++ b/aexpect/__init__.py
@@ -14,6 +14,8 @@ Aexpect module, see help('aexpect.client') to get info about the main
 entry-points.
 """
 
+# _version is generated by tool.setuptools_scm
+from ._version import version as __version__
 from . import remote, rss_client
 from .client import (
     Expect,
diff --git a/pyproject.toml b/pyproject.toml
index 085928f..dfb3782 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
 name = "aexpect"
 description = "Python library used to control interactive programs"
 readme = "README.rst"
-version = "1.8.0"
+dynamic = ["version"]
 license = {text = "GPL-2.0-or-later"}
 authors = [{name = "Aexpect developers", email = "[email protected]"}]
 maintainers = [{name = "Aexpect developers", email = "[email protected]"}]
@@ -44,6 +44,7 @@ include = ["aexpect*"]
 [tool.setuptools_scm]
 version_scheme = "post-release"
 local_scheme = "node-and-date"
+write_to = "aexpect/_version.py"
 
 [tool.black]
 line-length = 79

would it work for you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively it suggested:

%build
export SETUPTOOLS_SCM_PRETEND_VERSION=%{version}
%pyproject_wheel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried identical export of a variable suggested by AI and it didn't work - in fact I stated the various problems I encountered in the commit messages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure what the problem is, I built the previous version as well as my suggested one and they all worked like a charm on F42. Could you please share the steps that fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so let me elaborate with details about the error here. The initial error I would get without any change regarding the version is

Error: The version in the Python package metadata 0.0.0 normalizes to zero.
It's likely a packaging error caused by missing version information
(e.g. when using a version control system snapshot as a source).
Try providing the version information manually when building the Python package,
for example by setting the SETUPTOOLS_SCM_PRETEND_VERSION environment variable if the package uses setuptools_scm.
If you are confident that the version of the Python package is intentionally zero,
you may %define the _python_dist_allow_version_zero macro in the spec file to disable this check.

error: Dependency tokens must begin with alpha-numeric, '_' or '/': *** PYTHON_PROVIDED_VERSION_NORMALIZES_TO_ZERO___SEE_STDERR ***
Provides: python-aexpect = 1.8.0-1.fc42 python3-aexpect = 1.8.0-1.fc42 python3.13-aexpect = 1.8.0-1.fc42
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PartialHardlinkSets) <= 4.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: /usr/bin/python3 python(abi) = 3.13
    bogus date in %changelog: Tue Feb 28 2022 Lucas Meneghel Rodrigues <[email protected]> - 1.7.0-1
    bogus date in %changelog: Tue Feb 28 2022 Lucas Meneghel Rodrigues <[email protected]> - 1.7.0-1
    Dependency tokens must begin with alpha-numeric, '_' or '/': *** PYTHON_PROVIDED_VERSION_NORMALIZES_TO_ZERO___SEE_STDERR ***

and will remain the same error whether I implement the diff in 262b9a8#r2661195752 or the exported variable or both (have already tried the exported variable before too).

My environment is the same OS like yours, the fact it is a container should not matter:

# cat /etc/os-release 
NAME="Fedora Linux"
VERSION="42 (Container Image)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=42
VERSION_CODENAME=""
PLATFORM_ID="platform:f42"
PRETTY_NAME="Fedora Linux 42 (Container Image)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:42"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f42/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=42
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=42
SUPPORT_END=2026-05-13
VARIANT="Container Image"
VARIANT_ID=container

I tried identical export of a variable suggested by AI and it didn't work - in fact I stated the various problems I encountered in the commit messages.

These are other things I tried from the commit message:

The RPM spec file already contains a fixed or non-dynamic version
so having a dynamic version for the pyproject.toml doesn't bring
any benefit. Exporting env variables to force such a version is
complicated when mixed with the isolated bash environments for the
separate stages and sed-ing the pyproject file is invasive and
might not work with all autosetup magic.

@ldoktor Do you think any different in rpmbuild versions might affect this? Just in case:

# rpmbuild --version
RPM version 4.20.1

license = {text = "GPL-2.0-or-later"}
authors = [{name = "Aexpect developers", email = "[email protected]"}]
maintainers = [{name = "Aexpect developers", email = "[email protected]"}]
requires-python = ">=3.8"
Expand Down
9 changes: 4 additions & 5 deletions python-aexpect.spec
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ sftp, telnet, among others.
%endif

%build
%py3_build
%pyproject_wheel

%install
%py3_install
%pyproject_install
%pyproject_save_files aexpect
ln -s aexpect_helper %{buildroot}%{_bindir}/aexpect_helper-%{python3_pkgversion}
ln -s aexpect_helper %{buildroot}%{_bindir}/aexpect_helper-%{python3_version}

Expand All @@ -72,11 +73,9 @@ ln -s aexpect_helper %{buildroot}%{_bindir}/aexpect_helper-%{python3_version}
selftests/checkall
%endif

%files -n python3-aexpect
%files -n python3-aexpect -f %{pyproject_files}
%license LICENSE
%doc README.rst
%{python3_sitelib}/aexpect/
%{python3_sitelib}/aexpect-%{version}-py%{python3_version}.egg-info/
%{_bindir}/aexpect_helper*

%changelog
Expand Down
Loading