ikamensh / flynt

A tool to automatically convert old string literal formatting to f-strings
MIT License
689 stars 33 forks source link

need help for installing dev package and running tests #165

Closed PiRK closed 1 year ago

PiRK commented 1 year ago

I'm trying to write tests for #164, but I 'm not able to install the package.

It looks like a problem with some dependencies, maybe conflicting. But I don't understand the error.

$ pip install -e .[dev]
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///home/pierre/dev/flynt
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build editable ... done
  Preparing editable metadata (pyproject.toml) ... done
Requirement already satisfied: astor in /home/pierre/.local/lib/python3.10/site-packages (from flynt==0.77) (0.8.1)
Requirement already satisfied: tomli>=1.1.0 in /home/pierre/.local/lib/python3.10/site-packages (from flynt==0.77) (2.0.1)
Collecting build
  Using cached build-0.10.0-py3-none-any.whl (17 kB)
Collecting twine
  Using cached twine-4.0.2-py3-none-any.whl (36 kB)
Collecting pytest-cov
  Using cached pytest_cov-4.0.0-py3-none-any.whl (21 kB)
Requirement already satisfied: pytest in /home/pierre/.local/lib/python3.10/site-packages (from flynt==0.77) (7.2.0)
Requirement already satisfied: pre-commit in /home/pierre/.local/lib/python3.10/site-packages (from flynt==0.77) (2.18.1)
Requirement already satisfied: packaging>=19.0 in /home/pierre/.local/lib/python3.10/site-packages (from build->flynt==0.77) (21.3)
Collecting pyproject_hooks
  Using cached pyproject_hooks-1.0.0-py3-none-any.whl (9.3 kB)
Requirement already satisfied: toml in /home/pierre/.local/lib/python3.10/site-packages (from pre-commit->flynt==0.77) (0.10.2)
Requirement already satisfied: cfgv>=2.0.0 in /home/pierre/.local/lib/python3.10/site-packages (from pre-commit->flynt==0.77) (3.3.1)
Requirement already satisfied: identify>=1.0.0 in /home/pierre/.local/lib/python3.10/site-packages (from pre-commit->flynt==0.77) (2.5.0)
Requirement already satisfied: nodeenv>=0.11.1 in /home/pierre/.local/lib/python3.10/site-packages (from pre-commit->flynt==0.77) (1.6.0)
Requirement already satisfied: virtualenv>=20.0.8 in /home/pierre/.local/lib/python3.10/site-packages (from pre-commit->flynt==0.77) (20.14.1)
Requirement already satisfied: pyyaml>=5.1 in /usr/lib/python3/dist-packages (from pre-commit->flynt==0.77) (5.4.1)
Requirement already satisfied: pluggy<2.0,>=0.12 in /home/pierre/.local/lib/python3.10/site-packages (from pytest->flynt==0.77) (1.0.0)
Requirement already satisfied: attrs>=19.2.0 in /home/pierre/.local/lib/python3.10/site-packages (from pytest->flynt==0.77) (21.4.0)
Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/pierre/.local/lib/python3.10/site-packages (from pytest->flynt==0.77) (1.0.4)
Requirement already satisfied: iniconfig in /home/pierre/.local/lib/python3.10/site-packages (from pytest->flynt==0.77) (1.1.1)
Requirement already satisfied: coverage[toml]>=5.2.1 in /home/pierre/.local/lib/python3.10/site-packages (from pytest-cov->flynt==0.77) (6.5.0)
Collecting rich>=12.0.0
  Using cached rich-13.3.1-py3-none-any.whl (239 kB)
Requirement already satisfied: importlib-metadata>=3.6 in /usr/lib/python3/dist-packages (from twine->flynt==0.77) (4.6.4)
Requirement already satisfied: requests>=2.20 in /usr/lib/python3/dist-packages (from twine->flynt==0.77) (2.25.1)
Collecting readme-renderer>=35.0
  Using cached readme_renderer-37.3-py3-none-any.whl (14 kB)
Collecting rfc3986>=1.4.0
  Using cached rfc3986-2.0.0-py2.py3-none-any.whl (31 kB)
Requirement already satisfied: urllib3>=1.26.0 in /usr/lib/python3/dist-packages (from twine->flynt==0.77) (1.26.5)
Requirement already satisfied: keyring>=15.1 in /usr/lib/python3/dist-packages (from twine->flynt==0.77) (23.5.0)
Collecting requests-toolbelt!=0.9.0,>=0.8.0
  Using cached requests_toolbelt-0.10.1-py2.py3-none-any.whl (54 kB)
Collecting pkginfo>=1.8.1
  Using cached pkginfo-1.9.6-py3-none-any.whl (30 kB)
Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in /usr/lib/python3/dist-packages (from packaging>=19.0->build->flynt==0.77) (2.4.7)
Collecting docutils>=0.13.1
  Using cached docutils-0.19-py3-none-any.whl (570 kB)
Requirement already satisfied: bleach>=2.1.0 in /home/pierre/.local/lib/python3.10/site-packages (from readme-renderer>=35.0->twine->flynt==0.77) (5.0.0)
Requirement already satisfied: Pygments>=2.5.1 in /usr/lib/python3/dist-packages (from readme-renderer>=35.0->twine->flynt==0.77) (2.11.2)
Collecting markdown-it-py<3.0.0,>=2.1.0
  Using cached markdown_it_py-2.2.0-py3-none-any.whl (84 kB)
Collecting Pygments>=2.5.1
  Using cached Pygments-2.14.0-py3-none-any.whl (1.1 MB)
Requirement already satisfied: platformdirs<3,>=2 in /home/pierre/.local/lib/python3.10/site-packages (from virtualenv>=20.0.8->pre-commit->flynt==0.77) (2.5.2)
Requirement already satisfied: filelock<4,>=3.2 in /home/pierre/.local/lib/python3.10/site-packages (from virtualenv>=20.0.8->pre-commit->flynt==0.77) (3.6.0)
Requirement already satisfied: distlib<1,>=0.3.1 in /home/pierre/.local/lib/python3.10/site-packages (from virtualenv>=20.0.8->pre-commit->flynt==0.77) (0.3.4)
Requirement already satisfied: six<2,>=1.9.0 in /usr/lib/python3/dist-packages (from virtualenv>=20.0.8->pre-commit->flynt==0.77) (1.16.0)
Requirement already satisfied: webencodings in /usr/lib/python3/dist-packages (from bleach>=2.1.0->readme-renderer>=35.0->twine->flynt==0.77) (0.5.1)
Collecting mdurl~=0.1
  Using cached mdurl-0.1.2-py3-none-any.whl (10.0 kB)
Building wheels for collected packages: flynt
  Building editable for flynt (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building editable for flynt (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [24 lines of output]
      Traceback (most recent call last):
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/usr/lib/python3/dist-packages/pip/_vendor/pep517/in_process/_in_process.py", line 283, in build_editable
          return hook(wheel_directory, config_settings, metadata_directory)
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/build.py", line 78, in build_editable
          return os.path.basename(next(builder.build(wheel_directory, ['editable'])))
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/builders/plugin/interface.py", line 158, in build
          artifact = version_api[version](directory, **build_data)
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/builders/wheel.py", line 388, in build_editable
          return self.build_editable_detection(directory, **build_data)
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/builders/wheel.py", line 399, in build_editable_detection
          for included_file in self.recurse_project_files():
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/builders/plugin/interface.py", line 196, in recurse_project_files
          if self.config.include_path(relative_file_path, is_package=is_package):
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/builders/config.py", line 94, in include_path
          and not self.path_is_excluded(relative_path)
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/builders/config.py", line 106, in path_is_excluded
          if self.exclude_spec is None:
        File "/tmp/pip-build-env-mmjl_4in/overlay/local/lib/python3.10/dist-packages/hatchling/builders/config.py", line 207, in exclude_spec
          self.__exclude_spec = pathspec.GitIgnoreSpec.from_lines(all_exclude_patterns)
      AttributeError: module 'pathspec' has no attribute 'GitIgnoreSpec'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building editable for flynt
Failed to build flynt
ERROR: Could not build wheels for flynt, which is required to install pyproject.toml-based projects

Note that I ran pip install pathspec --upgrade to be sure to have the latest version. And it seems to have a GitIgnoreSpec attribute.

$ python
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pathspec
>>> pathspec.GitIgnoreSpec()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: PathSpec.__init__() missing 1 required positional argument: 'patterns'
>>> pathspec.GitIgnoreSpec
<class 'pathspec.gitignore.GitIgnoreSpec'>
>>> pathspec.__version__
'0.11.0'
PiRK commented 1 year ago

I fixed the error. I had to uninstall the system's pathspec (sudo apt remove pathspec, version 0.9.0) so that the newly installed version (0.11.0) would be used instead.

Sorry for the unnecessary issue, I'm closing it.

DLu commented 3 weeks ago

@PiRK I appreciate you creating this "unnecessary" issue because it helped me solve a similar issue with my own project. I instead did sudo apt remove python3-pathspec. Cheers.