Skip to content

Commit 833d703

Browse files
committed
Add utility to install git-lfs in userspace on Linux
1 parent 433e37b commit 833d703

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/huggingface_hub/lfs.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,26 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
import os
17+
import subprocess
18+
import sys
19+
1620

1721
LFS_MULTIPART_UPLOAD_COMMAND = "lfs-multipart-upload"
22+
23+
24+
def install_lfs_in_userspace():
25+
"""
26+
If in Linux, installs git-lfs in userspace
27+
(sometimes useful if you can't `sudo apt install` or equivalent).
28+
"""
29+
if sys.platform != "linux":
30+
raise ValueError("Only implemented for Linux right now")
31+
GIT_LFS_TARBALL = "https://github.com/git-lfs/git-lfs/releases/download/v2.13.1/git-lfs-linux-amd64-v2.13.1.tar.gz"
32+
CWD = os.path.join(os.getcwd(), "install_lfs")
33+
os.makedirs(CWD, exist_ok=True)
34+
subprocess.run(
35+
["wget", "-O", "tarball.tar.gz", GIT_LFS_TARBALL], check=True, cwd=CWD
36+
)
37+
subprocess.run(["tar", "-xvzf", "tarball.tar.gz"], check=True, cwd=CWD)
38+
subprocess.run(["bash", "install.sh"], check=True, cwd=CWD)

0 commit comments

Comments
 (0)