Comments (2)
First, the value of
package
is determined from theincludes
field inpyproject.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.
First, the value of
package
is determined from theincludes
field inpyproject.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)
- Author names with commas result in invalid PKG-INFO Author-Email field HOT 1
- Improve documentation on hooks flow - specifically when and how the dynamic version is written to a file HOT 3
- why use pdm-backend over setuptools? HOT 1
- Use `git describe` for generating project version from SCM HOT 6
- cleaning up the source directory after build HOT 2
- .dist-info folder name incorrectly normalized HOT 2
- Allow filtering tags when using SCM to determine the version HOT 3
- 2.2.0 regression: All project installs with multiline descriptions are broken HOT 4
- pdm-backend 2.2.1 test failure in Debian Sid: demo-metadata-test HOT 1
- The actual behavior of `Dynamic project version` is different from document HOT 3
- Support map "includes" to a different directory in site-packages HOT 3
- Errors when using the `editables` backend with the `includes` field
- package-dir and `FileNotFoundError: [Errno 2] No such file or directory` HOT 7
- a way to import modules from the project root in `pdm_build.py` HOT 3
- a way to import modules from the project root in `pdm_build.py`
- a way to apply hooks from a `BuildHookInterface` HOT 1
- `pdm` installed scripts break in with venv + non-src layout HOT 7
- pdm_build.py added twice in sdist file.
- Support different versions of packages for different environments HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pdm-backend.