setuptools icon indicating copy to clipboard operation
setuptools copied to clipboard

[BUG] Version normalization making an unexpected change

Open CamDavidsonPilon opened this issue 1 year ago • 4 comments

setuptools version

>=40.8.1

Python version

3.11

OS

ubuntu

Additional environment information

Run in the github action

Description

When building a wheel using github actions, my version was normalized from 24.2.25r0 to 24.2.25.post0. I am not able to reproduce this locally, as 24.2.25r0 should be a valid version name. Here is a link the the action logs: https://github.com/Pioreactor/pioreactor/actions/runs/8040467416/job/21958604300#step:5:10

Expected behavior

I expected there to be no change to the version name.

How to Reproduce

I've rerun the github action, and it's giving the same change.

However, locally, no change is introduced:

from setuptools import setuptools
from setuptools import dist
d = dist.Distribution()
d._normalize_version('24.2.25rc0')

Output

'24.2.25rc0'

CamDavidsonPilon avatar Feb 26 '24 15:02 CamDavidsonPilon

I guess what is happening is:

  • in your local machine pip is choosing to use a "non-isolated build" so it just uses the version of setuptools that you have installed in the environment (probably an updated one)
  • in the CI, pip is choosing to use an "isolated build", and therefore it creates a brand new virtual environment. In this new virtual environment an old version of setuptools is being used.

(Or vice-versa)

To read more about build isolation you can refer to https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/#build-isolation.

To consistently disable the "build isolation" feature in pip you can:

  1. Install the latest version of setuptools and wheel + any other build dependencies, and
  2. Run pip install with the --no-build-isolation flag.

If you try this you should at least see a consistent behaviour between the local machine and CI.

Would you like to give this a try and see how it goes?

abravalheri avatar Feb 26 '24 21:02 abravalheri

I am not able to reproduce this locally, as 24.2.25r0 should be a valid version name.

I am supposing that here you mean ...rc0 instead of ...r0

abravalheri avatar Feb 26 '24 21:02 abravalheri

Thank you @abravalheri I will try that.

I am supposing that here you mean ...rc0 instead of ...r0

Ah yes, I did mean rc0.

CamDavidsonPilon avatar Feb 26 '24 22:02 CamDavidsonPilon

Alternatively, to consistently enable build isolation, you can add a pyproject.toml file:

[build-system]
requires = ["setuptools>=69.1.1"]
build-backend = "setuptools.build_meta"

This way, you can specify a minimum version required for the setuptools that will be installed in the "disposable" build environment.

abravalheri avatar Feb 27 '24 05:02 abravalheri

I haven't seen this problem since, so I suspect it was something odd unique to my setup. I feel this issue can be closed.

CamDavidsonPilon avatar Jun 12 '24 01:06 CamDavidsonPilon