Search code examples
python-packagingpython-poetry

Using poetry on different machines


I am working on a Python project and recently started using poetry. I was originally working on the project using macOS 11.0, but as I near completion, I wanted to test it on a Linux workstation. I use Github for my repository, and so, I am able to clone the repo easily. However, that is where the simple part ends. I have used both pyenv and conda for the virtual environment on macOS, but when I clone the repo onto the workstation, I set up an environment and then try the following command:

poetry shell
poetry install

I receive the following error after poetry install:

  ParseVersionError

  Unable to parse "at20RC5+54.g5702a232fe.dirty".

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/semver/version.py:211 in parse
      207│         except TypeError:
      208│             match = None
      209│
      210│         if match is None:
    → 211│             raise ParseVersionError('Unable to parse "{}".'.format(text))
      212│
      213│         text = text.rstrip(".")
      214│
      215│         major = int(match.group(1))

I have tried poetry lock with the same result, and I have even deleted poetry.lock and attempted poetry lock with no success.

I intend to build and publish it when all is said and done, but because I eventually want to add features that my Mac does not have (e.g., CUDA), I want to code on the workstation as well.

Any help will be appreciated.

Update -- 03/27/21

pyproject.toml

[tool.poetry]
name = "qaa"
version = "0.1.0"
description = "Quasi-Anharmonic Analysis"
authors = ["Timothy H. Click <tclick@okstate.edu>"]
license = "BSD-3-Clause"
readme = "README.rst"
homepage = "https://github.com/tclick/qaa"
repository = "https://github.com/tclick/qaa"
documentation = "https://qaa.readthedocs.io"
classifiers = [
    "Programming Language :: Python :: 3.6",
    "Programming Language :: Python :: 3.7",
    "Programming Language :: Python :: 3.8",
    "Programming Language :: Python :: 3.9",
]

[tool.poetry.urls]
Changelog = "https://github.com/tclick/qaa/releases"

[tool.poetry.dependencies]
python = "^3.8"
click = "^7.0"
numpy = "^1.20.1"
scipy = "^1.6.1"
matplotlib = "^3.3.4"
seaborn = "^0.11.1"
scikit-learn = "^0.24.1"
pandas = "^1.2.3"
netCDF4 = "^1.5.6"
mdtraj = "^1.9.5"

[tool.poetry.dev-dependencies]
pytest = "^6.2.2"
pytest-cache = "^1.0"
pytest-click = "^1.0.2"
pytest-console-scripts = "^1.1.0"
pytest-cov = "^2.11.1"
pytest-flake8 = "^1.0.7"
pytest-mock = "^3.5.1"
pytest-pep8 = "^1.0.6"
pytest-randomly = "^3.5.0"
coverage = {extras = ["toml"], version = "^5.3"}
safety = "^1.9.0"
mypy = "^0.812"
typeguard = "^2.9.1"
xdoctest = {extras = ["colors"], version = "^0.15.0"}
sphinx = "^3.3.1"
sphinx-autobuild = "^2020.9.1"
pre-commit = "^2.8.2"
flake8 = "^3.8.4"
black = "^20.8b1"
flake8-bandit = "^2.1.2"
flake8-bugbear = "^21.3.2"
flake8-docstrings = "^1.5.0"
flake8-rst-docstrings = "^0.0.14"
pep8-naming = "^0.11.1"
darglint = "^1.5.5"
reorder-python-imports = "^2.3.6"
pre-commit-hooks = "^3.3.0"
sphinx-rtd-theme = "^0.5.0"
sphinx-click = "^2.5.0"
Pygments = "^2.7.2"
ipython = "^7.21.0"
isort = "^5.7.0"
towncrier = "^19.2.0"
nox = "^2020.12.31"
pytest-coverage = "^0.0"
nox-poetry = "^0.8.4"
numpydoc = "^1.1.0"
codecov = "^2.1.11"
flake8-black = "^0.2.1"
flake8-import-order = "^0.18.1"

[tool.poetry.scripts]
qaa = "qaa.__main__:main"

update -- 03/29/21

This is the error received when running poetry lock -vvv

Using virtualenv: /home/tclick/.cache/pypoetry/virtualenvs/qaa-VNW0yB_S-py3.8

  Stack trace:

  10  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/console_application.py:131 in run
       129│             parsed_args = resolved_command.args
       130│
     → 131│             status_code = command.handle(parsed_args, io)
       132│         except KeyboardInterrupt:
       133│             status_code = 1

   9  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:120 in handle
       118│     def handle(self, args, io):  # type: (Args, IO) -> int
       119│         try:
     → 120│             status_code = self._do_handle(args, io)
       121│         except KeyboardInterrupt:
       122│             if io.is_debug():

   8  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/command/command.py:163 in _do_handle
       161│         if self._dispatcher and self._dispatcher.has_listeners(PRE_HANDLE):
       162│             event = PreHandleEvent(args, io, self)
     → 163│             self._dispatcher.dispatch(PRE_HANDLE, event)
       164│
       165│             if event.is_handled():

   7  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:22 in dispatch
        20│
        21│         if listeners:
     →  22│             self._do_dispatch(listeners, event_name, event)
        23│
        24│         return event

   6  ~/.poetry/lib/poetry/_vendor/py3.8/clikit/api/event/event_dispatcher.py:89 in _do_dispatch
        87│                 break
        88│
     →  89│             listener(event, event_name, self)
        90│
        91│     def _sort_listeners(self, event_name):  # type: (str) -> None

   5  ~/.poetry/lib/poetry/console/config/application_config.py:141 in set_installer
       139│
       140│         poetry = command.poetry
     → 141│         installer = Installer(
       142│             event.io,
       143│             command.env,

   4  ~/.poetry/lib/poetry/installation/installer.py:65 in __init__
        63│         self._installer = self._get_installer()
        64│         if installed is None:
     →  65│             installed = self._get_installed()
        66│
        67│         self._installed_repository = installed

   3  ~/.poetry/lib/poetry/installation/installer.py:561 in _get_installed
       559│
       560│     def _get_installed(self):  # type: () -> InstalledRepository
     → 561│         return InstalledRepository.load(self._env)
       562│

   2  ~/.poetry/lib/poetry/repositories/installed_repository.py:118 in load
       116│                 path = Path(str(distribution._path))
       117│                 version = distribution.metadata["version"]
     → 118│                 package = Package(name, version, version)
       119│                 package.description = distribution.metadata.get("summary", "")
       120│

   1  ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/packages/package.py:61 in __init__
        59│
        60│         if not isinstance(version, Version):
     →  61│             self._version = Version.parse(version)
        62│             self._pretty_version = pretty_version or version
        63│         else:

  ParseVersionError

  Unable to parse "at20RC5+54.g5702a232fe.dirty".

  at ~/.poetry/lib/poetry/_vendor/py3.8/poetry/core/semver/version.py:206 in parse
      202│         except TypeError:
      203│             match = None
      204│
      205│         if match is None:
    → 206│             raise ParseVersionError('Unable to parse "{}".'.format(text))
      207│
      208│         text = text.rstrip(".")
      209│
      210│         major = int(match.group(1))

Solution

  • I think you should NOT run poetry shell first. It's used only when poetry project and its dependencies are installed.

    poetry install should work nice in the project directory with pyproject.toml

    Possible help:

    • ensure that poetry installed and path to poetry executable in PATH environment variable;
    • check that python 3.8+ is installed (from your dependencies). If you use pyenv check that path to this version is available for terminal.