dream2nix icon indicating copy to clipboard operation
dream2nix copied to clipboard

"error: attribute 'name' missing" from the Python documentation

Open Zhen-hao opened this issue 2 years ago • 5 comments
trafficstars

following the documentation page, my flake file

{
  inputs = {
    dream2nix.url = "github:nix-community/dream2nix";
  };

  outputs = inp:
    inp.dream2nix.lib.makeFlakeOutputs {
      systems = ["x86_64-linux"];
      config.projectRoot = ./.;
      source = ./.;
      projects = ./pyproject.toml;
    };
}

gives this error

error: attribute 'name' missing

       at /nix/store/49wz7m3jxvvczxnz0li4fdam6bb1ckf6-source/src/modules/functions.discoverers/implementation.nix:106:46:

          105|     dlib.sanitizeRelativePath
          106|     "${config.dream2nixConfig.packagesDir}/${rootProject.name}/${project.relPath or ""}/dream-lock.json";
             |                                              ^
          107|

Zhen-hao avatar Jan 19 '23 10:01 Zhen-hao

With the (wip) poetry translator, the rootProject name should be taken from your pyproject.toml. Is

[tool.poetry]
name = "your-package"

defined there?

(we should probably default to the directories name if not defined)

phaer avatar Jan 19 '23 11:01 phaer

hi @phaer , Yes, I have name defined under [tool.poetry].

I got the same error when trying the following pyproject.toml,

[project]
name = "titanic_ml"
description = "titanic_ml example package"
version = "0.1.0"
authors = [
    { name = "Niels Zeilemaker", email = "[email protected]" }
]
dependencies = [
    "pyspark[ml]",
    "sklearn"
]

[project.optional-dependencies]
dev = [
    "tox",
    "pre-commit",
    "bump2version"
]

[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.2,<4"]

Source: https://godatadriven.com/blog/minimal-pyproject-toml-example/

Zhen-hao avatar Jan 19 '23 14:01 Zhen-hao

The pyproject.toml of the python project is not a valid value for the projects field.

Please use a dream2nix project description there.

nix run github:nix-community/dream2nix#detect-projects . > projects.toml should work for python as well as far as I understand.

NobbZ avatar Feb 18 '23 09:02 NobbZ

The pyproject.toml of the python project is not a valid value for the projects field.

Please use a dream2nix project description there.

nix run github:nix-community/dream2nix#detect-projects . > projects.toml should work for python as well as far as I understand.

I see.

My challenge is that I want to use Nix in a non-intrusive way because I need to collaborate with people who don't use Nix. Is it possible to anchor to requirements.txt instead of projects.toml?

Zhen-hao avatar Feb 18 '23 12:02 Zhen-hao

Not sure what you mean by "anchor"…

Though as I already said in the chat today, for simple code contributions in a non-nix world, a simply mkShell (not even flake based!) providing a python close to the projects main version as well as pip and a venv, or simply running poetry "imperatively" worked well for me.

There is really no need to go through most of the packaging related woes, if you just want to contribute within a non-nix world.

Depending on the details, you might need to re-install your venv every couple of GCs, though you will get your work/contributions done.

NobbZ avatar Feb 18 '23 17:02 NobbZ