| 29 Oct 2024 |
truh | I usually put it in buildInputs not propagatedBuildInputs
pkgs.openldap
pkgs.cyrus_sasl
# Fix for "cannot find -lldap_r: No such file or directory"
(pkgs.writeTextFile {
name = "openldap-lib-fix";
destination = "/lib/libldap_r.so";
text = "INPUT ( libldap.so )\n";
})
Should no longer be necessary if you poetry2nix is up to date | 14:34:34 |
truh | It's already here https://github.com/nix-community/poetry2nix/blob/2b84afaf6ff1765bcb4cdd97e53a6914feb82ebf/overrides/default.nix#L2724 | 14:35:33 |
Pico | I'm just working from a poetry2nix source tree :) | 14:35:39 |
Pico | So yes, working from what is already there | 14:35:57 |
| Daniel Garcia Medina joined the room. | 20:07:06 |
| 31 Oct 2024 |
| 9456ed88e6 joined the room. | 19:52:24 |
9456ed88e6 | I'm running into a problem that I cannot figure out, if someone has a clue, I would very much appreciate some feedback.
I am getting an error when I use nix to run or build my python poetry project if the entry point module is not named main.
Here is the error:
~/mypackage$ nix run
Traceback (most recent call last):
File "/nix/store/g0fsa09mpa90apcy2i02vljgd5rxxj42-python3.12-mypackage-0.5.0/bin/.mypackage-wrapped", line 6, in <module>
from mypackage.cli import app
ModuleNotFoundError: No module named 'mypackage.cli'
Here is the structure of my project:
mypackage/
├── README.md
├── mypackage
│ ├── __init__.py
│ ├── cli.py
│ └── mymodule.py
├── flake.lock
├── flake.nix
├── poetry.lock
├── pyproject.toml
Here is the [tool.poetry.scripts] section of my pyproject.toml
[tool.poetry.scripts]
mypackage = "mypackage.cli:app"
Here is my flake.nix
{
description = "mypackage";
# Flake inputs
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
# Flake outputs
outputs = { self, nixpkgs, poetry2nix }:
let
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
});
in
{
packages = forAllSystems
({ pkgs }:
let
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
in
rec {
myapp = mkPoetryApplication { projectDir = self; };
default = myapp;
apps.default = "${myapp}/bin/mypackage";
});
devShells = forAllSystems
({ pkgs }:
let
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
in
{
default = pkgs.mkShell
{
packages = with pkgs; [
poetry
(mkPoetryApplication { projectDir = self; })
];
};
});
};
}
If I simply rename the cli.py module to main.py, and change the pyproject.toml to reflect the new name, everything works, and there is no error when running the executable produced by nix build, or running with nix run.
The structure of my project tree when it works is simply
mypackage/
├── README.md
├── mypackage
│ ├── __init__.py
│ ├── main.py <------------ This is the change.
│ └── mymodule.py
├── flake.lock
├── flake.nix
├── poetry.lock
├── pyproject.toml
Here is the [tool.poetry.scripts] section of my pyproject.toml with the associated change
[tool.poetry.scripts]
mypackage = "mypackage.main:app"
Does anyone know why I am getting the error when I try to name the module something other than main.py, how can I get everything working when I name the module cli.py?
| 19:55:59 |
K900 | You probably don't have the renamed module tracked by git | 19:56:34 |
K900 | So it's filtered out when evaluating the flake | 19:56:42 |
9456ed88e6 | I have just double checked, and everything is being tracked. Thanks your suggestion tho. | 19:58:39 |
9456ed88e6 | Also I love how you're in every single nix related matrix room :P thanks for trying to answer my questions | 19:59:11 |
K900 | When you rename the file, git does not track the rename | 19:59:18 |
K900 | Unless you use git mv | 19:59:23 |
9456ed88e6 | I have committed the changes tho, I can try with git mv to see if it makes a difference | 19:59:51 |
9456ed88e6 | No change | 20:03:00 |
K900 | What's the output of git show HEAD? | 20:04:04 |
9456ed88e6 | commit 028be2f14b3310f3b4ae7d3d41234a19c10d6b49 (HEAD -> feature/entrypoint-option-2)
Author: GITHUB_USERNAME <EMAIL>
Date: Thu Oct 31 16:04:40 2024 -0400
change module name
diff --git a/mypackage/__main__.py b/mypackage/__main__.py
index a7146ff..8f48437 100644
--- a/mypackage/__main__.py
+++ b/mypackage/__main__.py
@@ -1,3 +1,3 @@
-from mypackage.main import app
+from mypackage.cli import app
app()
diff --git a/mypackage/main.py b/mypackage/cli.py
similarity index 100%
rename from mypackage/main.py
rename to mypackage/cli.py
diff --git a/pyproject.toml b/pyproject.toml
index 717f5c7..3872e71 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -7,7 +7,7 @@ readme = "README.md"
license = "Blue Oak Model License 1.0.0"
[tool.poetry.scripts]
-mypackage = "mypackage.main:app"
+mypackage = "mypackage.cli:app"
[tool.poetry.dependencies]
python = "^3.12"
| 20:07:39 |
K900 | And what is in your pyproject.toml? | 20:10:01 |
9456ed88e6 | [tool.poetry]
name = "mypackage"
version = "0.5.0"
description = "description"
authors = ["author"]
readme = "README.md"
license = "Blue Oak Model License 1.0.0"
[tool.poetry.scripts]
mypackage = "mypackage.cli:app"
[tool.poetry.dependencies]
python = "^3.12"
typer = "^0.12.3"
pydantic = "^2.8.2"
pytest = "^8.3.2"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
| 20:11:25 |
9456ed88e6 | poetry run mypackage works correctly btw. | 20:12:27 |
9456ed88e6 | * poetry run mypackage works correctly btw with whatever the module is named | 20:12:55 |
| 1 Nov 2024 |
Pico | Seems to work fine for me fwiw
tree
.
├── flake.lock
├── flake.nix
└── test
├── pack
│ ├── do_stuff.py
│ └── __init__.py
├── poetry.lock
└── pyproject.toml
cat flake.nix
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, poetry2nix }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
app = mkPoetryApplication { projectDir = ./test; };
in
{
devShells.x86_64-linux.default = pkgs.mkShell {
packages = with pkgs; [ app ];
};
};
}```
cat test/pyproject.toml [tool.poetry] name = "pack" version = "0.1.0" description = "" authors = ["Your Name you@example.com"]
[tool.poetry.dependencies] python = "^3.11"
[tool.poetry.scripts] foo = "pack.do_stuff:main"
[build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"
foo Doing stuff
| 14:35:54 |
Pico | * Seems to work fine for me fwiw
tree
.
├── flake.lock
├── flake.nix
└── test
├── pack
│ ├── do_stuff.py
│ └── __init__.py
├── poetry.lock
└── pyproject.toml
cat flake.nix
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, poetry2nix }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
app = mkPoetryApplication { projectDir = ./test; };
in
{
devShells.x86_64-linux.default = pkgs.mkShell {
packages = with pkgs; [ app ];
};
};
}```
```
cat test/pyproject.toml
\[tool.poetry\]
name = "pack"
version = "0.1.0"
description = ""
authors = \["Your Name [you@example.com](mailto:you@example.com)"\]
\[tool.poetry.dependencies\]
python = "^3.11"
\[tool.poetry.scripts\]
foo = "pack.do\_stuff:main"
\[build-system\]
requires = \["poetry-core"\]
build-backend = "poetry.core.masonry.api"
```
foo
Doing stuff
```
| 14:37:01 |
Pico | * Seems to work fine for me fwiw
tree
.
├── flake.lock
├── flake.nix
└── test
├── pack
│ ├── do_stuff.py
│ └── __init__.py
├── poetry.lock
└── pyproject.toml
cat flake.nix
{
description = "A very basic flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
outputs = { self, nixpkgs, poetry2nix }:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
app = mkPoetryApplication { projectDir = ./test; };
in
{
devShells.x86_64-linux.default = pkgs.mkShell {
packages = with pkgs; [ app ];
};
};
}
cat test/pyproject.toml
\[tool.poetry\]
name = "pack"
version = "0.1.0"
description = ""
authors = \["Your Name [you@example.com](mailto:you@example.com)"\]
\[tool.poetry.dependencies\]
python = "^3.11"
\[tool.poetry.scripts\]
foo = "pack.do\_stuff:main"
\[build-system\]
requires = \["poetry-core"\]
build-backend = "poetry.core.masonry.api"
foo
Doing stuff
| 14:39:02 |
| 2 Nov 2024 |
| pie_ joined the room. | 02:26:45 |
pie_ | Hey folks, anyone know offhand how to fix this? I'm building pyqtwebengine with poetry2nix and its missing some kind of (propagated) dep or something, but idk enough about qt/sip;
...
Executing pipBuildPhase
Creating a wheel...
WARNING: The directory '/homeless-shelter/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
Processing /build/PyQtWebEngine-5.15.7
Running command Preparing metadata (pyproject.toml)
Querying qmake about your Qt installation...
These bindings will be built: QtWebEngineCore, QtWebEngine, QtWebEngineWidgets.
Generating the QtWebEngineCore bindings...
_in_process.py: /build/PyQtWebEngine-5.15.7/sip/QtWebEngineCore/QtWebEngineCoremod.sip: line 25: column 9: 'QtCore/QtCoremod.sip' could not be found
/build/PyQtWebEngine-5.15.7/sip/QtWebEngineCore/QtWebEngineCoremod.sip: line 26: column 9: 'QtGui/QtGuimod.sip' could not be found
/build/PyQtWebEngine-5.15.7/sip/QtWebEngineCore/QtWebEngineCoremod.sip: line 27: column 9: 'QtNetwork/QtNetworkmod.sip' could not be found
/build/PyQtWebEngine-5.15.7/sip/QtWebEngineCore/qwebengineclientcertificatestore.sip: line 24: column 6: 'PyQt_SSL' is not a known qualifier
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: /nix/store/wfbjq35kxs6x83c3ncpfxdyl5gbhdx4h-python3-3.12.6/bin/python3.12 /nix/store/xdgmgzz3ng0bl0x5r6vmx0arqnfwsfj1-python3.12-pip-24.0/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_wheel /build/tmpqnqavqa5
...
| 02:28:05 |
pie_ | hrmblgrmbl.... https://github.com/Python-SIP/sip/blob/10cb0c23cd25756769a1a388ab0976245e7f6590/sipbuild/builder.py#L228
| 03:28:53 |
pie_ | ah...yeah here we go..i guess this is the way to go, bleh... https://github.com/NixOS/nixpkgs/blob/a3a8b0fbfb8dc700982a1d4fe6078e92b8042c54/pkgs/development/python-modules/pyqtwebengine/default.nix#L35 | 03:42:14 |
| 4 Nov 2024 |
truh | In reply to @9456ed88e6:matrix.org
I'm running into a problem that I cannot figure out, if someone has a clue, I would very much appreciate some feedback.
I am getting an error when I use nix to run or build my python poetry project if the entry point module is not named main.
Here is the error:
~/mypackage$ nix run
Traceback (most recent call last):
File "/nix/store/g0fsa09mpa90apcy2i02vljgd5rxxj42-python3.12-mypackage-0.5.0/bin/.mypackage-wrapped", line 6, in <module>
from mypackage.cli import app
ModuleNotFoundError: No module named 'mypackage.cli'
Here is the structure of my project:
mypackage/
├── README.md
├── mypackage
│ ├── __init__.py
│ ├── cli.py
│ └── mymodule.py
├── flake.lock
├── flake.nix
├── poetry.lock
├── pyproject.toml
Here is the [tool.poetry.scripts] section of my pyproject.toml
[tool.poetry.scripts]
mypackage = "mypackage.cli:app"
Here is my flake.nix
{
description = "mypackage";
# Flake inputs
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
poetry2nix.url = "github:nix-community/poetry2nix";
};
# Flake outputs
outputs = { self, nixpkgs, poetry2nix }:
let
# Systems supported
allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];
# Helper to provide system-specific attributes
forAllSystems = f: nixpkgs.lib.genAttrs allSystems (system: f {
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
});
in
{
packages = forAllSystems
({ pkgs }:
let
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
in
rec {
myapp = mkPoetryApplication { projectDir = self; };
default = myapp;
apps.default = "${myapp}/bin/mypackage";
});
devShells = forAllSystems
({ pkgs }:
let
inherit (poetry2nix.lib.mkPoetry2Nix { inherit pkgs; }) mkPoetryApplication;
in
{
default = pkgs.mkShell
{
packages = with pkgs; [
poetry
(mkPoetryApplication { projectDir = self; })
];
};
});
};
}
If I simply rename the cli.py module to main.py, and change the pyproject.toml to reflect the new name, everything works, and there is no error when running the executable produced by nix build, or running with nix run.
The structure of my project tree when it works is simply
mypackage/
├── README.md
├── mypackage
│ ├── __init__.py
│ ├── main.py <------------ This is the change.
│ └── mymodule.py
├── flake.lock
├── flake.nix
├── poetry.lock
├── pyproject.toml
Here is the [tool.poetry.scripts] section of my pyproject.toml with the associated change
[tool.poetry.scripts]
mypackage = "mypackage.main:app"
Does anyone know why I am getting the error when I try to name the module something other than main.py, how can I get everything working when I name the module cli.py?
Does the error go away with an earlier poetry2nix version? | 09:32:34 |
truh | I also experience ModuleNotFoundErrors (that I still need to investigate) with one of my projects when upgrading to the lastest poetry2nix | 09:33:53 |