error: [Errno 2] No such file or directory: 'build/test1.c' #22

Closed
juanrubio opened this Issue Jun 30, 2016 · 7 comments

Comments

Projects
None yet
4 participants

juanrubio commented Jun 30, 2016

Hi!,

I'm trying to create a snap package for my project (https://github.com/tizonia/tizonia-openmax-il), and I'm finding this error when pycryptodomex' setup.py is being run.

Pycryptodomex is being pulled as my project depends on 'gmusicapi', and 'gmusicapi' depends on 'pycrodomex'.

It looks like Pycryptodome's setup.py by default assumes a 'build' folder under the distribution root directory, and it looks like there isn't one when all this is being triggered by 'snapcraft'.

I'm not too familiar with either setup.py scripts or snapcraft, so I guess there is a possibility that this could be a snapcraft defect.

(NOTE: tizonia's snapcraft.yaml location is https://github.com/tizonia/tizonia-openmax-il/blob/master/tools/snapcraft.yaml)

 Running setup.py install for rsa ... done
  Running setup.py install for oauth2client ... done
  Running setup.py install for funcsigs ... done
  Running setup.py install for pbr ... done
  Running setup.py install for mock ... done
  Running setup.py install for appdirs ... done
  Running setup.py install for pycryptodomex ... error
    Complete output from command /home/joni/work/snap/parts/pypideps/install/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EmijGR/pycryptodomex/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" build_ext -I/home/joni/work/snap/parts/pypideps/install/usr/include/python2.7 install --record /tmp/pip-hvWWzT-record/install-record.txt --single-version-externally-managed --compile --home=/tmp/tmpbv29_M:
    running build_ext
    error: [Errno 2] No such file or directory: 'build/test1.c'

    ----------------------------------------
Command "/home/joni/work/snap/parts/pypideps/install/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-EmijGR/pycryptodomex/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" build_ext -I/home/joni/work/snap/parts/pypideps/install/usr/include/python2.7 install --record /tmp/pip-hvWWzT-record/install-record.txt --single-version-externally-managed --compile --home=/tmp/tmpbv29_M" failed with error code 1 in /tmp/pip-build-EmijGR/pycryptodomex/
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 31, in <module>
    snapcraft.main.main()
  File "/usr/lib/python3/dist-packages/snapcraft/main.py", line 203, in main
    return run(args, project_options)
  File "/usr/lib/python3/dist-packages/snapcraft/main.py", line 259, in run
    lifecycle.snap(project_options, args['<directory>'], args['--output'])
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 256, in snap
    snap = execute('prime', project_options)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 98, in execute
    _Executor(config, project_options).run(step, part_names)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 127, in run
    self._run_step(step, part, part_names, dirty, recursed)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/lifecycle.py", line 165, in _run_step
    getattr(part, step)()
  File "/usr/lib/python3/dist-packages/snapcraft/internal/pluginhandler.py", line 276, in pull
    self.code.pull()
  File "/usr/lib/python3/dist-packages/snapcraft/plugins/python2.py", line 106, in pull
    self._pip()
  File "/usr/lib/python3/dist-packages/snapcraft/plugins/python2.py", line 147, in _pip
    self.options.python_packages)
  File "/usr/lib/python3/dist-packages/snapcraft/_baseplugin.py", line 221, in run
    return common.run(cmd, cwd=cwd, **kwargs)
  File "/usr/lib/python3/dist-packages/snapcraft/internal/common.py", line 61, in run
    subprocess.check_call(['/bin/sh', f.name] + cmd, **kwargs)
  File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/bin/sh', '/tmp/tmpfqfr7sp2', 'python2', '/home/joni/work/snap/parts/pypideps/install/usr/bin/pip2', 'install', '--global-option=build_ext', '--global-option=-I/home/joni/work/snap/parts/pypideps/install/usr/include/python2.7', '--target', '/home/joni/work/snap/parts/pypideps/install/usr/lib/python2.7/site-packages', '--upgrade', 'soundcloud', 'gmusicapi']' returned non-zero exit status 1
Contributor

battyc commented Jul 6, 2016

It looks like a permissions issue to me. The setup script is trying to create a "build" directory but doesn't have permission to do so. Running the setup with elevated privileges should remedy the issue.

I've tried running snapcraft with sudo, with the same effect.

There is the possibility that this is a snapcraft defect. I also raised a ticket in launchpad:
https://bugs.launchpad.net/snapcraft/+bug/1598396

Contributor

battyc commented Jul 8, 2016

This may be a shot in the dark but what version comes up when you type "python --version"? Looking over the setup script it decides which version to install by checking the systems default. If you're defaulted to python3 then you could try aliasing the desired version to "python" and then running the snapcraft command again.

I know this solved a similar issue I had when trying to install it for python3 at first because my system was defaulted to 2.7.

snapcraft supports both python2 and 3.
In this case, snapcraft's python2 plugin is being used in my snapcraft.yaml (see https://github.com/tizonia/tizonia-openmax-il/blob/master/tools/snapcraft.yaml).

And I believe this is what the log shows

------------------------------------
Command "/home/joni/work/snap/parts/pypideps/install/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-raxuNt/pycryptodomex/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" build_ext -I/home/joni/work/snap/parts/pypideps/install/usr/include/python2.7 install --record /tmp/pip-DDbfVF-record/install-record.txt --single-version-externally-managed --compile --home=/tmp/tmpuy64o1" failed with error code 1 in /tmp/pip-build-raxuNt/pycryptodomex/
Command '['/bin/sh', '/tmp/tmpgp1jn1c0', 'python2',
'/home/joni/work/snap/parts/pypideps/install/usr/bin/pip2', 'install',
'--global-option=build_ext', '--global-option=-I/home/joni/work/snap/p
arts/pypideps/install/usr/include/python2.7', '--target',
'/home/joni/work/snap/parts/pypideps/install/usr/lib/python2.7/site-
packages', '--upgrade', 'soundcloud', 'gmusicapi']' returned non-zero
exit status 1

popey commented Sep 14, 2016

I also hit this. This appears to be fixed in Snapcraft 2.17, which is in Yakkety and lands in Xenial "soon". So you can probably close this issue I guess.

Edit: Spoke too soon. It actually didn't fix it.

popey commented Sep 14, 2016

It actually seems like it's just missing creating the build directory as part of the setup. A co-worker provided this output..

http://paste.ubuntu.com/23178423/

root@daydream:/pycryptodome# python2 setup.py -v build_ext
running build_ext
error: [Errno 2] No such file or directory: 'build/test1.c'
root@daydream:/pycryptodome# mkdir build
root@daydream:/pycryptodome# python2 setup.py -v build_ext
running build_ext
Compiling support for Intel AES instructions
building 'Crypto.Hash._MD2' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
etc

@Legrandin Legrandin added the bug label Oct 16, 2016

@Legrandin Legrandin closed this in #47 Jan 15, 2017

Legrandin added a commit that referenced this issue Jan 15, 2017

Merge pull request #47 from saboya/bug-22
Creates build dir before test file. Fixes #22

Excellent!. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment