From 09ec4701afe07d4376ff7d16d0375859a8a54f5d Mon Sep 17 00:00:00 2001 From: paugier Date: Thu, 15 May 2025 16:10:08 +0200 Subject: [PATCH 1/3] ci: install setuptools-scm to install with the right version number --- .github/workflows/ci.yml | 4 ++-- pyproject.toml | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ec548c06..acc554921 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: allow-prereleases: true - name: Install/Upgrade Python dependencies - run: python -m pip install --upgrade pip wheel 'setuptools>=60.2' + run: python -m pip install --upgrade pip wheel 'setuptools>=60.2' 'setuptools-scm[toml]>=6.0' - name: Build run: | @@ -80,7 +80,7 @@ jobs: run: python -c "import sys; print(hasattr(sys, 'gettotalrefcount'))" - name: Install/Upgrade Python dependencies - run: python -m pip install --upgrade pip wheel + run: python -m pip install --upgrade pip wheel 'setuptools>=60.2' 'setuptools-scm[toml]>=6.0' - name: Build run: | diff --git a/pyproject.toml b/pyproject.toml index a3194aec7..e18e719b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,5 @@ [build-system] requires = [ "setuptools>=64.0", "setuptools-scm[toml]>=6.0", "wheel>=0.34.2",] build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] From 51db6b38fdcb892b5734d2b1405046b15183a658 Mon Sep 17 00:00:00 2001 From: paugier Date: Thu, 15 May 2025 17:07:51 +0200 Subject: [PATCH 2/3] test_dont_mix_cpython_and_universal_abis with pyproject.toml and pip calls --- test/hpy_devel/test_distutils.py | 36 ++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/test/hpy_devel/test_distutils.py b/test/hpy_devel/test_distutils.py index 62904f095..affc7effa 100644 --- a/test/hpy_devel/test_distutils.py +++ b/test/hpy_devel/test_distutils.py @@ -182,16 +182,27 @@ def gen_project(self): HPy_MODINIT(hpymod_legacy, moduledef) """) + def _gen_file(self, fname, preamble, src): + """Generate a file inside hpy_test_project""" + src = textwrap.dedent(preamble) + textwrap.dedent(src) + self.hpy_test_project.join(fname).write(src) + def gen_setup_py(self, src): - preamble = textwrap.dedent(""" + preamble = """ from setuptools import setup, Extension cpymod = Extension("cpymod", ["cpymod.c"]) hpymod = Extension("hpymod", ["hpymod.c"]) hpymod_legacy = Extension("hpymod_legacy", ["hpymod_legacy.c"]) - """) - src = preamble + textwrap.dedent(src) - f = self.hpy_test_project.join('setup.py') - f.write(src) + """ + self._gen_file('setup.py', preamble, src) + + def gen_pyproject_toml(self, src="[project]\nname = 'hpy_test_project'\nversion = '0.0.0'\n"): + preamble = """ + [build-system] + requires = ["setuptools>=64.0", "hpy; implementation_name == 'cpython'"] + build-backend = "setuptools.build_meta" + """ + self._gen_file('pyproject.toml', preamble, src) def get_docstring(self, modname): cmd = f'import {modname}; print({modname}.__doc__)' @@ -297,13 +308,11 @@ def test_dont_mix_cpython_and_universal_abis(self): """ # make sure that the build dirs for cpython and universal ABIs are # distinct - self.gen_setup_py(""" - setup(name = "hpy_test_project", - hpy_ext_modules = [hpymod], - install_requires = [], - ) - """) - self.python('setup.py', 'install') + self.gen_setup_py("setup(hpy_ext_modules = [hpymod])") + self.gen_pyproject_toml() + + command = ['-m', 'pip', 'install', '.', '-v', '--no-build-isolation'] + self.python(*command) # in the build/ dir, we should have 2 directories: temp and lib build = self.hpy_test_project.join('build') temps = build.listdir('temp*') @@ -315,7 +324,8 @@ def test_dont_mix_cpython_and_universal_abis(self): assert doc == 'hpymod with HPy ABI: cpython' # now recompile with universal *without* cleaning the build - self.python('setup.py', '--hpy-abi=universal', 'install') + command.append('--config-settings=--global-option=--hpy-abi=universal') + self.python(*command) # in the build/ dir, we should have 4 directories: 2 temp*, and 2 lib* build = self.hpy_test_project.join('build') temps = build.listdir('temp*') From baeb2fa9cae9a2834f44cddf95b77c65a5f358bd Mon Sep 17 00:00:00 2001 From: paugier Date: Thu, 15 May 2025 22:32:38 +0200 Subject: [PATCH 3/3] ci: try Check Python 2.7 compatibility with Ubuntu 22.04 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index acc554921..7f68ace7e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -322,7 +322,7 @@ jobs: check_py27_compat: name: Check Python 2.7 compatibility - runs-on: 'ubuntu-20.04' + runs-on: 'ubuntu-22.04' steps: - uses: actions/checkout@v4