DavidVujic / poetry-multiproject-plugin

A Poetry plugin that makes it simple to share code between projects in monorepos.
https://davidvujic.github.io/python-polylith-docs/installation/
MIT License
190 stars 7 forks source link

Allow configure location of dot dirs #66

Open alexanderilyin opened 3 hours ago

alexanderilyin commented 3 hours ago

poetry build-project fails when run in Dev Container:

⬢ [Docker] ❯ poetry build-project
Using /workspaces/partcad/pyproject.toml

[Errno 13] Permission denied: '/workspaces/.prepare_partcad-dev'

I would like to be able to create .prepare_partcad-dev in /tmp

I considered using sudo / chmod / chown but I do not like those.

alexanderilyin commented 3 hours ago

Also this:

sudo mkdir -m 777 /workspaces/.prepare_partcad-dev
poetry build-project

Fails with the following output:

Using /workspaces/partcad/pyproject.toml

[('/workspaces/partcad', '/workspaces/.prepare_partcad-dev', '[Errno 1] Operation not permitted')]
alexanderilyin commented 3 hours ago

A little bit more details:

⬢ [Docker] ❯ ls -al /workspaces/
total 12
drwxr-xr-x  4 root root 4096 Nov 16 06:20 .
drwxr-xr-x  1 root root 4096 Nov 16 03:58 ..
drwxrwxrwx  1 root root 4096 Nov 16 05:14 partcad
drwxrwxrwx 10 root root 4096 Nov 16 06:20 .prepare_partcad-dev
⬢ [Docker] ❯ id
uid=1000(node) gid=1000(node) groups=1000(node),998(nvm),999(npm)
DavidVujic commented 1 hour ago

Hi @alexanderilyin, thank you for reporting this issue!

I have no experience of Dev Containers, but it looks like a permission issue as you have described. The build-project command will create a temporary directory, and copy the paths specified in the packages section. Then it will reconstruct a separate pyproject.toml file. Finally it will run the regular poetry build on it to create a dist folder with a wheel. It will also delete the temporary folder.

I wonder if the user running in the container doesn't have the permissions to do things like that. You mention a temp folder, are there different permissions there?

alexanderilyin commented 46 minutes ago

Yep, long story short cloned folder is mounted to /workspaces/the_project/, terminal runs under non privileged user in this case it's node. Parent directory /workspaces is owner by root:

⬢ [Docker] ❯ stat /workspaces/
  File: /workspaces/
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: 0,192   Inode: 315072      Links: 4
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-11-16 06:20:33.222276001 +0000
Modify: 2024-11-16 06:20:33.192274806 +0000
Change: 2024-11-16 06:20:33.192274806 +0000
 Birth: 2024-11-16 03:58:13.096981744 +0000

Generally I have sudo in container and I can do chmod / chown but I choose not to. My 1st choice for writeable location outside /workspace/the_project is /tmp, since it's writeable by anyone in 99.9% envs I've seen:

⬢ [Docker] ❯ stat /tmp
  File: /tmp
  Size: 20480           Blocks: 40         IO Block: 4096   directory
Device: 0,192   Inode: 291713      Links: 1
Access: (1777/drwxrwxrwt)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-11-16 08:41:23.069267117 +0000
Modify: 2024-11-16 09:07:14.525772722 +0000
Change: 2024-11-16 09:07:14.525772722 +0000
 Birth: 2024-11-16 03:58:15.567087253 +0000

It would be nice to have a command option (also settable via ENV var) so I can tell plugin to use not .parent.parent but my choice of the "base" dir.

P. S. I'm going to use the plugin to release two packages from single "monorepo".