2929from typing import Dict , List , Set
3030from ..project_ops_info import ProjectUpdateInfo , ProjectBuildInfo
3131from ..utils import note , fatal , get_venv_python
32+ from ..pkg_content_type import PythonTypeData
3233
3334from ..package import Package
3435from .package_handler import PackageHandler
@@ -49,6 +50,10 @@ def process_pkg(self, pkg: Package):
4950 if pkg .src_type == "pypi" :
5051 self .pypi_pkg_s .add (pkg .name )
5152 add = True
53+ elif isinstance (pkg .type_data , PythonTypeData ):
54+ # Explicit type: python via 'with:' mechanism
55+ self .src_pkg_s .add (pkg .name )
56+ add = True
5257 elif pkg .pkg_type is not None and pkg .pkg_type == PackageHandlerPython .name :
5358 self .src_pkg_s .add (pkg .name )
5459 add = True
@@ -408,17 +413,30 @@ def _write_requirements_txt(self,
408413 for pkg in python_pkgs :
409414
410415 if hasattr (pkg , "url" ):
411- # Editable package
412- # fp.write("-e file://%s/%s#egg=%s\n" % (
413- # packages_dir.replace("\\","/"),
414- # pkg.name,
415- # pkg.name))
416- fp .write ("-e %s/%s\n " % (
417- packages_dir .replace ("\\ " ,"/" ),
418- pkg .name ))
416+ # Source package (git, dir, http, etc.)
417+ # Determine editability: type_data takes priority, then default True
418+ editable = True
419+ if isinstance (pkg .type_data , PythonTypeData ) and pkg .type_data .editable is not None :
420+ editable = pkg .type_data .editable
421+
422+ # Extras from type_data (for source packages declared with type: python + with: extras:)
423+ extras = None
424+ if isinstance (pkg .type_data , PythonTypeData ):
425+ extras = pkg .type_data .extras
426+ extras_str = "[%s]" % "," .join (extras ) if extras else ""
427+
428+ pkg_path = "%s/%s" % (packages_dir .replace ("\\ " ,"/" ), pkg .name )
429+ if editable :
430+ fp .write ("-e %s%s\n " % (pkg_path , extras_str ))
431+ else :
432+ fp .write ("%s%s\n " % (pkg_path , extras_str ))
419433 else :
420434 # PyPi package — build PEP 508 specifier: name[extras]version
421- extras = getattr (pkg , "extras" , None )
435+ # Extras: prefer type_data if present, fall back to pkg.extras (PackagePyPi)
436+ if isinstance (pkg .type_data , PythonTypeData ) and pkg .type_data .extras is not None :
437+ extras = pkg .type_data .extras
438+ else :
439+ extras = getattr (pkg , "extras" , None )
422440 extras_str = "[%s]" % "," .join (extras ) if extras else ""
423441 if pkg .version is not None :
424442 if pkg .version [0 ] in ['<' ,'>' ,'=' ]:
0 commit comments