Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use NuGet package in Python?

We have a NuGet package in Azure Artifacts which we would like to use in our Python code. We are able to use DLLs and also assemblies from NuGet library, in Python but here we would specifically like to use NuGet package which another team built and deployed on Azure Artifacts.

Following is the code we have been able to write so far:

import clr
import unittest

clr.AddReference("System.Security.Cryptography.Algorithms")

def test(self):
    self.assertTrue(issubclass(type(System.Security.Cryptography.MD5.Create()),System.Security.Cryptography.MD5))

unittest.main()
like image 976
Shreya Kaushik Avatar asked Sep 18 '25 06:09

Shreya Kaushik


1 Answers

You need to install the packages using NuGet command line, copy required .dll files to your project folder, and then add reference using clr.AddReferenceToFile('filePathToPackageDll').

nuget sources add -Name <SourceName> -Source <SourceURL> -username <UserName> -password <Pat>
nuget.exe restore
like image 124
Cece Dong - MSFT Avatar answered Sep 20 '25 21:09

Cece Dong - MSFT