Repository: pdm-project/pdm

Issue:
Importing editable dependencies in requirements.txt
- [x] I have searched the issue tracker and believe that this is not a duplicate.

## Steps to reproduce
`pdm import requirements.txt -v`
```
python.use_venv is on, creating a virtualenv for this project...
Run command: ['/home/john/.local/pipx/venvs/pdm/bin/python', '-m', 'virtualenv',
'/home/john/Projects/airbyte/airbyte-integrations/connectors/source-spotify/.venv', '-p', '/usr/bin/python',
'--no-pip', '--no-setuptools', '--no-wheel', '--prompt=source-spotify-3.10']
created virtual environment CPython3.10.9.final.0-64 in 72ms
creator CPython3Posix(dest=/home/john/Projects/airbyte/airbyte-integrations/connectors/source-spotify/.venv,clear=False, no_vcs_ignore=False, global=False)
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Virtualenv is created successfully at
/home/john/Projects/airbyte/airbyte-integrations/connectors/source-spotify/.venv
The project's requires-python has been set to >=3.10. You can change it later if necessary.
Changes are written to pyproject.toml.
```
`pdm install -v`
```
Lock file does not exist
Updating the lock file...
WARNING: Skipping editable dependency -e b''#egg=connector-acceptance-test in the [project] table. Please move
it to the [tool.pdm.dev-dependencies] table
WARNING: Skipping editable dependency -e b''#egg=source-spotify in the [project] table. Please move it to the
[tool.pdm.dev-dependencies] table
STATUS: Resolving dependencies
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   python>=3.10
pdm.termui:   Adding requirement python>=3.10
pdm.termui: ======== Starting round 0 ========
STATUS: Resolving: new pin python>=3.10
pdm.termui: Pinning: python None
pdm.termui: ======== Ending round 0 ========
pdm.termui: ======== Starting round 1 ========
pdm.termui: ======== Resolution Result ========
pdm.termui: Stable pins:
pdm.termui:   python None
STATUS: Fetching hashes for resolved packages...
🔒 Lock successful
Changes are written to pdm.lock.
WARNING: Skipping editable dependency -e b''#egg=connector-acceptance-test in the [project] table. Please move
it to the [tool.pdm.dev-dependencies] table
WARNING: Skipping editable dependency -e b''#egg=source-spotify in the [project] table. Please move it to the
[tool.pdm.dev-dependencies] table
STATUS: Resolving packages from lockfile...
STATUS: Fetching hashes for resolved packages...
All packages are synced to date, nothing to do.

🎉 All complete!
```

<!--Describe the minimized example of how to reproduce the bug-->

## Actual behavior
Adds egg folder to normal dependencies. And doesn't install anything.

<!--A clear and concise description the result of the above steps--> 

## Expected behavior

If editable dependency is found while importing requirements.txt, exact behavior as `pdm add -d -e ../../editable/` is expected.
<!--A clear and concise description of what you expected to happen.-->

## Environment Information

```bash
PDM version:
2.4.2
Python Interpreter:
/home/john/Projects/airbyte/airbyte-integrations/connectors/source-spotify/.venv/bin/python (3.10)
Project Root:
/home/john/Projects/airbyte/airbyte-integrations/connectors/source-spotify
Project Packages:
None
{
"implementation_name": "cpython",
"implementation_version": "3.10.9",
"os_name": "posix",
"platform_machine": "x86_64",
"platform_release": "6.1.9-2-cachyos-bore",
"platform_system": "Linux",
"platform_version": "#1 SMP PREEMPT_DYNAMIC Thu, 02 Feb 2023 12:28:59 +0000",
"python_full_version": "3.10.9",
"platform_python_implementation": "CPython",
"python_version": "3.10",
"sys_platform": "linux"
}

```


Discussion:

Patch:
diff --git a/news/1674.bugfix.md b/news/1674.bugfix.md
new file mode 100644
index 00000000..72c1dd9f
--- /dev/null
+++ b/news/1674.bugfix.md
@@ -0,0 +1,1 @@
+Import editable requirements into dev dependencies.
diff --git a/src/pdm/formats/requirements.py b/src/pdm/formats/requirements.py
index 504ddbd2..17b381d1 100644
--- a/src/pdm/formats/requirements.py
+++ b/src/pdm/formats/requirements.py
@@ -129,13 +129,24 @@ def convert(
 ) -> tuple[Mapping[str, Any], Mapping[str, Any]]:
     parser = RequirementParser()
     parser.parse(str(filename))
+    backend = project.backend
 
-    deps = make_array([r.as_line() for r in parser.requirements], True)
+    deps = make_array([], True)
+    dev_deps = make_array([], True)
+
+    for req in parser.requirements:
+        if req.is_file_or_url:
+            req.relocate(backend)  # type: ignore[attr-defined]
+        if req.editable or options.dev:
+            dev_deps.append(req.as_line())
+        else:
+            deps.append(req.as_line())
     data: dict[str, Any] = {}
     settings: dict[str, Any] = {}
-    if options.dev:
-        settings["dev-dependencies"] = {options.group or "dev": deps}
-    elif options.group:
+    if dev_deps:
+        dev_group = options.group if options.group and options.dev else "dev"
+        settings["dev-dependencies"] = {dev_group: dev_deps}
+    if options.group and deps:
         data["optional-dependencies"] = {options.group: deps}
     else:
         data["dependencies"] = deps


Test patch:
diff --git a/tests/test_formats.py b/tests/test_formats.py
index f5d7aef5..04febbcb 100644
--- a/tests/test_formats.py
+++ b/tests/test_formats.py
@@ -29,11 +29,14 @@ def test_convert_requirements_file(project, is_dev):
     options = Namespace(dev=is_dev, group=None)
     result, settings = requirements.convert(project, golden_file, options)
     group = settings["dev-dependencies"]["dev"] if is_dev else result["dependencies"]
+    dev_group = settings["dev-dependencies"]["dev"]
 
     assert len(settings["source"]) == 2
     assert "webassets==2.0" in group
     assert 'whoosh==2.7.4; sys_platform == "win32"' in group
-    assert "-e git+https://github.com/pypa/pip.git@main#egg=pip" in group
+    assert "-e git+https://github.com/pypa/pip.git@main#egg=pip" in dev_group
+    if not is_dev:
+        assert "-e git+https://github.com/pypa/pip.git@main#egg=pip" not in group
     assert (
         "pep508-package @ git+https://github.com/techalchemy/test-project.git"
         "@master#subdirectory=parent_folder/pep508-package" in group
@@ -129,16 +132,17 @@ def test_convert_flit(project):
 def test_import_requirements_with_group(project):
     golden_file = FIXTURES / "requirements.txt"
     assert requirements.check_fingerprint(project, golden_file)
-    result, _ = requirements.convert(
+    result, settings = requirements.convert(
         project, golden_file, Namespace(dev=False, group="test")
     )
 
     group = result["optional-dependencies"]["test"]
+    dev_group = settings["dev-dependencies"]["dev"]
     assert "webassets==2.0" in group
     assert 'whoosh==2.7.4; sys_platform == "win32"' in group
-    assert "-e git+https://github.com/pypa/pip.git@main#egg=pip" in group
+    assert "-e git+https://github.com/pypa/pip.git@main#egg=pip" not in group
+    assert "-e git+https://github.com/pypa/pip.git@main#egg=pip" in dev_group
     assert not result.get("dependencies")
-    assert not result.get("dev-dependencies", {}).get("dev")
 
 
 def test_export_expand_env_vars_in_source(project, monkeypatch):