示例#1
0
 public override bool Equals(object obj)
 {
     if (obj is PythonVersion)
     {
         PythonVersion ver = (PythonVersion)obj;
         return((ver.Major == this.Major) && (ver.Minor == this.Minor) && (ver.Bugfix == this.Bugfix));
     }
     else
     {
         return(false);
     }
 }
示例#2
0
        public PythonInstance(dynamic PyInstance)
        {
            Version      = new PythonVersion(PyInstance.Version);
            Architecture = (CpuArchitecture)Enum.Parse(typeof(CpuArchitecture), PyInstance.Architecture.ToString(), true);
            List <PythonWheel> newWheels = new List <PythonWheel>();
            dynamic            wheels    = PyInstance.Wheels;

            foreach (dynamic wheel in wheels)
            {
                newWheels.Add(new PythonWheel(wheel));
            }
            Wheels = newWheels;
        }
示例#3
0
 public IEnumerable <PythonWheel> GetWheels(PythonVersion PyVersion, CpuArchitecture CpuArch)
 {
     foreach (SubstitutablePythons SubPyInstaller in Pythons)
     {
         foreach (PythonInstance PyInstaller in SubPyInstaller.PythonInstances)
         {
             if ((PyInstaller.Version == PyVersion) && (PyInstaller.Architecture == CpuArch))
             {
                 return(PyInstaller.Wheels);
             }
         }
     }
     throw new ArgumentException("Python Version not found");
 }
        private static List <PythonPackage> ParseLegacyPipList(string PipLegacyList)
        {
            List <PythonPackage> PythonPackages = new List <PythonPackage>();
            IEnumerable <string> packageStrings = PipLegacyList.SplitLines();

            foreach (string packageString in packageStrings)
            {
                string pattern = @"(\S+)\s*\((\S+)\)";
                Match  match   = Regex.Match(packageString, pattern);
                if (match.Success)
                {
                    string        packageName   = match.Groups[1].Value;
                    string        versionString = match.Groups[2].Value;
                    PythonVersion version       = new PythonVersion(0, 0, 0);
                    pattern = @"(\d+)\.(\d+)\.(\d+)";
                    match   = Regex.Match(versionString, pattern);
                    if (match.Success)
                    {
                        version = new PythonVersion(Int32.Parse(match.Groups[1].Value), Int32.Parse(match.Groups[2].Value), Int32.Parse(match.Groups[3].Value));
                    }
                    else
                    {
                        pattern = @"(\d+)\.(\d+)";
                        match   = Regex.Match(versionString, pattern);
                        if (match.Success)
                        {
                            version = new PythonVersion(Int32.Parse(match.Groups[1].Value), Int32.Parse(match.Groups[2].Value), 0);
                        }
                        else
                        {
                            pattern = @"(\d+)";
                            match   = Regex.Match(versionString, pattern);
                            if (match.Success)
                            {
                                version = new PythonVersion(Int32.Parse(match.Groups[1].Value), 0, 0);
                            }
                        }
                    }
                    PythonPackage package = new PythonPackage();
                    package.Name    = packageName;
                    package.Version = version;
                    PythonPackages.Add(package);
                }
            }
            return(PythonPackages);
        }
        private static List <PythonPackage> ParseJsonPipList(string PipJsonList)
        {
            List <PythonPackage> PythonPackages = new List <PythonPackage>();
            JSONNode             json           = JSON.Parse(PipJsonList);

            if (json == null)
            {
                throw new ArgumentException("Pip list JSON failed to parse.");
            }
            if (!json.IsArray)
            {
                throw new ArgumentException(string.Format("Pip list root JSON type is not list type"));
            }
            JSONArray array = json.AsArray;

            foreach (JSONNode node in array)
            {
                if (!node.IsObject)
                {
                    InstallLogger.Log(string.Format("Found unexpected json node {0}", node.Value));
                    continue;
                }
                Dictionary <string, JSONNode> jsonObject = node.Linq.ToDictionary(x => x.Key, x => x.Value);
                if (!jsonObject.ContainsKey("name") ||
                    !jsonObject.ContainsKey("version"))
                {
                    InstallLogger.Log(string.Format("Found unexpected json node {0}", node.Value));
                    continue;
                }
                string        versionString = jsonObject["version"].Value;
                PythonVersion version       = new PythonVersion(0, 0, 0);
                string        pattern       = @"(\d+)\.(\d+)\.(\d+)";
                Match         match         = Regex.Match(versionString, pattern);
                if (match.Success)
                {
                    version = new PythonVersion(Int32.Parse(match.Groups[1].Value), Int32.Parse(match.Groups[2].Value), Int32.Parse(match.Groups[3].Value));
                }
                else
                {
                    pattern = @"(\d+)\.(\d+)";
                    match   = Regex.Match(versionString, pattern);
                    if (match.Success)
                    {
                        version = new PythonVersion(Int32.Parse(match.Groups[1].Value), Int32.Parse(match.Groups[2].Value), 0);
                    }
                    else
                    {
                        pattern = @"(\d+)";
                        match   = Regex.Match(versionString, pattern);
                        if (match.Success)
                        {
                            version = new PythonVersion(Int32.Parse(match.Groups[1].Value), 0, 0);
                        }
                    }
                }
                PythonPackage package = new PythonPackage();
                package.Name    = jsonObject["name"].Value;
                package.Version = version;
                PythonPackages.Add(package);
            }

            return(PythonPackages);
        }
示例#6
0
 public bool Equals(PythonVersion other)
 {
     return(Equals(other, this));
 }
示例#7
0
 public PythonVersion(PythonVersion PyVersion)
 {
     Major  = PyVersion.Major;
     Minor  = PyVersion.Minor;
     Bugfix = PyVersion.Bugfix;
 }
示例#8
0
 public PythonPackage(dynamic PyPackage)
 {
     Version = new PythonVersion(PyPackage.Version);
     Name    = PyPackage.Name;
 }