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.2.0 #612

Closed
djhoese opened this issue Aug 27, 2021 · 15 comments · Fixed by #616
Closed

AttributeError: 'Version' object has no attribute 'release' after upgrade to 6.2.0 #612

djhoese opened this issue Aug 27, 2021 · 15 comments · Fixed by #616

Comments

@djhoese
Copy link

djhoese commented Aug 27, 2021

Related to #605 and #607.

I was just running a CI job to create wheels and sdist for the vispy project and it just picked up setuptools_scm 6.2.0 (released 16 minutes ago) and fails during sdist building. I noticed #607 says that modern setuptools should use pip. What is the recommended way to build an sdist package if not python setup.py sdist to avoid this error?

 Traceback (most recent call last):
  File "setup.py", line 150, in <module>
    'Framework :: IPython'
  File "/opt/hostedtoolcache/Python/3.7.11/x64/lib/python3.7/site-packages/setuptools/__init__.py", line 144, in setup
    return distutils.core.setup(**attrs)
  File "/opt/hostedtoolcache/Python/3.7.11/x64/lib/python3.7/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/opt/hostedtoolcache/Python/3.7.11/x64/lib/python3.7/site-packages/setuptools/dist.py", line 426, in __init__
    k: v for k, v in attrs.items()
  File "/opt/hostedtoolcache/Python/3.7.11/x64/lib/python3.7/distutils/dist.py", line 292, in __init__
    self.finalize_options()
  File "/opt/hostedtoolcache/Python/3.7.11/x64/lib/python3.7/site-packages/setuptools/dist.py", line 717, in finalize_options
    ep(self)
  File "/opt/hostedtoolcache/Python/3.7.11/x64/lib/python3.7/site-packages/setuptools/dist.py", line 724, in _finalize_setup_keywords
    ep.load()(self, ep.name, value)
  File "/home/runner/work/vispy/vispy/.eggs/setuptools_scm-6.2.0-py3.7.egg/setuptools_scm/integration.py", line 29, in version_keyword
    dist.metadata.version = _get_version(config)
  File "/home/runner/work/vispy/vispy/.eggs/setuptools_scm-6.2.0-py3.7.egg/setuptools_scm/__init__.py", line 192, in _get_version
    template=config.write_to_template,
  File "/home/runner/work/vispy/vispy/.eggs/setuptools_scm-6.2.0-py3.7.egg/setuptools_scm/__init__.py", line 94, in dump_version
    version_fields = parsed_version.release
AttributeError: 'Version' object has no attribute 'release'
@RonnyPfannschmidt
Copy link
Contributor

@jaraco what the heck is up with that - i made setuptools_scm crash setup.py on bdist_egg and it STILL installs eggs on broken/old setuptools

also version 6.2.0 was pulled for another mistake

@RonnyPfannschmidt
Copy link
Contributor

@djhoese the recommended way is to upgrade pip, setuptools and wheel before building a sdist, ideally one uses the build tool

like we do in

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install --upgrade wheel setuptools build
- name: Build package
run: python -m build -s -w -o dist/

@djhoese
Copy link
Author

djhoese commented Aug 27, 2021

What's sad about this is that I've learned about the build tool in the past and somehow forgot about it when updating VisPy's CI. I was updating pip already, but wasn't updating the other packages. Looks like sdist is building again now so feel free to close this as far as my issue is concerned. Now just waiting on GitHub Actions to start the other deployment jobs...

@RonnyPfannschmidt
Copy link
Contributor

im leaving this open until i understand why the heck we did manage to build a egg

@henryiii
Copy link
Contributor

henryiii commented Aug 27, 2021

Or use pyproject.toml, in which case, you specify setuptools and wheel, and it always works, instead of requiring something on the user's side. You can also use build through pipx, since it's an eXecutable, not a library. So then that becomes:

# No setup-python or install dependencies step required

     - name: Build package 
       run: pipx run build 

Also, never pass both -s and -w to build, as it defaults to doing a source then a wheel from the SDist, which is better than building the wheel and SDist independently - can catch a buggy SDist that way. You can set the output directory if you want, but it defaults to dist/ already.

@djhoese
Copy link
Author

djhoese commented Aug 27, 2021

@henryiii My project has a pyproject.toml, but the setuptools version specifier is based on whatever version was in the setuptools_scm instructions at the time of adding it. Not sure if that's what you are saying. If you're curious: https://github.com/vispy/vispy/blob/main/pyproject.toml

@henryiii
Copy link
Contributor

Quick note: you should always specify build-backend in pyproject.toml, either build-backend = "setuptools.build_meta" (much better) or build-backend = "setuptools.build_meta:__legacy__ (what you implicitly have now, but clarifies that you really are stuck with then legacy builder).

Also, never put anything less than setuptools>=42 in pyproject.toml. Versions before that didn't support pyproject.toml, so if you have a cached version of 40 or 41, they will break (this has happened to me). 40+ sort-of half supports it, but only 42+ really does.

Good, then you don't need to specify setuptools and wheel, but you do need to use a builder that can build PEP 517 projects with PEP 518 dependencies. Just directly calling python setup.py sdist sticks you with whatever is present already, and installs in your environment, instead of an isolated one.

@henryiii
Copy link
Contributor

(But this should also be fixed, these are just general recommendations for the future)

@djhoese
Copy link
Author

djhoese commented Aug 27, 2021

Ok so to clarify: if I use the build tool, I should be able to specify the build-backend as setuptools.build_meta in my pyproject.toml and remove setuptools and wheel from the dependencies and only list setuptools_scm (as far as packaging/versioning dependencies go). Technically I am depending on setuptools though so maybe I should just list setuptools as a dependency and let setuptools_scm force the setuptools version to >45?

