Skip to content

Failure when installing Python library #37

@kacper-ka

Description

@kacper-ka

Summary

Installation of Python library in clean environment fails.

Steps to reproduce

  1. Clone repository (path: /home/user/projects/erpc)
  2. Create clean virtual environment (python -m venv /home/user/python-env)
  3. Activate virtual environment (source /home/user/python-env/bin/activate)
  4. Install Python library from path (python -m pip install /home/user/projects/erpc/erpc_python)

Current buggy behaviour

Step 3. fails with error code 1 (Python ModuleNotFoundError exception).

Expected correct behaviour

Step 3. completes successfully, module gets installed in virtual environment.

Relevant logs

Step 3. output:

Processing /home/kacper/projects/erpc/erpc_python
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-ym2kz4cl/setup.py", line 36, in <module>
        from erpc import erpc_version
      File "/tmp/pip-req-build-ym2kz4cl/erpc/__init__.py", line 39, in <module>
        from . import arbitrator
      File "/tmp/pip-req-build-ym2kz4cl/erpc/arbitrator.py", line 37, in <module>
        from .transport import Transport
      File "/tmp/pip-req-build-ym2kz4cl/erpc/transport.py", line 36, in <module>
        import serial
    ModuleNotFoundError: No module named 'serial'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-ym2kz4cl/

Possible fixes

The issue is caused by line 36 in file setup.py:

from erpc import erpc_version

Importing any file from erpc package causes __init__.py script to execute, in consequence some other modules are pulled as well (as seen in the log above). To overcome the issue it is proposed to remove the offending line and read the version constant with a following snippet:

with open(path.join(here, 'erpc', 'erpc_version.py')) as f:
    exec(f.read())

Then in the setup invocation instead of referencing the constant via erpc_version.ERPC_VERSION (line 52) use ERPC_VERSION directly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions