python-poetry / poetry

Python packaging and dependency management made easy
https://python-poetry.org
MIT License
31.25k stars 2.26k forks source link

Poetry build, python is not in the subpath of my folder #7800

Open rmarquet21 opened 1 year ago

rmarquet21 commented 1 year ago

Issue

Hello, I'm trying to do a poetry build of my Python app. The problem is that I keep getting an error that says '/Users/robin/.pyenv/versions/3.10.9/bin/python3.10' is not in the subpath of '/Users/robin/Documents/rmarquet21/st_annotation' OR one path is relative, and the other is absolute. I have tried to find a solution to my issue, but I haven't found any. I also use pyenv and currently have a global version of Python 3.8, so I don't understand where version 3.10.9 is coming from.

pyproject.toml

[tool.poetry]
name = "st-text-annotator"
version = "0.1.6"
description = "Component for annotating text for NLP resolution"
classifiers = ["Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent"]
authors = ["Robin Marquet <robin.marquet@epitech.eu>"]
license = "MIT License"
readme = "README.md"
packages = [{include = "st_text_annotator", from = "src"}]

[tool.poetry.dependencies]
python = "^3.8,<3.9"
streamlit = "^1.21.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

output

(st-text-annotator-py3.8) āžœ  st_annotation git:(master) āœ— poetry build               
Building st-text-annotator (0.1.6)
  - Building sdist

'/Users/robin/.pyenv/versions/3.10.9/bin/python3.10' is not in the subpath of '/Users/robin/Documents/rmarquet21/st_annotation' OR one path is relative and the other is absolute.
dimbleby commented 1 year ago

you forgot to rerun with -vvv and provide the output

rmarquet21 commented 1 year ago

you forgot to rerun with -vvv and provide the output

poetry build -vvv
Trying to detect current active python executable as specified in the config.
Found: /Users/robin/.pyenv/versions/3.8.16/bin/python

  Stack trace:

  13  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:327 in run
       325ā”‚
       326ā”‚             try:
     ā†’ 327ā”‚                 exit_code = self._run(io)
       328ā”‚             except BrokenPipeError:
       329ā”‚                 # If we are piped to another process, it may close early and send a

  12  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py:190 in _run
       188ā”‚         self._load_plugins(io)
       189ā”‚
     ā†’ 190ā”‚         exit_code: int = super()._run(io)
       191ā”‚         return exit_code
       192ā”‚

  11  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:431 in _run
       429ā”‚             io.input.interactive(interactive)
       430ā”‚
     ā†’ 431ā”‚         exit_code = self._run_command(command, io)
       432ā”‚         self._running_command = None
       433ā”‚

  10  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:473 in _run_command
       471ā”‚
       472ā”‚         if error is not None:
     ā†’ 473ā”‚             raise error
       474ā”‚
       475ā”‚         return terminate_event.exit_code

   9  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:457 in _run_command
       455ā”‚
       456ā”‚             if command_event.command_should_run():
     ā†’ 457ā”‚                 exit_code = command.run(io)
       458ā”‚             else:
       459ā”‚                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

   8  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/commands/base_command.py:119 in run
       117ā”‚         io.input.validate()
       118ā”‚
     ā†’ 119ā”‚         status_code = self.execute(io)
       120ā”‚
       121ā”‚         if status_code is None:

   7  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/cleo/commands/command.py:62 in execute
        60ā”‚
        61ā”‚         try:
     ā†’  62ā”‚             return self.handle()
        63ā”‚         except KeyboardInterrupt:
        64ā”‚             return 1

   6  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/build.py:34 in handle
        32ā”‚
        33ā”‚             builder = Builder(self.poetry)
     ā†’  34ā”‚             builder.build(fmt, executable=env.python)
        35ā”‚
        36ā”‚         return 0

   5  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/core/masonry/builder.py:39 in build
        37ā”‚
        38ā”‚         for builder in builders:
     ā†’  39ā”‚             builder(self._poetry, executable=executable).build(target_dir)
        40ā”‚

   4  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/core/masonry/builders/sdist.py:80 in build
        78ā”‚             tar_dir = f"{name}-{self._meta.version}"
        79ā”‚
     ā†’  80ā”‚             files_to_add = self.find_files_to_add(exclude_build=False)
        81ā”‚
        82ā”‚             for file in sorted(files_to_add, key=lambda x: x.relative_to_source_root()):

   3  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/core/masonry/builders/sdist.py:323 in find_files_to_add
       321ā”‚
       322ā”‚     def find_files_to_add(self, exclude_build: bool = False) -> set[BuildIncludeFile]:
     ā†’ 323ā”‚         to_add = super().find_files_to_add(exclude_build)
       324ā”‚
       325ā”‚         # add any additional files, starting with all LICENSE files

   2  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/core/masonry/builders/builder.py:189 in find_files_to_add
       187ā”‚
       188ā”‚                             if not current_file.is_dir() and not self.is_excluded(
     ā†’ 189ā”‚                                 include_file.relative_to_source_root()
       190ā”‚                             ):
       191ā”‚                                 to_add.add(include_file)

   1  ~/Library/Application Support/pypoetry/venv/lib/python3.10/site-packages/poetry/core/masonry/builders/builder.py:399 in relative_to_source_root
       397ā”‚     def relative_to_source_root(self) -> Path:
       398ā”‚         if self.source_root is not None:
     ā†’ 399ā”‚             return self.path.relative_to(self.source_root)
       400ā”‚
       401ā”‚         return self.path

  ValueError

  '/Users/robin/.pyenv/versions/3.10.9/bin/python3.10' is not in the subpath of '/Users/robin/Documents/rmarquet21/st_annotation' OR one path is relative and the other is absolute.

  at ~/.pyenv/versions/3.10.11/lib/python3.10/pathlib.py:818 in relative_to
       814ā”‚         n = len(to_abs_parts)
       815ā”‚         cf = self._flavour.casefold_parts
       816ā”‚         if (root or drv) if n == 0 else cf(abs_parts[:n]) != cf(to_abs_parts):
       817ā”‚             formatted = self._format_parsed_parts(to_drv, to_root, to_parts)
    ā†’  818ā”‚             raise ValueError("{!r} is not in the subpath of {!r}"
       819ā”‚                     " OR one path is relative and the other is absolute."
       820ā”‚                              .format(str(self), str(formatted)))
       821ā”‚         return self._from_parsed_parts('', root if n == 1 else '',
       822ā”‚                                        abs_parts[n:])
dimbleby commented 1 year ago

I expect you'll want to investigate what's going on near find_files_to_add(), stick some print statements or similar in there.

Perhaps you've got a symlink or something that's behaving unexpectedly.

rmarquet21 commented 1 year ago

I find, I have a symlink, in my node_modules, you know how to remove them from build ?

.
ā”œā”€ā”€ CHANGELOG.md
ā”œā”€ā”€ LICENSE
ā”œā”€ā”€ MANIFEST.in
ā”œā”€ā”€ README.md
ā”œā”€ā”€ examples
ā”‚   ā””ā”€ā”€ example.py
ā”œā”€ā”€ poetry.lock
ā”œā”€ā”€ pyproject.toml
ā”œā”€ā”€ requirements.txt
ā”œā”€ā”€ setup.py
ā””ā”€ā”€ src
    ā””ā”€ā”€ st_text_annotator
        ā”œā”€ā”€ __init__.py
        ā””ā”€ā”€ frontend
            ā”œā”€ā”€ build
            ā”œā”€ā”€ node_modules
            ā”œā”€ā”€ package-lock.json
            ā”œā”€ā”€ package.json
            ā”œā”€ā”€ public
            ā”œā”€ā”€ src
            ā””ā”€ā”€ tsconfig.json

9 directories, 13 files

I try with exclude = ["./src/st_text_annotator/frontend/node_modules/**/*"] but this do nothing

martinda commented 7 months ago

I use a symbolic link for the build/ folder and point it to a different file system. This is done for performance reasons on our CI server (Jenkins). Poetry builds break because of this. But Gradle (Java) builds and other types of builds do not. I use poetry 1.7.1.

thomasalcock commented 1 month ago

Any updates on this? I've run into the same issue.

andresdelfino commented 1 month ago

In case it is of help for somebody else: I had this problem, and it was because there was a virtual environment created inside the project directory I was trying to install with "pip install .". After removing the virtual environment directory, it worked correctly.