snapcraft clean on macOS failing, python os.sched_getaffinity does not exist

Bug #1866251 reported by Mark M Evans
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
Undecided
Chris Patterson

Bug Description

Builds work fine (via multipass) but clean fails because macOs python does not support sched_getaffinity.

$ multipass --version
multipass 1.1.0+mac
multipassd 1.1.0+mac
$ snapcraft --version
snapcraft, version 3.9.1
$ snapcraft clean
Sorry, an error occurred in Snapcraft:
module 'os' has no attribute 'sched_getaffinity'
Traceback (most recent call last):
  File "/usr/local/bin/snapcraft", line 8, in <module>
    sys.exit(run())
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/cli/_command.py", line 88, in invoke
    return super().invoke(ctx)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/cli/lifecycle.py", line 356, in clean
    lifecycle.clean(project, parts, steps.PRIME)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/internal/lifecycle/_clean.py", line 199, in clean
    config = project_loader.load_config(project)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/internal/project_loader/__init__.py", line 39, in load_config
    return Config(project)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/internal/project_loader/_config.py", line 212, in __init__
    self.data = self._expand_env(snapcraft_yaml)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/internal/project_loader/_config.py", line 335, in _expand_env
    snapcraft_global_environment(self.project)
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/internal/project_loader/_env.py", line 110, in snapcraft_global_environment
    "SNAPCRAFT_PARALLEL_BUILD_COUNT": str(project.parallel_build_count),
  File "/usr/local/Cellar/snapcraft/3.10/libexec/lib/python3.7/site-packages/snapcraft/project/_project_options.py", line 134, in parallel_build_count
    return len(os.sched_getaffinity(0))
AttributeError: module 'os' has no attribute 'sched_getaffinity'

Revision history for this message
Mark M Evans (markmevans) wrote :
description: updated
Revision history for this message
Chris Patterson (cjp256) wrote :

Thank you for the report. We will fix shortly.

FWIW, I don't think we should calculate SNAPCRAFT_PARALLEL_BUILD_COUNT until build-time. It's really a matter of the resources available in the build-environment that matters, not the host...

Changed in snapcraft:
status: New → Confirmed
Revision history for this message
Chris Patterson (cjp256) wrote :
Changed in snapcraft:
assignee: nobody → Chris Patterson (cjp256)
status: Confirmed → In Progress
Revision history for this message
Mark M Evans (markmevans) wrote :
Download full text (5.8 KiB)

Thanks for the quick fix. I checked out the branch and I'm running into another issue now. Specifically:

$ snapcraft clean
Failed to get information for snap 'core': could not connect to 'http+unix://%2Frun%2Fsnapd.socket/v2/snaps/core'.

I hacked in a `traceback.print_exc()` in the 2 places that raise that error and got the following:

$ snapcraft clean
Traceback (most recent call last):
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1252, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1298, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1247, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/http/client.py", line 966, in send
    self.connect()
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/requests_unixsocket/adapters.py", line 32, in connect
    sock.connect(socket_path)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/urllib3/util/retry.py", line 368, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/Users/markmevans/riptide/source/snapcraft.fix-sched/py3env.fix-sched/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr...

Read more...

Revision history for this message
Chris Patterson (cjp256) wrote :

Sorry I missed the follow up post, hopefully it's no longer an issue. But closing the original scope as Fix Released, if you're still having issues please create a new issue and we'll investigate.

Changed in snapcraft:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.