GithubHelp home page GithubHelp logo

Comments (2)

frostming avatar frostming commented on August 15, 2024

First, the value of package is determined from the includes field in pyproject.toml

Not exactly, packages is not a list of paths, but a list of import names like ["foo", "foo.bar", ...], find out yourself.

includes = ["src/mypackage/", "other"]

This doesn't work because PDM will be confused what is the package-dir, in other words, it doesn't support extra paths out of package-dir

from pdm-backend.

xulongwu4 avatar xulongwu4 commented on August 15, 2024

First, the value of package is determined from the includes field in pyproject.toml

Not exactly, packages is not a list of paths, but a list of import names like ["foo", "foo.bar", ...], find out yourself.

@frostming do you mean that the package variable in the call editables.map(package, os.path.join(package_dir, package)) is not a path but a module such as foo.bar? If that is true, the os.path.join(package_dir, package) part would look problematic because the result of the joined path would be src/foo.bar here.

I have created the following sample project to demonstrate the problem more clearly. My directory tree is

$ tree .
.
├── pyproject.toml
└── src
    ├── mypackage1
    │   └── __init__.py
    └── mypackage2
        └── __init__.py

and the content of pyproject.toml is

[project]
name = "test"
version = "0.1.0"
description = "Default template for PDM package"
authors = []
dependencies = []
requires-python = "==3.12.*"

[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm.build]
package-dir = "src"
includes = ["src/mypackage1", "src/mypackage2"]
editable-backend = "editables"

@frostming as you can see, I only put folders inside the package-dir into includes . This is expected to work correctly based on your explanation above.

However, when I ran pdm install, which would perform an editable installation of the project using editables as the backend, I got the following error message:

$ pdm install
WARNING: Lockfile does not exist
Updating the lock file...
🔒 Lock successful
Changes are written to pdm.lock.
All packages are synced to date, nothing to do.
Installing the project as an editable package...
  ✖ Install test 0.1.0 failed

See /home/oulongwu/.local/state/pdm/log/pdm-install-1abiz06e.log for detailed debug log.
[BuildError]: Build backend raised error: Showing the last 10 lines of the build output:
  File "/tmp/pdm-build-env-ik5scq67-shared/lib/python3.12/site-packages/pdm/backend/base.py", line 149, in call_hook
    getattr(hook, hook_name)(context, *args, **kwargs)
  File "/tmp/pdm-build-env-ik5scq67-shared/lib/python3.12/site-packages/pdm/backend/editable.py", line 22, in pdm_build_initialize
    editables = self._prepare_editable(context)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/tmp/pdm-build-env-ik5scq67-shared/lib/python3.12/site-packages/pdm/backend/editable.py", line 61, in _prepare_editable
    editables.map(package, os.path.join(package_dir, package))
  File "/tmp/pdm-build-env-34ob9dw_-overlay/lib/python3.12/site-packages/editables/__init__.py", line 60, in map
    raise EditableException(f"{target} is not a valid Python package or module")
editables.EditableException: src/src/mypackage1 is not a valid Python package or module
WARNING: Add '-v' to see the detailed traceback

The error happens when pdm-backend thought we are referring to src/src/mypackage1 in the call to editable.map. This is the result of calling os.path.join(package_dir, package) with package_dir set to src and package set to src/mypackage1. As you can see, package here is a path rather than a dot-separated python package name.

from pdm-backend.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.