uilianries / conan-ldap-authentication

A LDAP authentication plugin for Conan.io
MIT License
6 stars 1 forks source link

Plugin installation failing because not already installed #20

Closed felixtech-msp closed 2 years ago

felixtech-msp commented 2 years ago

Python Version: 3.10 Installed packages: libsasl2-dev libldap2-dev libssl-dev Installed Python packages: conan python-ldap

When I install this plugin to an already existing Conan server the installation fails with this message:

Collecting conan_ldap_authentication
  Downloading conan_ldap_authentication-0.3.0.tar.gz (7.2 kB)
  Preparing metadata (setup.py) ... done
Collecting python-ldap>=3.2.0
  Downloading python-ldap-3.4.0.tar.gz (376 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 376.2/376.2 KB 17.6 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting configparser>=4.0.2
  Downloading configparser-5.2.0-py3-none-any.whl (19 kB)
Requirement already satisfied: conan>=1.19.0 in /usr/local/lib/python3.10/site-packages (from conan_ldap_authentication) (1.47.0)
Requirement already satisfied: python-dateutil<3,>=2.7.0 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (2.8.2)
Requirement already satisfied: Jinja2<4.0.0,>=3.0 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (3.1.1)
Requirement already satisfied: requests<3.0.0,>=2.25 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (2.27.1)
Requirement already satisfied: node-semver==0.6.1 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (0.6.1)
Requirement already satisfied: urllib3<1.27,>=1.26.6 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (1.26.9)
Requirement already satisfied: six<=1.16.0,>=1.10.0 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (1.16.0)
Requirement already satisfied: patch-ng<1.18,>=1.17.4 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (1.17.4)
Requirement already satisfied: distro<=1.6.0,>=1.0.2 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (1.6.0)
Requirement already satisfied: bottle<0.13,>=0.12.8 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (0.12.19)
Requirement already satisfied: tqdm<5,>=4.28.1 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (4.63.1)
Requirement already satisfied: pluginbase>=0.5 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (1.0.1)
Requirement already satisfied: PyYAML<6.0,>=3.11 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (5.4.1)
Requirement already satisfied: pygments<3.0,>=2.0 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (2.11.2)
Requirement already satisfied: fasteners>=0.14.1 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (0.17.3)
Requirement already satisfied: colorama<0.5.0,>=0.3.3 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (0.4.4)
Requirement already satisfied: PyJWT<2.0.0,>=1.4.0 in /usr/local/lib/python3.10/site-packages (from conan>=1.19.0->conan_ldap_authentication) (1.7.1)
Collecting pyasn1>=0.3.7
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.1/77.1 KB 7.2 MB/s eta 0:00:00
Collecting pyasn1-modules>=0.1.5
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 155.3/155.3 KB 9.8 MB/s eta 0:00:00
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/site-packages (from Jinja2<4.0.0,>=3.0->conan>=1.19.0->conan_ldap_authentication) (2.1.1)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/site-packages (from requests<3.0.0,>=2.25->conan>=1.19.0->conan_ldap_authentication) (3.3)
Requirement already satisfied: charset-normalizer~=2.0.0 in /usr/local/lib/python3.10/site-packages (from requests<3.0.0,>=2.25->conan>=1.19.0->conan_ldap_authentication) (2.0.12)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/site-packages (from requests<3.0.0,>=2.25->conan>=1.19.0->conan_ldap_authentication) (2021.10.8)
Building wheels for collected packages: conan_ldap_authentication, python-ldap
  Building wheel for conan_ldap_authentication (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [51 lines of output]
      /usr/local/lib/python3.10/site-packages/setuptools/dist.py:717: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib
      creating build/lib/conan
      copying conan/__init__.py -> build/lib/conan
      copying conan/ldap_authentication.py -> build/lib/conan
      creating build/lib/conan/test
      copying conan/test/test_authentication.py -> build/lib/conan/test
      copying conan/test/__init__.py -> build/lib/conan/test
      copying conan/test/test_conan_authentication.py -> build/lib/conan/test
      copying conan/test/configuration_file.py -> build/lib/conan/test
      copying conan/requirements_test.txt -> build/lib/conan
      copying conan/requirements.txt -> build/lib/conan
      installing to build/bdist.linux-x86_64/wheel
      running install
      running install_lib
      creating build/bdist.linux-x86_64
      creating build/bdist.linux-x86_64/wheel
      creating build/bdist.linux-x86_64/wheel/conan
      creating build/bdist.linux-x86_64/wheel/conan/test
      copying build/lib/conan/test/test_authentication.py -> build/bdist.linux-x86_64/wheel/conan/test
      copying build/lib/conan/test/__init__.py -> build/bdist.linux-x86_64/wheel/conan/test
      copying build/lib/conan/test/test_conan_authentication.py -> build/bdist.linux-x86_64/wheel/conan/test
      copying build/lib/conan/test/configuration_file.py -> build/bdist.linux-x86_64/wheel/conan/test
      copying build/lib/conan/requirements_test.txt -> build/bdist.linux-x86_64/wheel/conan
      copying build/lib/conan/__init__.py -> build/bdist.linux-x86_64/wheel/conan
      copying build/lib/conan/ldap_authentication.py -> build/bdist.linux-x86_64/wheel/conan
      copying build/lib/conan/requirements.txt -> build/bdist.linux-x86_64/wheel/conan
      running install_data
      creating build/bdist.linux-x86_64/wheel/conan_ldap_authentication-0.3.0.data
      creating build/bdist.linux-x86_64/wheel/conan_ldap_authentication-0.3.0.data/data
      creating build/bdist.linux-x86_64/wheel/root
      creating build/bdist.linux-x86_64/wheel/root/.conan_server
      creating build/bdist.linux-x86_64/wheel/root/.conan_server/plugins
      creating build/bdist.linux-x86_64/wheel/root/.conan_server/plugins/authenticator
      copying conan/ldap_authentication.py -> build/bdist.linux-x86_64/wheel/root/.conan_server/plugins/authenticator
      running install_egg_info
      running egg_info
      writing conan_ldap_authentication.egg-info/PKG-INFO
      writing dependency_links to conan_ldap_authentication.egg-info/dependency_links.txt
      writing requirements to conan_ldap_authentication.egg-info/requires.txt
      writing top-level names to conan_ldap_authentication.egg-info/top_level.txt
      reading manifest file 'conan_ldap_authentication.egg-info/SOURCES.txt'
      writing manifest file 'conan_ldap_authentication.egg-info/SOURCES.txt'
      Copying conan_ldap_authentication.egg-info to build/bdist.linux-x86_64/wheel/conan_ldap_authentication-0.3.0-py3.10.egg-info
      running install_scripts
      error: [Errno 2] No such file or directory: '/root/.conan_server/plugins/authenticator/ldap_authentication.py'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for conan_ldap_authentication
  Running setup.py clean for conan_ldap_authentication
  Building wheel for python-ldap (pyproject.toml) ... done
  Created wheel for python-ldap: filename=python_ldap-3.4.0-cp310-cp310-linux_x86_64.whl size=316500 sha256=353a24833bf5ee1eef0971f7e2498c2512c8f5ac5e56cc01f656c91d4e3b01b4
  Stored in directory: /root/.cache/pip/wheels/a6/f9/78/3545434582aa1df2498d7eae4727f25dc358b18eea5a760ddc
Successfully built python-ldap
Failed to build conan_ldap_authentication
Installing collected packages: pyasn1, pyasn1-modules, configparser, python-ldap, conan_ldap_authentication
  Running setup.py install for conan_ldap_authentication ... done
  DEPRECATION: conan_ldap_authentication was installed using the legacy 'setup.py install' method, because a wheel could not be built for it. A possible replacement is to fix the wheel build issue reported above. Discussion can be found at https://github.com/pypa/pip/issues/8368
Successfully installed conan_ldap_authentication-0.3.0 configparser-5.2.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 python-ldap-3.4.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv

This makes no sense because it says the plugin file is not there but why should it be there when I just want to install the plugin??

uilianries commented 2 years ago

Hello @felixtech-msp I see you are installing on root folder. Are you running it on Docker? Which image? How did you install python? I would like to have more details to reproduce your error.

felixtech-msp commented 2 years ago

Hello @uilianries! I am using Docker and this is my Dockerfile:

FROM python:3.10
RUN apt-get update && apt-get install -y libsasl2-dev libldap2-dev libssl-dev && apt-get clean
RUN pip install conan
RUN pip install python-ldap
RUN pip install conan_ldap_authentication
CMD ["conan_server"]

The error occurs during build of this Dockerfile. The OS of the Docker host is Ubuntu 20.04.3 LTS; Docker version 20.10.12, build e91ed57.

When I just don't install the plugin and instead copying the .py file into the right location the plugin works.

uilianries commented 2 years ago

It works for me, but I'm using the official Conan docker images instead. I suggest you doing the same, do you don't need to maintain a new one:

FROM conanio/conan_server

RUN apk add gcc openldap-dev musl-dev

RUN pip install conan_ldap_authentication

The thing is, conan_ldap_authentication uses python-ldap pip package, which is a wrapper for openldap C libraries, however, it's not installed by default.

You don't need to add CMD statement here, because the official image already does it. It's code is listed here: https://github.com/conan-io/conan-docker-tools/blob/master/legacy/conan_server/Dockerfile

felixtech-msp commented 2 years ago

With exactly your Dockerfile exactly the same issue happens again.

uilianries commented 2 years ago

@felixtech-msp please, update you copy, I provided a small hotfix. As it runs as root, it seems like need to force that file copy.

I also added a Docker recipe in the repository, which you can use for your projects.

Closing this issue now. Please, re-open in case it does not work.

felixtech-msp commented 2 years ago

The new package has a missing file:

Collecting conan_ldap_authentication
  Downloading https://files.pythonhosted.org/packages/74/cf/4af6ac2d036d65ebfe4481198089414473f4b01f4fa2527b52069a3563f1/conan_ldap_authentication-0.4.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-w65df3tn/conan-ldap-authentication/setup.py", line 131, in <module>
        install_requires=Requirements.get(),
      File "/tmp/pip-install-w65df3tn/conan-ldap-authentication/setup.py", line 34, in get
        with open(Requirements.__requirements_path) as req_file:
      File "/usr/local/lib/python3.7/codecs.py", line 898, in open
        file = builtins.open(filename, mode, buffering)
    FileNotFoundError: [Errno 2] No such file or directory: 'conan_ldap/requirements.txt'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-w65df3tn/conan-ldap-authentication/
You are using pip version 19.0.1, however version 22.0.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip install conan_ldap_authentication' returned a non-zero code: 1