Install and update pyRevit extension from a private repo

Hi everyone,
sorry for opening an old post but I found this very interesting and I wasn’t able to let the above hints work.

In the Command Prompt I wrote this code:

pyrevit extend ui extensionName https://github.com/GiuseppeDotto/myPrivateRepository.git --dest=“C:\Users\giuse\AppData\Roaming\pyRevit\Extensions” --token=“tokenOfMyAccount”

but doesn’t work and returns

Error: reference ‘refs/remotes/origin/master’ not found

What am I doing wrong? :no_mouth:
Thank you for the helping!

try with debug for more explicit error
--debug
maybe you master branch not being named master?

1 Like

Hi @Jean-Marc , thanks for answering. That was the problem.
By default, the GitHub branch was named “main”, renaming it to “master” all worked very fine.

Though I am not seeing the extension from the extension manager in pyRevit and when I try to update it with the command line

pyrevit extensions update extensionName --token=“tokenOfMyAccount”

it returns the following error:

Error: Installed extension “extensionName” not found. (pyRevitLabs.Common.PyRevitException)
… at pyRevitLabs.PyRevit.PyRevitExtensions.GetInstalledExtension(String searchPattern)
… at pyRevitCLI.PyRevitCLI.ProcessArguments()
… at pyRevitCLI.PyRevitCLI.Main(String args)

Maybe is because I download the repository content at the default path %appdata%\pyRevit\Extensions ?

it should not be an issue. I bumped into the pb several time due to typos in the extension name.
try a pyrevit env to make sure you have the proper extension name

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