@@ -233,10 +233,13 @@ def __init__(
233233 name : str ,
234234 version : str ,
235235 slug : str | None = None ,
236+ repo : str | None = None ,
237+ tag_or_commit : str | None = None ,
236238 ) -> None :
237239 super ().__init__ (name , version , slug )
238240 self ._conda_exe : Path | None = None
239241 self ._prefix : Path | None = None
242+ self .url = f"git+{ repo } @{ tag_or_commit } " if repo and tag_or_commit else None
240243
241244 @property
242245 def prefix (self ) -> Path :
@@ -321,8 +324,10 @@ def env_path(self) -> Path:
321324 A unique path for storing the conda environment.
322325 """
323326 with self .get_environment_file () as file :
324- suffix = hashlib .sha1 (file .read_bytes (), usedforsecurity = False ).hexdigest ()
325- return self .prefix / f"{ self .slug } -{ suffix } "
327+ suffix = hashlib .sha1 (file .read_bytes (), usedforsecurity = False )
328+ if self .url is not None :
329+ suffix .update (bytes (self .url , encoding = "utf-8" ))
330+ return self .prefix / f"{ self .slug } -{ suffix .hexdigest ()} "
326331
327332 def create_env (self ) -> None :
328333 """
@@ -333,9 +338,10 @@ def create_env(self) -> None:
333338 logger .info (f"Environment at { self .env_path } already exists, skipping." )
334339 return
335340
341+ conda_exe = f"{ self .get_conda_exe (update = True )} "
336342 with self .get_environment_file () as file :
337343 cmd = [
338- f" { self . get_conda_exe ( update = True ) } " ,
344+ conda_exe ,
339345 "create" ,
340346 "--yes" ,
341347 "--file" ,
@@ -346,6 +352,21 @@ def create_env(self) -> None:
346352 logger .debug (f"Running { ' ' .join (cmd )} " )
347353 subprocess .run (cmd , check = True ) # noqa: S603
348354
355+ if self .url is not None :
356+ logger .info (f"Installing development version of { self .slug } from { self .url } " )
357+ cmd = [
358+ conda_exe ,
359+ "run" ,
360+ "--prefix" ,
361+ f"{ self .env_path } " ,
362+ "pip" ,
363+ "install" ,
364+ "--no-deps" ,
365+ self .url ,
366+ ]
367+ logger .debug (f"Running { ' ' .join (cmd )} " )
368+ subprocess .run (cmd , check = True ) # noqa: S603
369+
349370 def run (self , cmd : Iterable [str ]) -> None :
350371 """
351372 Run a command.
0 commit comments