-
-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop #egg
fragment on pdm export
if supplied a --no-egg-fragments
#2641
Comments
I was able to look at this a little deeper today, and determined that this is being set as a result of the requirements from a pdm/src/pdm/models/requirements.py Lines 355 to 372 in 07918b8
I was able to also determine that for some reason the logic for will result in the pdm/src/pdm/cli/commands/export.py Lines 59 to 68 in 07918b8
In my own testing with mocking this code directly, I originally thought that I was following the same logic, but you can see I'm only getting the default dependencies of my modified [project]
name = "monorepo"
version = "0.1.0"
dependencies = [
#none of these work ! they're not supposed to
#"-e pkg-core @ file:///${PROJECT_ROOT}/packages/pkg-core",
#"-e pkg-first @ file:///${PROJECT_ROOT}/packages/pkg-first",
#"-e pkg-second @ file:///${PROJECT_ROOT}/packages/pkg-second",
#"-e pkg-third @ file:///${PROJECT_ROOT}/packages/pkg-third",
#"-e pkg-fourth @ file:///${PROJECT_ROOT}/packages/pkg-fourth",
#"./packages/pkg-core",
#"./packages/pkg-first",
#"./packages/pkg-second",
#"./packages/pkg-third",
#"./packages/pkg-fourth",
# these will!
"pkg-core @ file:///${PROJECT_ROOT}/packages/pkg-core",
"pkg-first @ file:///${PROJECT_ROOT}/packages/pkg-first",
"pkg-second @ file:///${PROJECT_ROOT}/packages/pkg-second",
"pkg-third @ file:///${PROJECT_ROOT}/packages/pkg-third",
"pkg-fourth @ file:///${PROJECT_ROOT}/packages/pkg-fourth",
]
requires-python = ">=3.8"
[tool.pdm.dev-dependencies]
dev = [
"-e pkg-core @ file:///${PROJECT_ROOT}/packages/pkg-core",
"-e pkg-first @ file:///${PROJECT_ROOT}/packages/pkg-first",
"-e pkg-second @ file:///${PROJECT_ROOT}/packages/pkg-second",
"-e pkg-third @ file:///${PROJECT_ROOT}/packages/pkg-third",
"-e pkg-fourth @ file:///${PROJECT_ROOT}/packages/pkg-fourth",
]
[tool.pdm]
distribution = false
[build-system]
requires = ["pdm-backend"]
build-backend = "pdm.backend" >>> from pdm.core import Core
>>> from pdm.project.core import Project
>>> core = Core()
>>> Project(core, '.')
<Project '/home/python/pdm-example-monorepo'>
>>> proj = Project(core, '.')
>>> packages = requirements.values()
>>> packages
dict_values([FileRequirement(name='pkg-core', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=False, prerelease=None, groups=['default'], url='file:///${PROJECT_ROOT}/packages/pkg-core', path=PosixPath('packages/pkg-core'), subdirectory=None), FileRequirement(name='pkg-first', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=False, prerelease=None, groups=['default'], url='file:///${PROJECT_ROOT}/packages/pkg-first', path=PosixPath('packages/pkg-first'), subdirectory=None), FileRequirement(name='pkg-second', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=False, prerelease=None, groups=['default'], url='file:///${PROJECT_ROOT}/packages/pkg-second', path=PosixPath('packages/pkg-second'), subdirectory=None), FileRequirement(name='pkg-third', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=False, prerelease=None, groups=['default'], url='file:///${PROJECT_ROOT}/packages/pkg-third', path=PosixPath('packages/pkg-third'), subdirectory=None), FileRequirement(name='pkg-fourth', marker=None, extras=set(), specifier=<SpecifierSet('')>, editable=False, prerelease=None, groups=['default'], url='file:///${PROJECT_ROOT}/packages/pkg-fourth', path=PosixPath('packages/pkg-fourth'), subdirectory=None)])
>>> content = FORMATS["requirements"].export(proj, packages, options)
>>> content
'# This file is @generated by PDM.\n# Please do not edit it manually.\n\npkg-core @ file:///home/python/pdm-example-monorepo/packages/pkg-core\npkg-first @ file:///home/python/pdm-example-monorepo/packages/pkg-first\npkg-fourth @ file:///home/python/pdm-example-monorepo/packages/pkg-fourth\npkg-second @ file:///home/python/pdm-example-monorepo/packages/pkg-second\npkg-third @ file:///home/python/pdm-example-monorepo/packages/pkg-third\n'
>>> print(content)
# This file is @generated by PDM.
# Please do not edit it manually.
pkg-core @ file:///home/python/pdm-example-monorepo/packages/pkg-core
pkg-first @ file:///home/python/pdm-example-monorepo/packages/pkg-first
pkg-fourth @ file:///home/python/pdm-example-monorepo/packages/pkg-fourth
pkg-second @ file:///home/python/pdm-example-monorepo/packages/pkg-second
pkg-third @ file:///home/python/pdm-example-monorepo/packages/pkg-third
Then when running
As I dug deeper, I will get the same results of my repl session above if I run
I think in order for this to be an acceptable feature, there would need to be proof in what happens with a vanilla In a vanila
However, when not in a git directory, the same way of installation will result in what I'm after:
Ultimately I can see how I could implement this feature. Through |
I'm close to closing this issue as I've come to refactor my thoughts considerably, with my feature request being an edge case and the egg quirk being part of a much larger, and ongoing conversation from 2013, (with it mostly dropped in [email protected] hopefully to drop completely in 2025. And with it only being supported within a VCS repository url that's editable to name the package 🙄 I was originally dealing with theoretical scenarios and have recently moved to concrete implementation which as of now I'm comfortable with needing to use local editable when needed with a I found this one other comment today that I stumbled as I'm actively investigating, where mitsuhiko recommends using pdm's method of handling local editables which is also very topical as I'm also currently leveraging pdm for a refactor of a medium sized codebase to a monorepo - and I've looked a lot at the page mentioned a lot 😆 |
I am closing this issue feature request. Thank you for letting me dump my thoughts here! The primary reason is that this feature wouldn't be useful to many people, the output of Another reason is there's a better option (in my case at least) to use non-editable package paths and rely on Some more context: I have gone through many scenarios with boilerplate project structures. I've since discovered the best approach for my use case is to not rely on Now, in this specific use case, I am using both During development, I will use pdm. For deployment, I can use I could also still convert the requirements over through I expect in the future, For posterity and anyone that might stumble across this, the monorepo is laid out almost identical to pdm-project/pdm-example-monorepo. To then use it for [project]
dependencies = [
"pkg-core @ file:///${PROJECT_ROOT}/packages/pkg-core",
"pkg-first @ file:///${PROJECT_ROOT}/packages/pkg-first",
"pkg-second @ file:///${PROJECT_ROOT}/packages/pkg-second",
]
requires-python = ">=3.8"
[tool.pdm.dev-dependencies]
dev = [
"-e pkg-core @ file:///${PROJECT_ROOT}/packages/pkg-core",
"-e pkg-first @ file:///${PROJECT_ROOT}/packages/pkg-first",
"-e pkg-second @ file:///${PROJECT_ROOT}/packages/pkg-second",
] or as a diff: 2c2,6
< dependencies = []
---
> dependencies = [
> "pkg-core @ file:///${PROJECT_ROOT}/packages/pkg-core",
> "pkg-first @ file:///${PROJECT_ROOT}/packages/pkg-first",
> "pkg-second @ file:///${PROJECT_ROOT}/packages/pkg-second",
> ] Thanks again for your excellent work and this excellent project! Footnotes
|
Is your feature/enhancement proposal related to a problem? Please describe.
This is my first feature/enhancement proposal. This relates to a problem reconciling
#egg
fragments not being supported withuv
. astral-sh/uv#46pip
is also dropping support for egg distributions: pypa/pip#12330There has been work to remove it already: https://discuss.python.org/t/killing-off-the-egg-fragment-once-and-for-all/21660/ with a PR pypa/pip#11617
In the first referenced astral-sh/uv issue; a reply mentions the use of "editable wheels", which I think is the only case for it being used from what I can see in the documentation.
At usage/dependency/#vcs-dependencies
I'm currently working on a proof of concept with
pdm
for use in a monorepo lift. Following the documentation on this and referring to the example repo - the dependencies at the root of the project are written like:This works correctly for installing and working with the project in my testing for the proof of concept.
When attempting to export the dependencies to be read by a tool like
uv
; the export includes an egg fragment (probably for compatibility).Here's the output of the
pdm-example-monorepo
from runningpdm export
:This will fail
uv pip install -r requirements.txt
A workaround is to use sed to strip any
#egg
fragments from the editable installs frompdm export
with a pipe throughsed
Describe the solution you'd like
An option to drop the egg fragments like
--no-hashes
, perhaps--no-egg-fragments
.With my own unfamiliarity with code, I able to go as far as attempting to instantiate an instance of the export command in a repl, with a
pdm.core.Core()
instance, but I ended up falling back to mysed
workaround for my proof of concept.Feel free to modify or drop the suggestion. I appreciate your hard work on
pdm
!The text was updated successfully, but these errors were encountered: