Install and update pyRevit extension from a private repo

Looking into pyrevit env was like the extension wasn’t even installed (but visible in the Revit ribbon bar)… then I tried deleting manually from the default extension path in %appdata% and installing the extension again but in a different folder… It worked! :white_check_mark:

I can’t be sure without knowing the code, but I think that is connected to the default path.
I wish it will be possible to deal with all of this simply using pyRevit, or maybe editing the extensions.json like I do for the public repositories.

Renaming main to master helped here too! Thank you for clarifying that.

1 Like

Very interesting topic! At our company, we need to migrate extensions to GitHub, and with password authentication deprecating, extension manager installation will not work. I understand we can use the CLI, but most users will not be comfortable with that.

Is there any way that the extension manager can trigger an identity provider based on the extension url authication requirements (e.g. a GitHub organization that uses SAML)?

GitHub: About authentication with SAML single sign-on

you might want to fill an issue for that one on pyRevit Github @GooseG
The CLI approach can be pretty seamless if you create a batch script to do the 'pyrevit extend ui ... --token=xxxxx' using a token

Thanks @Jean-Marc for the quick response, I have created an issue here.

On the CLI approach, how would you instruct your users to collect and input their token?
Are not all these steps required?

@GooseG replying to your second question first:
the token is produced only for the github admin (or whatever github manager role)
so only once.

my approach today, with my colleagues:

  1. user installs pyrevit (could install pyrevit CLI only but that would require to clone and install pyrevit repo as an extra step (pyrevit clone …)
  2. I get them to run from the command line : pyrevit extend ui extensionName https://github.com/gituser/repoName.git --dest="C:\xxxx" --token= "6984ef654eaf6a54f65ef"

Note that I could have make a bat file to do that and provide them with a 1 click solution, but I tend to enforce the use and knowledge of the command line

  1. then I have the following code in the startup.py script at root of my extension + a button in my toolbar to automatically (or by the push of that button) update the extension content. I also have the reload button from the pyrevit toolbar
# -*- coding: UTF-8 -*-

import os

os.system('cmd /c "pyrevit extensions update extensionName --token="6984ef654eaf6a54f65ef""')

then nothing to worry about, except for the “attach” to new revit version, but luckily, you can just add that to the startup.py script to run the cli : pyrevit attach ...

2 Likes

Wondering if anybody else saw this
When using this cli feature the config file only registers the path to the top folder not to the .extension folder which causes the addin to not load
@Jean-Marc

Yes, @revitislife, and that is the exact reason my first few steps in pyRevit were so clumsy at first.
I did not see it at the time and thought that was something else.
Not the first and definitely not the last.
Learning programming and a framework feels like being a lemming

@Jean-Marc thanks for clarifying so did you end up abandoning the cli method for deploying or did you find a workaround?

never mind I can brute force it using

pyrevit extensions paths add "extension path"
1 Like

I am still using the pyrevit extend ui command
It works a treat.
my regular install process for my users is:

  1. install pyrevit if not already done
  2. run the pyrevit extend ui... command line (I install from a private github repo on C:/pyRevit folder and put all my extensions there

how about overwriting the config file on the program data? - I see the current cli only overwrites the config.ini on the AppData folder.

I haven’t had to deal with that, no idea

1 Like

realised needed to learn a little bit more of the cli syntax

@revitislife
to get by, try the --help arg in the cli:

pyrevit extend --help
pyrevit extensions --help
...
1 Like

Hi.
Ive tested with my password,
with a Fine-grained personal access token and
Personal access tokens (classic).

I get this message for all three options:

Whats the problem?

Greets.

1 Like

i have exactly the same issue , i tested with password, fine grained personal access token and personal access token classis, and nothing works for a private repo.

i then activated the github trial version of enterprise cloud , and make the repository internal, and create a fake github accoun and invited to my enterprise and tested again with the 3 methods (PW and 2 tokens) and it is not working, receiving the same error with status code : 401

can anyone guide me what i am doing wrong?

What and why it does not work:
The window for the extension management is kind of broken as Github does not accept username+password combinations anymore.
It should be redesigned both on the backend and frontend to take only tokens.

What works:
using the pyrevit cli (that comes installed with pyRevit), you can specify the token with the --token key

to install

pyrevit extend ui yourExtensionName https:\\github.com/user/repo.git --dest="C:/folder" --token=35684ger6384er63t5er635herzsh

to update

pyrevit extensions update yourExtensionName --token=35684ger6384er63t5er635herzsh

while using the cli, if you don’t know what to do with it you can always use: pyrevit **keyword** -h -h will bring the help for the keyword you want to use

when i try as you said above, i got this error, how i can solve this?
(knowing that i renamed my branch to “master” as indicated in the above replies)

Error: Could not load file or assembly 'LibGit2Sharp, Version=0.29.0.0, Culture=neutral, PublicKeyToken=7cb........................' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Run with "--debug" option to see debug messages

and when i run with --debug, i got this:

C:\Users\XXX>pyrevit extend ui XXX https:XXX.git --dest="C:/XXX" --token=XXX --debug

--token = XXX
extend = True
<extension_name> = XXX
ui = True
<repo_url> = https://XXX.git
Debug: Checking for all: wiki
Debug: Missing: wiki
Debug: Checking for all: blog
Debug: Missing: blog
Debug: Checking for all: docs
Debug: Missing: docs
Debug: Checking for all: source
Debug: Missing: source
Debug: Checking for all: youtube
Debug: Missing: youtube
Debug: Checking for all: support
Debug: Missing: support
Debug: Checking for all: env
Debug: Missing: env
Debug: Checking for all: update
Debug: Missing: update
Debug: Checking for all: clone
Debug: Missing: clone
Debug: Checking for all: clones
Debug: Missing: clones
Debug: Checking for all: attach
Debug: Missing: attach
Debug: Checking for all: detach
Debug: Missing: detach
Debug: Checking for all: attached
Debug: Missing: attached
Debug: Checking for all: switch
Debug: Missing: switch
Debug: Checking for all: extend
Debug: Checking for any: ui,lib
Debug: Matching: ui
Error: Could not load file or assembly 'LibGit2Sharp, Version=0.29.0.0, Culture=neutral, PublicKeyToken=7cb.......XXX....' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) (System.IO.FileLoadException)
   at pyRevitLabs.PyRevit.PyRevitExtensions.InstallExtension(String extensionName, PyRevitExtensionTypes extensionType, String repoPath, String destPath, String branchName, GitInstallerCredentials credentials)
   at pyRevitCLI.PyRevitCLI.ProcessArguments()
   at pyRevitCLI.PyRevitCLI.Main(String[] args)```

This bug has been fixed in some of the latest PR.
try any of the wip installers in the past week or so here:

pyRevitCI · Workflow runs · eirannejad/pyRevit

wip installers instructions

note: you will need a github account to grab the installer