Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'Version' object has no attribute 'release' after upgrade to 6.1.0 #605

Closed
P403n1x87 opened this issue Aug 26, 2021 · 15 comments · Fixed by #607 or googlefonts/gftools#406

Comments

@P403n1x87
Copy link

We have jobs in CI that depend on the latest version of this extension and so as soon as 6.1.0 became available on PyPI we started hitting the following error:

Traceback (most recent call last):
  File "setup.py", line 150, in <module>
    setup(
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.8/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 447, in __init__
    _Distribution.__init__(self, {
  File "/usr/lib/python3.8/distutils/dist.py", line 292, in __init__
    self.finalize_options()
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 740, in finalize_options
    ep.load()(self)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 747, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/home/circleci/project/.eggs/setuptools_scm-6.1.0-py3.8.egg/setuptools_scm/integration.py", line 26, in version_keyword
    dist.metadata.version = _get_version(config)
  File "/home/circleci/project/.eggs/setuptools_scm-6.1.0-py3.8.egg/setuptools_scm/__init__.py", line 188, in _get_version
    dump_version(
  File "/home/circleci/project/.eggs/setuptools_scm-6.1.0-py3.8.egg/setuptools_scm/__init__.py", line 94, in dump_version
    version_fields = parsed_version.release
AttributeError: 'Version' object has no attribute 'release'

Our setup.py has the following

    use_scm_version={"write_to": "ddtrace/_version.py"},
    setup_requires=["setuptools_scm[toml]>=4", "cython"],

and we also have

"packaging>=17.1",

in install_requires.

@RonnyPfannschmidt
Copy link
Contributor

I'll get to debugging this as soon as the toddler is sleeping

@crockeo
Copy link

crockeo commented Aug 26, 2021

I'll leave it up to maintainers to provide a definitive answer, but it looks like this occurs because of an incompatibility between an old version of setuptools and a new version of setuptools_scm. This commit from October 2019 introduced the release field to Versions in the vendored copy of packaging bundled with setuptools which is included in any release after setuptools==42.0.0.

Tl;dr upgrade setuptools to setuptools>=42.0.0.

@RonnyPfannschmidt
Copy link
Contributor

RonnyPfannschmidt commented Aug 26, 2021

I suspect its a missed compatibility test between setuptools and packaging, please try a setuptools update as well (i believe i missed that old setuptools vendors a too old packaging)

Any setuptools that tries to use pip instead of easy install is likely recent enough

@RonnyPfannschmidt
Copy link
Contributor

@crockeo thanks for verifying my suspicion faster than I send it out

@crockeo
Copy link

crockeo commented Aug 26, 2021

Just dealt with a support ticket about this earlier today, so I wanted to share my findings upstream 🙂

@RonnyPfannschmidt
Copy link
Contributor

yanked the release now that i'm back at the computer, will work on a fix now

@RonnyPfannschmidt
Copy link
Contributor

i finished analysis - setuptools is ignoring the requirement for setuptools >= 45

the line in https://github.com/pypa/setuptools_scm/blob/main/setup.py#L31 should have sorted the issue, it didn't

@henryiii
Copy link
Contributor

henryiii commented Aug 27, 2021

setup.py isn't run (or included) when you install from a wheel, so virtually no one should see that error.

@RonnyPfannschmidt
Copy link
Contributor

@henryiii the error happens in a build egg location, so it is executed

asb added a commit to asb/opentitan that referenced this issue Aug 27, 2021
CI is currently failing:
* <lowRISC#7952>
* <pypa/setuptools_scm#605>

While this isn't necessarily the correct direct fix, it seems like it
would be better for the Docker image build to be aligned with
ci/install-build-deps.sh (which will always update to the latest pip and
setuptools).

Signed-off-by: Alex Bradbury <asb@lowrisc.org>
asb added a commit to asb/opentitan that referenced this issue Aug 27, 2021
CI is currently failing:
* <lowRISC#7952>
* <pypa/setuptools_scm#605>

While this isn't necessarily the correct direct fix, it seems like it
would be better for the Docker image build to be aligned with
ci/install-build-deps.sh (which will always update to the latest pip and
setuptools).

Also, as a test, install python deps with --user (which also better
aligns with the CI dependency installation).

Signed-off-by: Alex Bradbury <asb@lowrisc.org>
RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Aug 27, 2021
copybara-service bot pushed a commit to google/pigweed that referenced this issue Aug 27, 2021
On Debian venv creation uses a fairly old version of setuptools:

  /usr/bin/python3 -m venv --upgrade /tmp/venv; /tmp/venv/bin/pip list
  Package       Version
  ------------- -------
  pip           20.3.4
  pkg-resources 0.0.0
  setuptools    44.1.1

This can cause issues installing packages, e.g.
pypa/setuptools_scm#605

Upgrade setuptools in addition to pip. This matches the builtin behavior
of venv when passing the new --upgrade-deps option, which we could
eventually use to have these packages upgraded automatically upon venv
creation.

Also log the output of the upgrade as this might be useful later.
Debugging bootstrap is quite a bit harder when all of the output is
discarded.

No-Docs-Update-Reason: bug fix
Change-Id: I3c13ccef171f5e9d17b6781341568e7b9909a161
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/58520
Commit-Queue: Michael Spang <spang@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
brettlangdon added a commit to DataDog/dd-trace-py that referenced this issue Aug 27, 2021
setuptool_scm>=6.1 has had issues with external dependencies and changing extras
pypa/setuptools_scm#611
pypa/setuptools_scm#605
@mspang
Copy link

mspang commented Aug 27, 2021

I'd suggest finding a way to retain compatibility with older setuptools as virtualenvs with older setuptools than you require are produced by default on every system I've tried.

@henryiii
Copy link
Contributor

henryiii commented Aug 27, 2021

(Not that I like being stuck with old versions of things, but I agree - upgrading setuptools as a requirement has always been very hard to do. It's solved by PEP 517, but not everyone is using that (though I'm not sure why not).)

mergify bot pushed a commit to DataDog/dd-trace-py that referenced this issue Aug 27, 2021
* Cap setuptools_scm <6.1
setuptool_scm>=6.1 has had issues with external dependencies and changing extras
pypa/setuptools_scm#611
pypa/setuptools_scm#605

* Add release note

* also update pyproject.toml
mergify bot pushed a commit to DataDog/dd-trace-py that referenced this issue Aug 27, 2021
* Cap setuptools_scm <6.1
setuptool_scm>=6.1 has had issues with external dependencies and changing extras
pypa/setuptools_scm#611
pypa/setuptools_scm#605

* Add release note

* also update pyproject.toml

(cherry picked from commit 5b8d345)

# Conflicts:
#	setup.py
mergify bot pushed a commit to DataDog/dd-trace-py that referenced this issue Aug 27, 2021
* Cap setuptools_scm <6.1
setuptool_scm>=6.1 has had issues with external dependencies and changing extras
pypa/setuptools_scm#611
pypa/setuptools_scm#605

* Add release note

* also update pyproject.toml

(cherry picked from commit 5b8d345)

# Conflicts:
#	setup.py
mergify bot added a commit to DataDog/dd-trace-py that referenced this issue Aug 27, 2021
* Cap setuptools_scm <6.1 (#2816)

* Cap setuptools_scm <6.1
setuptool_scm>=6.1 has had issues with external dependencies and changing extras
pypa/setuptools_scm#611
pypa/setuptools_scm#605

* Add release note

* also update pyproject.toml

(cherry picked from commit 5b8d345)

# Conflicts:
#	setup.py

* Update setup.py

* Update setup.py

Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com>
mergify bot added a commit to DataDog/dd-trace-py that referenced this issue Aug 27, 2021
* Cap setuptools_scm <6.1 (#2816)

* Cap setuptools_scm <6.1
setuptool_scm>=6.1 has had issues with external dependencies and changing extras
pypa/setuptools_scm#611
pypa/setuptools_scm#605

* Add release note

* also update pyproject.toml

(cherry picked from commit 5b8d345)

# Conflicts:
#	setup.py

* Update setup.py

* Update setup.py

Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com>
m4rc1e added a commit to m4rc1e/tools that referenced this issue Aug 31, 2021
m4rc1e added a commit to googlefonts/gftools that referenced this issue Aug 31, 2021
@muthu-tech
Copy link

muthu-tech commented Aug 31, 2021

Pip installation that was working with python36-devel stopped working while called via DockerFile. And I tried setuptools latest version, still it throws AttributeError: 'Version' object has no attribute 'release'.

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-tzjqsevs/petl/

Can someone please let me know any options worth trying to get back working pip installations via docker

@RonnyPfannschmidt
Copy link
Contributor

@muthu-tech update pip and setuptools

@muthu-tech
Copy link

@muthu-tech update pip and setuptools

@RonnyPfannschmidt I did that . I have ,
python3 -m pip install --upgrade pip

python3 -m pip install -r requirements.txt

and first entry in requirements.txt has setuptools==57.4.0

And it throws

ERROR: Could not install packages due to an OSError: [Errno 39] Directory not empty: 'pycache'

FYI, these commands are inside a dockerfile and pip installations were working fine until last week and right now they are broken.

@RonnyPfannschmidt
Copy link
Contributor

Update setuptools first in requirements is too late

p12tic added a commit to p12tic/buildbot that referenced this issue Sep 4, 2021
Looks like setuptools_scm broke its compatibility with older setuptools.
See pypa/setuptools_scm#605. Recommended
solution is to upgrade pip and setuptools to newest version. Since we're
upgrading setuptools on our Linux CI anyway, do the same on appveyor.
m4rc1e added a commit to m4rc1e/tools that referenced this issue Oct 13, 2021
zaro0508 added a commit to zaro0508/sceptre that referenced this issue Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants