Example #1
0
 public CPythonInterpreterFactory(InterpreterConfiguration configuration, InterpreterFactoryCreationOptions options)
     : base(configuration, options.WatchLibraryForNewModules)
 {
 }
Example #2
0
 public AstPythonInterpreterFactory(InterpreterConfiguration config, InterpreterFactoryCreationOptions options)
     : this(config, options, string.IsNullOrEmpty(options?.DatabasePath))
 {
 }
Example #3
0
 public CPythonInterpreterFactory(InterpreterConfiguration configuration, InterpreterFactoryCreationOptions options) :
     base(configuration, options.WatchLibraryForNewModules)
 {
 }
 public IronPythonAstInterpreterFactory(Dictionary <string, object> properties) :
     this(VisualStudioInterpreterConfiguration.CreateFromDictionary(properties), InterpreterFactoryCreationOptions.FromDictionary(properties))
 {
 }
Example #5
0
        static void Main(string[] args)
        {
            var responseFile = Path.GetFullPath(args.FirstOrDefault() ?? "AnalysisMemoryTester.rsp");

            if (!File.Exists(responseFile))
            {
                if (!string.IsNullOrEmpty(responseFile))
                {
                    Console.WriteLine("Could not open {0}", responseFile);
                }
                else
                {
                    Console.WriteLine("No response file specified");
                }
                PrintUsage();
                return;
            }

            var commands = File.ReadAllLines(responseFile)
                           .Select(line => line.Trim())
                           .ToList();

            Environment.CurrentDirectory = Path.GetDirectoryName(responseFile);

            var interpreter = GetFirstCommand(commands, "python\\s+(\\d\\.\\d)\\s+(.+)", m => m.Groups[1].Value + " " + m.Groups[2].Value, v => v.Length > 4 && File.Exists(v.Substring(4).Trim()));
            var version     = Version.Parse(interpreter.Substring(0, 3));

            interpreter = interpreter.Substring(4).Trim();
            Console.WriteLine($"Using Python from {interpreter}");

            var logs = GetFirstCommand(commands, "logs\\s+(.+)", m => m.Groups[1].Value, v => PathUtils.IsValidPath(v.Trim()));

            if (!string.IsNullOrEmpty(logs))
            {
                if (!Path.IsPathRooted(logs))
                {
                    logs = Path.GetFullPath(logs);
                }
                Directory.CreateDirectory(logs);
                AnalysisLog.Output = Path.Combine(logs, "Detailed.csv");
                AnalysisLog.AsCSV  = true;
            }

            var config = new InterpreterConfiguration(
                "Python|" + interpreter,
                interpreter,
                Path.GetDirectoryName(interpreter),
                interpreter,
                interpreter,
                "PYTHONPATH",
                NativeMethods.GetBinaryType(interpreter) == System.Reflection.ProcessorArchitecture.Amd64 ? InterpreterArchitecture.x64 : InterpreterArchitecture.x86,
                version
                );

            var creationOpts = new InterpreterFactoryCreationOptions {
                UseExistingCache = false,
                WatchFileSystem  = false,
                TraceLevel       = TraceLevel.Verbose
            };

            if (!string.IsNullOrEmpty(logs))
            {
                creationOpts.DatabasePath = logs;
            }

            using (var factory = new Interpreter.Ast.AstPythonInterpreterFactory(config, creationOpts))
                using (var analyzer = PythonAnalyzer.CreateAsync(factory).WaitAndUnwrapExceptions()) {
                    var modules = new Dictionary <string, IPythonProjectEntry>();
                    var state   = new State();

                    foreach (var tuple in SplitCommands(commands))
                    {
                        RunCommand(
                            tuple.Item1,
                            tuple.Item2,
                            analyzer,
                            modules,
                            state
                            );
                    }
                }
        }
 public IronPythonAstInterpreterFactory(VisualStudioInterpreterConfiguration config, InterpreterFactoryCreationOptions options)
     : base(config, options)
 {
 }
Example #7
0
 private IronPythonAstInterpreterFactory(Dictionary <string, object> properties)
     : base(InterpreterConfiguration.FromDictionary(properties), InterpreterFactoryCreationOptions.FromDictionary(properties))
 {
 }
Example #8
0
 public IronPythonInterpreterFactory(InterpreterConfiguration config, InterpreterFactoryCreationOptions options)
     : base(config, options)
 {
 }
Example #9
0
        public static InterpreterFactoryCreationOptions FindInterpreterOptions(
            string prefixPath,
            IInterpreterOptionsService service,
            IPythonInterpreterFactory baseInterpreter = null
            )
        {
            var result = new InterpreterFactoryCreationOptions();

            var libPath = FindLibPath(prefixPath);

            result.PrefixPath  = prefixPath;
            result.LibraryPath = libPath;

            if (baseInterpreter == null)
            {
                baseInterpreter = FindBaseInterpreterFromVirtualEnv(prefixPath, libPath, service);
            }

            string interpExe, winterpExe;

            if (baseInterpreter != null)
            {
                // The interpreter name should be the same as the base interpreter.
                interpExe                          = Path.GetFileName(baseInterpreter.Configuration.InterpreterPath);
                winterpExe                         = Path.GetFileName(baseInterpreter.Configuration.WindowsInterpreterPath);
                result.InterpreterPath             = FindFile(prefixPath, interpExe);
                result.WindowInterpreterPath       = FindFile(prefixPath, winterpExe);
                result.PathEnvironmentVariableName = baseInterpreter.Configuration.PathEnvironmentVariable;
            }
            else
            {
                result.InterpreterPath             = string.Empty;
                result.WindowInterpreterPath       = string.Empty;
                result.PathEnvironmentVariableName = string.Empty;
            }

            if (baseInterpreter != null)
            {
                result.Description = string.Format(
                    "{0} ({1})",
                    CommonUtils.GetFileOrDirectoryName(prefixPath),
                    baseInterpreter.Description
                    );

                result.Id = baseInterpreter.Id;
                result.LanguageVersion           = baseInterpreter.Configuration.Version;
                result.Architecture              = baseInterpreter.Configuration.Architecture;
                result.WatchLibraryForNewModules = true;
            }
            else
            {
                result.Description = CommonUtils.GetFileOrDirectoryName(prefixPath);

                result.Id = Guid.Empty;
                result.LanguageVersion           = new Version(0, 0);
                result.Architecture              = ProcessorArchitecture.None;
                result.WatchLibraryForNewModules = false;
            }

            return(result);
        }
 internal AstPythonInterpreterFactory(Dictionary <string, object> properties) :
     this(InterpreterConfiguration.FromDictionary(properties), InterpreterFactoryCreationOptions.FromDictionary(properties))
 {
 }