@henryiii
Copy link
Contributor

henryiii commented Aug 27, 2021

If you use the build tool, you do not need to pre-install or update setuptools or wheel. Build, like pip, will make a temporary virtual environment, install exactly what you ask for (and only that) in the temporary virtual environment, and once it has an SDist or wheel, will remove the virtual environment. If you were using pip, it would do the same thing - pip wheel . builds the wheel, and pip install . builds the wheel in the temporary environment then installs it in the current environment. There isn't a way to build SDists with pip though, and pip really doesn't need to have a wheel command (it has to build wheels as part of what it does to install, so it was an easy addition), so build is required for proper SDist building that respects pyproject.toml, and recommended for wheel building.

You need wheel, setuptools, and setuptools_scm in your requires. You probably get setuptools from setuptools_scm, but don't count on it - always list the things you depend on, never trust transitive dependencies. I'm used to putting >=42 here, and that should continue to be safe even if setuptools_scm forces something higher. But you can always set it higher if you'd like.

build-backend isn't for build specifically, it's the backend all builders will look for and use, pip and build included.

nijel added a commit to WeblateOrg/docker that referenced this issue Aug 28, 2021
RonnyPfannschmidt added a commit to RonnyPfannschmidt/setuptools_scm that referenced this issue Aug 29, 2021
* fix pypa#612: depend on packaging to ensure version parsing parts
* fix pypa#611: correct the typo that hid away the toml extra and add it in ``setup.py`` as well
* fix pypa#615: restore support for the git_archive plugin which doesn't pass over the config
@ewherrmann
Copy link

I am having this issue as well because pip install of pdoc3 is still trying to use setuptools_scm version 6.2.0 even though it's been yanked. Any ideas how to force to use version 6.0.1?

Step 8/13 : RUN pip3 install --no-cache-dir -q -r /app/requirements.txt &&     pip3 install --no-cache-dir -q /app/blobs/PyRFC-1.9.93.zip &&     python3 /app/manage.py collectstatic --noinput
 ---> Running in 257022f10406
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2_deg70e/pdoc3_b478f1d33f234eef99e8b4df6628dea4/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2_deg70e/pdoc3_b478f1d33f234eef99e8b4df6628dea4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-7s5l679d
         cwd: /tmp/pip-install-2_deg70e/pdoc3_b478f1d33f234eef99e8b4df6628dea4/
    Complete output (21 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-2_deg70e/pdoc3_b478f1d33f234eef99e8b4df6628dea4/setup.py", line 60, in <module>
        python_requires='>= 3.5',
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.7/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__
        k: v for k, v in attrs.items()
      File "/usr/lib/python3.7/distutils/dist.py", line 292, in __init__
        self.finalize_options()
      File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 739, in finalize_options
        ep.load()(self, ep.name, value)
      File "/tmp/pip-install-2_deg70e/pdoc3_b478f1d33f234eef99e8b4df6628dea4/.eggs/setuptools_scm-6.2.0-py3.7.egg/setuptools_scm/integration.py", line 29, in version_keyword
        dist.metadata.version = _get_version(config)
      File "/tmp/pip-install-2_deg70e/pdoc3_b478f1d33f234eef99e8b4df6628dea4/.eggs/setuptools_scm-6.2.0-py3.7.egg/setuptools_scm/__init__.py", line 192, in _get_version
        template=config.write_to_template,
      File "/tmp/pip-install-2_deg70e/pdoc3_b478f1d33f234eef99e8b4df6628dea4/.eggs/setuptools_scm-6.2.0-py3.7.egg/setuptools_scm/__init__.py", line 94, in dump_version
        version_fields = parsed_version.release
    AttributeError: 'Version' object has no attribute 'release'
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/51/96/bf85b7bd7c18c8f6f4f85720875de817f124da3ee1d07adea84c20cbbe67/pdoc3-0.6.2.tar.gz#sha256=bfc011da61a3edd4bb1ec2b8dcaa483776b67a30bf67a28760ab25edd9dc502c (from https://pypi.org/simple/pdoc3/) (requires-python:>= 3.5). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement pdoc3==0.6.2 (from versions: 0.3.11, 0.3.12, 0.3.13, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.5.4, 0.6.0, 0.6.1, 0.6.2, 0.6.3, 0.6.4, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.7.4, 0.7.5, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.9.0, 0.9.1, 0.9.2, 0.10.0)
ERROR: No matching distribution found for pdoc3==0.6.2
The command '/bin/sh -c pip3 install --no-cache-dir -q -r /app/requirements.txt &&     pip3 install --no-cache-dir -q /app/blobs/PyRFC-1.9.93.zip &&     python3 /app/manage.py collectstatic --noinput' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1

@RonnyPfannschmidt
Copy link
Contributor

Install it using the system package manager

The next release will error out with a long message explaining the fixes

@ewherrmann
Copy link

@RonnyPfannschmidt thanks for the reply. Just to be clear, are you suggesting to install setuptools_scm using the system package manager?

@RonnyPfannschmidt
Copy link
Contributor

@ehashman that depends on your particular setup , depending on what it is, it may be a good idea to put build dependencies like pip/setuptools/setuptools_scm/wheel into layers using either pip or the system package manager

ar first glance it looks like on your case a pip based install may be fine, but i also suggest to update pip+setuptools first

@ewherrmann
Copy link

@RonnyPfannschmidt Thanks again. I was able to get the correct non-yanked release installed and running without error using apt-get install python3-setuptools-scm

berland added a commit to equinor/pyscal that referenced this issue Sep 1, 2021
setuptools_scm  6.1 gives the error message:
  AttributeError: 'Version' object has no attribute 'release'

See pypa/setuptools_scm#612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants