2
0

init_mamba.bat 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. @REM adapted from https://github.com/easydiffusion/easydiffusion
  2. @REM License
  3. @REM Copyright (c) 2022 cmdr2 and contributors
  4. @REM Section I
  5. @REM Permission is hereby granted, free of charge, to any person obtaining a copy
  6. @REM of this software and associated documentation files (the "Software"), to deal
  7. @REM in the Software without restriction, including without limitation the rights
  8. @REM to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. @REM copies of the Software, and to permit persons to whom the Software is
  10. @REM furnished to do so, subject to the following conditions:
  11. @REM The above copyright notice and this permission notice shall be included in all
  12. @REM copies or substantial portions of the Software.
  13. @REM The person obtaining a copy of the Software meets the Use-based restrictions
  14. @REM as referenced in Section II paragraph 1.
  15. @REM The person obtaining a copy of the Software accepts that the Model or
  16. @REM Derivatives of the Model (as defined in the "CreativeML Open RAIL-M" license
  17. @REM accompanying this License) are subject to Section II paragraph 1.
  18. @REM THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. @REM IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. @REM FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. @REM AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. @REM LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. @REM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. @REM SOFTWARE.
  25. @REM Section II
  26. @REM 1. Use-based restrictions. The restrictions set forth in Attachment A are
  27. @REM considered Use-based restrictions. Therefore the person obtaining a copy of the
  28. @REM Software cannot use the Software for the specified restricted uses. The person
  29. @REM obtaining a copy of the Software may use the Software only for lawful purposes.
  30. @REM 2. Except as set forth herein, the authors or copyright holders claim no rights
  31. @REM in the results of operating the Software. The person obtaining a copy of the
  32. @REM Software is accountable for the results of operating the Software and its
  33. @REM subsequent uses.
  34. @REM 3. If any provision of this License is held to be invalid, illegal or
  35. @REM unenforceable, the remaining provisions shall be unaffected thereby and
  36. @REM remain valid as if such provision had not been set forth herein.
  37. @REM END OF TERMS AND CONDITIONS
  38. @REM Attachment A
  39. @REM Use Restrictions
  40. @REM The person obtaining a copy of the Software agrees not to use the Software:
  41. @REM - In any way that violates any applicable national, federal, state, local
  42. @REM or international law or regulation;
  43. @REM - For the purpose of exploiting, harming or attempting to exploit or harm
  44. @REM minors in any way;
  45. @REM - To generate or disseminate verifiably false information and/or content
  46. @REM with the purpose of harming others;
  47. @REM - To generate or disseminate personal identifiable information that can
  48. @REM be used to harm an individual;
  49. @REM - To defame, disparage or otherwise harass others;
  50. @REM - For fully automated decision making that adversely impacts an
  51. @REM individual’s legal rights or otherwise creates or modifies a binding,
  52. @REM enforceable obligation;
  53. @REM - For any use intended to or which has the effect of discriminating
  54. @REM against or harming individuals or groups based on online or offline
  55. @REM social behavior or known or predicted personal or personality
  56. @REM characteristics;
  57. @REM - To exploit any of the vulnerabilities of a specific group of persons
  58. @REM based on their age, social, physical or mental characteristics, in order
  59. @REM to materially distort the behavior of a person pertaining to that group
  60. @REM in a manner that causes or is likely to cause that person or another
  61. @REM person physical or psychological harm;
  62. @REM - For any use intended to or which has the effect of discriminating
  63. @REM against individuals or groups based on legally protected characteristics
  64. @REM or categories;
  65. @REM - To provide medical advice and medical results interpretation;
  66. @REM - To generate or disseminate information for the purpose to be used for
  67. @REM administration of justice, law enforcement, immigration or asylum
  68. @REM processes, such as predicting an individual will commit fraud/crime
  69. @REM commitment (e.g. by text profiling, drawing causal relationships between
  70. @REM assertions made in documents, indiscriminate and arbitrarily-targeted
  71. @REM use).
  72. @echo off
  73. setlocal enabledelayedexpansion
  74. @rem This script will install git and conda (if not found on the PATH variable)
  75. @rem using micromamba (an 8mb static-linked single-file binary, conda replacement).
  76. @rem For users who already have git and conda, this step will be skipped.
  77. @rem This enables a user to install this project without manually installing conda and git.
  78. @rem config
  79. set MAMBA_ROOT_PREFIX=%cd%\installer_files\mamba
  80. set INSTALL_ENV_DIR=%cd%\installer_files\env
  81. set MICROMAMBA_DOWNLOAD_URL=https://github.com/easydiffusion/easydiffusion/releases/download/v1.1/micromamba.exe
  82. set umamba_exists=F
  83. set PYTHONHOME=
  84. set OLD_APPDATA=%APPDATA%
  85. set OLD_USERPROFILE=%USERPROFILE%
  86. set APPDATA=%cd%\installer_files\appdata
  87. set USERPROFILE=%cd%\installer_files\profile
  88. @rem figure out whether git and conda needs to be installed
  89. if exist "%INSTALL_ENV_DIR%" set PATH=%INSTALL_ENV_DIR%;%INSTALL_ENV_DIR%\Library\bin;%INSTALL_ENV_DIR%\Scripts;%INSTALL_ENV_DIR%\Library\usr\bin;%PATH%
  90. set PACKAGES_TO_INSTALL=git python=3.10.11 conda-forge::nodejs=22.9.0 conda pip==23.3.2 conda-forge::uv=0.4.17 conda-forge::vswhere
  91. @REM if not exist "%MAMBA_ROOT_PREFIX%\micromamba.exe" set umamba_exists=F
  92. if not exist "temp" mkdir temp
  93. call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version >%cd%\temp\tmp1 2>%cd%\temp\tmp2
  94. if "!ERRORLEVEL!" EQU "0" set umamba_exists=T
  95. @rem download micromamba
  96. if "%umamba_exists%" == "F" (
  97. echo "Downloading micromamba from %MICROMAMBA_DOWNLOAD_URL% to %MAMBA_ROOT_PREFIX%\micromamba.exe"
  98. mkdir "%MAMBA_ROOT_PREFIX%"
  99. call curl -Lk "%MICROMAMBA_DOWNLOAD_URL%" > "%MAMBA_ROOT_PREFIX%\micromamba.exe"
  100. if "!ERRORLEVEL!" NEQ "0" (
  101. echo "There was a problem downloading micromamba. Cannot continue."
  102. pause
  103. exit /b
  104. )
  105. mkdir "%APPDATA%"
  106. mkdir "%USERPROFILE%"
  107. @rem test the mamba binary
  108. echo Micromamba version:
  109. call "%MAMBA_ROOT_PREFIX%\micromamba.exe" --version
  110. )
  111. @rem create the installer env
  112. echo "Checking if the Micromamba/Conda environment is already installed."
  113. if not exist "%INSTALL_ENV_DIR%" (
  114. echo "Creating the Micromamba/Conda environment in %INSTALL_ENV_DIR%"
  115. call "%MAMBA_ROOT_PREFIX%\micromamba.exe" create -y --prefix "%INSTALL_ENV_DIR%"
  116. echo "Packages to install:%PACKAGES_TO_INSTALL%"
  117. call "%MAMBA_ROOT_PREFIX%\micromamba.exe" install -y --prefix "%INSTALL_ENV_DIR%" -c conda-forge %PACKAGES_TO_INSTALL%
  118. ) else (
  119. echo "Micromamba/Conda environment already installed in %INSTALL_ENV_DIR%, skipping installation"
  120. )
  121. if not exist "%INSTALL_ENV_DIR%" (
  122. echo "There was a problem while installing%PACKAGES_TO_INSTALL% using micromamba. Cannot continue."
  123. pause
  124. exit /b
  125. )
  126. @rem revert to the old APPDATA. only needed it for bypassing a bug in micromamba (with special characters)
  127. set APPDATA=%OLD_APPDATA%
  128. set USERPROFILE=%OLD_USERPROFILE%