nasa/fprime-gds

Local installation of `fprime-gds`

Closed this issue · 12 comments

F´ Version
Affected Component fprime-gds

Problem Description

setup.py's instructions for installing locally are:

# Developer and Dynamic Installation:
# ```
# pip install -e ./Gds
# ```

When running this from the top-level directory in this repository I get:

# pip install -e ./Gds
Obtaining file:///home/ptl/lib/fprime-gds-dtn/Gds
ERROR: file:///home/ptl/lib/fprime-gds-dtn/Gds does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

I tried running a pip install -e . instead and got:


Obtaining file:///home/ptl/lib/fprime-gds-dtn
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      /usr/local/lib/python3.9/dist-packages/setuptools/__init__.py:85: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`.
        dist.fetch_build_eggs(dist.setup_requires)
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/home/ptl/lib/fprime-gds-dtn/setup.py", line 39, in <module>
          setup(
        File "/usr/local/lib/python3.9/dist-packages/setuptools/__init__.py", line 108, in setup
          return distutils.core.setup(**attrs)
        File "/usr/local/lib/python3.9/dist-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "/usr/local/lib/python3.9/dist-packages/setuptools/dist.py", line 488, in __init__
          _Distribution.__init__(
        File "/usr/local/lib/python3.9/dist-packages/setuptools/_distutils/dist.py", line 283, in __init__
          self.finalize_options()
        File "/usr/local/lib/python3.9/dist-packages/setuptools/dist.py", line 912, in finalize_options
          ep(self)
        File "/usr/local/lib/python3.9/dist-packages/setuptools/dist.py", line 932, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/usr/local/lib/python3.9/dist-packages/setuptools_scm/integration.py", line 91, in version_keyword
          _assign_version(dist, config)
        File "/usr/local/lib/python3.9/dist-packages/setuptools_scm/integration.py", line 63, in _assign_version
          _version_missing(config)
        File "/usr/local/lib/python3.9/dist-packages/setuptools_scm/__init__.py", line 108, in _version_missing
          raise LookupError(
      LookupError: setuptools-scm was unable to detect version for /home/ptl/lib/fprime-gds-dtn.

      Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

      For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

A python3 setup.py install --user --prefix=/some/install/path results in the same error message as above.

Am I missing some sort of venv Python step here?

Expected Behaviour

I'd like to basically run something like python3 setup.py install --user --prefix=/some/install/path.

@pcrosemurgy I think the command you're looking for is, at the root of fprime-gds/ repo, pip install -e .
The ./Gds instruction is outdated, I'll fix that - thank you for pointing it out.

@thomas-bc Thanks for the quick response, unfortunately pip install -e . results in the the error pasted above:

I tried running a pip install -e . instead and got:
...

Ah my apologies, I read that too quickly. Hm that's interesting. Are you building develop? And which version of pip?

No worries! I'm on the devel branch. pip -V reports:

pip 23.0.1 from /usr/local/lib/python3.9/dist-packages/pip (python 3.9)

From the looks of the error message, it seems like there’s something wrong with your Python environment, specifically the setuptools et al.
We usually recommend installing things in a virtual environment, yes, although it’s not required. Have you tried following the steps from this guide? https://nasa.github.io/fprime/INSTALL.html
Specifically the pip install -U setuptools … part

I think I'm correctly using a Python venv:

root@122e3569c0e9:/home/ptl/lib/fprime-gds# python3 -m venv /home/ptl/class-venv
root@122e3569c0e9:/home/ptl/lib/fprime-gds# . /home/ptl/class-venv/bin/activate
(class-venv) root@122e3569c0e9:/home/ptl/lib/fprime-gds# pip install -U setuptools setuptools_scm wheel pip
Requirement already satisfied: setuptools in /home/ptl/class-venv/lib/python3.9/site-packages (44.1.1)
Collecting setuptools
  Downloading setuptools-67.6.0-py3-none-any.whl (1.1 MB)
     |████████████████████████████████| 1.1 MB 917 kB/s
Collecting setuptools_scm
  Using cached setuptools_scm-7.1.0-py3-none-any.whl (43 kB)
Collecting wheel
  Downloading wheel-0.40.0-py3-none-any.whl (64 kB)
     |████████████████████████████████| 64 kB 3.9 MB/s
Requirement already satisfied: pip in /home/ptl/class-venv/lib/python3.9/site-packages (20.3.4)
Collecting pip
  Using cached pip-23.0.1-py3-none-any.whl (2.1 MB)
Collecting typing-extensions
  Using cached typing_extensions-4.5.0-py3-none-any.whl (27 kB)
Collecting packaging>=20.0
  Using cached packaging-23.0-py3-none-any.whl (42 kB)
Collecting tomli>=1.0.0
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Installing collected packages: typing-extensions, tomli, setuptools, packaging, wheel, setuptools-scm, pip
  Attempting uninstall: setuptools
    Found existing installation: setuptools 44.1.1
    Uninstalling setuptools-44.1.1:
      Successfully uninstalled setuptools-44.1.1
  Attempting uninstall: pip
    Found existing installation: pip 20.3.4
    Uninstalling pip-20.3.4:
      Successfully uninstalled pip-20.3.4
Successfully installed packaging-23.0 pip-23.0.1 setuptools-67.6.0 setuptools-scm-7.1.0 tomli-2.0.1 typing-extensions-4.5.0 wheel-0.40.0
(class-venv) root@122e3569c0e9:/home/ptl/lib/fprime-gds# pip install -e .
Obtaining file:///home/ptl/lib/fprime-gds
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [30 lines of output]
      /home/ptl/class-venv/lib/python3.9/site-packages/setuptools/__init__.py:85: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`.
        dist.fetch_build_eggs(dist.setup_requires)
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/home/ptl/lib/fprime-gds/setup.py", line 39, in <module>
          setup(
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools/__init__.py", line 108, in setup
          return distutils.core.setup(**attrs)
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 147, in setup
          _setup_distribution = dist = klass(attrs)
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools/dist.py", line 488, in __init__
          _Distribution.__init__(
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 283, in __init__
          self.finalize_options()
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools/dist.py", line 912, in finalize_options
          ep(self)
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools/dist.py", line 932, in _finalize_setup_keywords
          ep.load()(self, ep.name, value)
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools_scm/integration.py", line 91, in version_keyword
          _assign_version(dist, config)
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools_scm/integration.py", line 63, in _assign_version
          _version_missing(config)
        File "/home/ptl/class-venv/lib/python3.9/site-packages/setuptools_scm/__init__.py", line 108, in _version_missing
          raise LookupError(
      LookupError: setuptools-scm was unable to detect version for /home/ptl/lib/fprime-gds.

      Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

      For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Is fprime-gds a proper git checkout or is it something else?

Ohhhhh I know what is going on. You must do a full clone of fprime-gds, not a single branch/commit "shallow" clone.

fprime-gds in this case should be a fully cloned git submodule. When adding the submodule I ran git submodule update --init --recursive and git submodule update --remote.

Ahh, so I'm running this in a Docker container and am volume-mapping the fprime-gds submodule into the container. When I cd to fprime-gds/ and try to run things like git remote -v I get a:

fatal: not a git repository: /home/ptl/lib/fprime-gds/../../.git/modules/lib/fprime-gds

When I repeat my steps but with an fprime-gds cloned within the container everything works. Is there a reason why pip install -e . would fail when an fprime-gds/.git/ directory is not present?

Ohh, in the error message in the issue description:

...
Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.
...

I'll do some searching, there's likely a way for this to work for a submodule.

With these 2 lines commented out it's possible to run pip install -e . within an fprime-gds repository that's checked out as a git submodule:

No obligation to support running pip packaging while checked out as a submodule but maybe it's possible to have some logic within setup.py that simply sets the version to something like 0.0.0-dev if SCM is not detected (i.e. if in a submodule or missing a .git/).

Looks like it's possible to define a fallback version within pyproject.toml (nektos/act#1389 (comment)). I believe this would require migrating from setup.py to a pyproject.toml though.