Skip to content

First run of setup.py fails when setting up M2Crypto #152

Closed

Description

@JensErat

While constructing a Docker file, I got into trouble while running ./venv/bin/python setup.py install, which fails when running the first time (but succeeds on the second run).

Stacktrace of the error:

Searching for M2Crypto
Reading https://pypi.python.org/simple/M2Crypto/
Best match: M2Crypto 0.22.3
Downloading https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.22.3.tar.gz#md5=573f21aaac7d5c9549798e72ffcefedd
Processing M2Crypto-0.22.3.tar.gz
Writing /tmp/easy_install-KBq_4X/M2Crypto-0.22.3/setup.cfg
Running M2Crypto-0.22.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-KBq_4X/M2Crypto-0.22.3/egg-dist-tmp-iRNoDy
Traceback (most recent call last):
  File "setup.py", line 57, in <module>
    include_package_data=True,
  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/install.py", line 74, in run
    self.do_egg_install()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/install.py", line 97, in do_egg_install
    cmd.run()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 358, in run
    self.easy_install(spec, not self.no_deps)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 574, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 625, in install_item
    self.process_distribution(spec, dist, deps)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 671, in process_distribution
    [requirement], self.local_index, self.easy_install
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 580, in resolve
    dist = best[req.key] = env.best_match(req, ws, installer)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 818, in best_match
    return self.obtain(req, installer) # try and download/install
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/pkg_resources.py", line 830, in obtain
    return installer(requirement)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 593, in easy_install
    return self.install_item(spec, dist.location, tmpdir, deps)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 623, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 809, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1015, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 1000, in run_setup
    run_setup(setup_script, args)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 50, in run_setup
    lambda: execfile(
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 100, in run
    return func()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/sandbox.py", line 52, in <lambda>
    {'__file__':setup_script, '__name__':'__main__'}
  File "setup.py", line 148, in <module>

  File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/bdist_egg.py", line 177, in run
    self.run_command("egg_info")
  File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 163, in run
    self.find_sources()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 186, in find_sources
    mm.run()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 246, in run
    self.add_defaults()
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 282, in add_defaults
    sdist.add_defaults(self)
  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/sdist.py", line 179, in add_defaults
    build_ext = self.get_finalized_command('build_ext')
  File "/usr/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command
    cmd_obj.ensure_finalized()
  File "/usr/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
    self.finalize_options()
  File "setup.py", line 69, in finalize_options

  File "/opt/lets-encrypt-preview/venv/local/lib/python2.7/site-packages/setuptools/command/build_ext.py", line 108, in finalize_options
    _build_ext.finalize_options(self)
  File "/usr/lib/python2.7/distutils/command/build_ext.py", line 182, in finalize_options
    if os.name == 'nt':
AttributeError: 'NoneType' object has no attribute 'name'

Dockerfile used so far (will put it on Github and post on mailing list when finished), as workaround I'm simply running the command twice (when it fails, which is currently always):

FROM ubuntu:trusty
MAINTAINER Jens Erat <[email protected]>

EXPOSE 80 443

ENV DEBIAN_FRONTEND noninteractive
RUN \
  apt-get update && \
  apt-get install --no-install-recommends -y apache2 && \
  apt-get install --no-install-recommends -y openssl ca-certificates git && \
  apt-get install --no-install-recommends -y python python-setuptools python-virtualenv python-dev gcc swig dialog libaugeas0 libssl-dev && \
  apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Quick and dirty fix for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=696327
RUN ln -s /usr/include/x86_64-linux-gnu/openssl/opensslconf.h /usr/include/openssl/

RUN cd /opt && git clone https://github.com/letsencrypt/lets-encrypt-preview.git
WORKDIR /opt/lets-encrypt-preview
# For some reason, first installation attempt fails
RUN \
  virtualenv --no-site-packages -p python2 venv && \
  ./venv/bin/python setup.py install || \
  ./venv/bin/python setup.py install

The link used is a workaround for a Debian/Ubuntu issue, I don't think letsencrypt is in charge here.

Activity

  1. JensErat commented on Jan 1, 2015

    @JensErat
    Author

    The full Dockerfile is also available on https://github.com/JensErat/docker-lets-encrypt-preview - might be pretty convenient for debugging the issue. I have no idea what's going wrong here.

  2. ThomasWaldmann commented on Jan 2, 2015

    @ThomasWaldmann
    Contributor

    i just tried a normal installation following the readme (no docker involved) and can confirm that m2crypto fails with os == None on first try. Second try somehow works...

  3. JensErat commented on Jan 22, 2015

    @JensErat
    Author

    I can confirm that USE_SETUPTOOLS=1 ./venv/bin/python setup.py install does not resolve the issue.

  4. kuba commented on Jan 24, 2015

    @kuba
    Contributor

    I was trying to narrow the problem down and have arrived at the following:

    1. rm -rf venv; virtualenv --no-site-packages venv; ./venv/bin/python setup.py develop works fine
    2. install fails whenever install_requires contains at least ['zope.interface', 'pycrypto', 'M2Crypto'] (install proceeds by installing them in that order), i.e. removing either zope.interface or pycrypto from install_requires "solves" the problem
  5. ThomasWaldmann commented on Jan 24, 2015

    @ThomasWaldmann
    Contributor

    just a vague idea: did you try reordering install_requires so M2Crypto comes first?

  6. kuba commented on Jan 24, 2015

    @kuba
    Contributor

    I believe that the order of items in install_requires does not matter (it's abstractly representing a set of dependencies) and in fact I have tested with lexicographically ordered dependencies: install_requires=['M2Crypto', 'pycrypto', 'zope.interface']

  7. added a commit that references this issue on Jan 24, 2015
  8. kuba commented on Jan 24, 2015

    @kuba
    Contributor

    Pure magic. It seems like the order does matter, but M2Crypto has to go last, to be installed first... Could anyone please test kuba@6a4164a?

  9. kuba commented on Jan 24, 2015

    @kuba
    Contributor

    #188 ready to pull

  10. added a commit that references this issue on Jan 25, 2015
  11. jdkasten commented on Jan 25, 2015

    @jdkasten
    Contributor

    @kuba solved this with #188 and fixed the problem. Thanks!

  12. JensErat commented on Jan 25, 2015

    @JensErat
    Author

    Also works for me now, thanks.

  13. added a commit that references this issue on Jul 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions