Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root project not installed in editable mode #5265

Closed
3 tasks done
Badg opened this issue Mar 2, 2022 · 7 comments
Closed
3 tasks done

Root project not installed in editable mode #5265

Badg opened this issue Mar 2, 2022 · 7 comments
Labels
status/duplicate Duplicate issues

Comments

@Badg
Copy link

Badg commented Mar 2, 2022

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Encountered on:

  • OSX 12.2.1 @ poetry 1.1.12
  • debian slim 11.2 (docker) @ poetry 1.1.13

Gist of pyproject.toml and dockerfile here

Issue

I can't get my root project installed in editable mode. My understanding (from both docs and past usage) is that the root project should always be installed in editable mode, but both within a docker container and on the host, I'm unable to get it to do so. I've tried removing the build system from pyproject.toml on the off-chance that it might be related to #2956, but that didn't get me anywhere (I also noticed #1382, but I don't know how this would be related). I also tried manually specifying it as an editable install in dev dependencies using develop = True, but that errored out on an assertion, so I... well, I basically gave up pursuing that route because it's been a long day.

Any thoughts? (PS: poetry is 🎉 😄 )

@Badg Badg added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 2, 2022
@kaluluosi
Copy link

kaluluosi commented Mar 4, 2022

I think maybe i know why editable no working.

This module create .pth file to sites-packages to add local project directory to sys.path.
masonry/builders/editable.py

try:
            pth_file = self._env.site_packages.write_text(
                pth_file, content, encoding="utf-8"  # it use utf-8 for encoding
            )
            self._debug(
                f"  - Adding <c2>{pth_file.name}</c2> to <b>{pth_file.parent}</b> for"
                f" {self._poetry.file.parent}"
            )
            return [pth_file]

but it use utf-8 for encoding the .pth

In Lib\site.py which for process the .pth file to add user path to sys.path.

  def addpackage(sitedir, name, known_paths):
      """Process a .pth file within the site-packages directory:
         For each line in the file, either combine it with sitedir to a path
         and add that to known_paths, or execute it if it starts with 'import '.
      """
      
      if known_paths is None:
          known_paths = _init_pathinfo()
          reset = True
      else:
          reset = False
      fullname = os.path.join(sitedir, name)
      _trace(f"Processing .pth file: {fullname!r}")
      try:
          # locale encoding is not ideal especially on Windows. But we have used
          # it for a long time. setuptools uses the locale encoding too.
          f = io.TextIOWrapper(io.open_code(fullname), encoding="locale")
      except IOError:
          return

It use 'local' to decode .pth file.
so when our project path has local character and not asic2
it will get wrong path just like 'c:/锘挎槬鐪犱/锘'
and this path is not exists

@anthonymichaelclark
Copy link
Contributor

@Badg It looks to me like your pyproject.toml is missing a required key -- eg, see here for an example of how it works in the current master.

This is from a project of mine that installs the project under development in editable mode in 1.1.13:

[tool.poetry]
name = "my-package"
version = "0.1.0"
description = "This is my package"
authors = ["anthonymichaelclark"]
include = ["my-package"]

Does adding that include key to your pyproject.toml solve your issue?

@abn
Copy link
Member

abn commented Apr 3, 2022

@anthonymichaelclark I think you are looking for package keyword and not include. The latter is for additional files like data files, build files, tests etc.

@Badg it might be related to package specification as the above comment alluded to. Can you share the directory structure of the project?

You could also check what paths are being written into the my_package.pth file in the site-packages directory in your virtual environment.

@Badg
Copy link
Author

Badg commented Apr 7, 2022

I'm super busy at the moment, so I can't right now, but I'll try to get around to the above suggestions in the next few weeks!

@Badg
Copy link
Author

Badg commented May 7, 2022

Update on this: I still haven't had a chance to try this again at work. However, I just encountered the same issue on my personal computer -- a win10 box -- running on the host OS (ie no docker) with python 3.9 (poetry latest version, running on py3.10). There, my pyproject.toml looks like this (lol on the project name)

[tool.poetry]
name = "finfuck"
version = "0.0.1"
description = "Financial fucking bullshit"
authors = ["Your Name <you@example.com>"]

[tool.poetry.dependencies]
# Currently pdftopng (camelot dep) has no wheels for 3.10
python = "~3.9"
forex-python = "^1.8"
alpha-vantage = "^2.3.1"
camelot-py = {extras = ["base"], version = "^0.10.1"}

[tool.poetry.dev-dependencies]
pytest = "^7.1.1"
ipython = "^8.2.0"

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

@anthonymichaelclark @abn I tried adding both packages and include to pyproject.toml and there was no difference in behavior. So it doesn't appear that the problem is there.

That being said, @kaluluosi 's comment about unicode definitely got my ears to perk up, because both my personal PC and my work computer have their system locale set to DE-DE.

When I go to remove the file, I also see:

PS D:\Dropbox\Projekte\finfuck> poetry run pip uninstall finfuck 
The currently activated Python version 3.10.0 is not supported by the project (~3.9).
Trying to find and use a compatible version.
Using python3.9 (3.9.7)
Found existing installation: finfuck 0.0.1
Uninstalling finfuck-0.0.1:
Would remove:
c:\users\niklas\appdata\local\pypoetry\cache\virtualenvs\finfuck-hb6y0nli-py3.9\lib\site-packages\finfuck-0.0.1.dist-info\*   
c:\users\niklas\appdata\local\pypoetry\cache\virtualenvs\finfuck-hb6y0nli-py3.9\lib\site-packages\finfuck.pth
Proceed (Y/n)?    

So it looks like the .pth is in fact being created.

@neersighted
Copy link
Member

Closing as a specialized duplicate of #6091 as the only working reproductions are based on that root cause.

@neersighted neersighted closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2022
@neersighted neersighted added status/duplicate Duplicate issues and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 4, 2022
Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

5 participants