33import hashlib
44import os
55import platform
6+ import re
67import shutil
78import subprocess
89import sys
@@ -515,15 +516,16 @@ def _write_requirements_file(
515516
516517 with self .input .wait_bar ("Writing requirements file..." ):
517518 with requirements_path .open ("w" , encoding = "utf-8" ) as f :
519+ # Add timestamp so build systems (such as Gradle) detect a change
520+ # in the file and perform a re-installation of all requirements.
521+ f .write (f"# Generated { datetime .now ()} \n " )
522+
518523 if requires :
519- # Add timestamp so build systems (such as Gradle) detect a change
520- # in the file and perform a re-installation of all requirements.
521- f .write (f"# Generated { datetime .now ()} \n " )
522524 for requirement in requires :
523525 # If the requirement is a local path, convert it to
524526 # absolute, because Flatpak moves the requirements file
525527 # to a different place before using it.
526- if _is_local_requirement (requirement ):
528+ if _is_local_path (requirement ):
527529 # We use os.path.abspath() rather than Path.resolve()
528530 # because we *don't* want Path's symlink resolving behavior.
529531 requirement = os .path .abspath (self .base_path / requirement )
@@ -544,7 +546,17 @@ def _extra_pip_args(self, app: AppConfig):
544546 :param app: The app configuration
545547 :returns: A list of additional arguments
546548 """
547- return []
549+ args : list [str ] = []
550+ for argument in app .requirement_installer_args :
551+ if relative_path_matcher .match (argument ) and _is_local_path (argument ):
552+ abs_path = os .path .abspath (self .base_path / argument )
553+ if Path (abs_path ).exists ():
554+ args .append (abs_path )
555+ continue
556+
557+ args .append (argument )
558+
559+ return args
548560
549561 def _pip_install (
550562 self ,
@@ -618,7 +630,7 @@ def _install_app_requirements(
618630 self .tools .os .mkdir (app_packages_path )
619631
620632 # Install requirements
621- if requires :
633+ if requires or app . requirement_installer_args :
622634 with self .input .wait_bar (progress_message ):
623635 self ._pip_install (
624636 app ,
@@ -972,15 +984,18 @@ def _has_url(requirement):
972984 )
973985
974986
975- def _is_local_requirement ( requirement ):
976- """Determine if the requirement is a local file path.
987+ def _is_local_path ( reference ):
988+ """Determine if the reference is a local file path.
977989
978- :param requirement : The requirement to check
979- :returns: True if the requirement is a local file path
990+ :param reference : The reference to check
991+ :returns: True if the reference is a local file path
980992 """
981- # Windows allows both / and \ as a path separator in requirements .
993+ # Windows allows both / and \ as a path separator in references .
982994 separators = [os .sep ]
983995 if os .altsep :
984996 separators .append (os .altsep )
985997
986- return any (sep in requirement for sep in separators ) and (not _has_url (requirement ))
998+ return any (sep in reference for sep in separators ) and (not _has_url (reference ))
999+
1000+
1001+ relative_path_matcher = re .compile (r"^\.{1,2}[\\/]" )
0 commit comments