{"modulePath":"github.com/siddharthab/bazel-gazelle-python","version":"v0.0.0-20230622012118-abfd5953dc9a","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package python\n\n## Functions\n\n```go\nfunc NewLanguage() language.Language\n```\n\n## Types\n\n```go\ntype Configuration struct {\n\t// Enable the Python Gazelle language extension.\n\tEnable bool\n\t// Root directory for Python code.\n\tRootDir string\n\t// Python package path (slash separated); its value is Bazel package path\n\t// relative to RootDir. If this starts with '..', then it means we have not\n\t// yet reached the Python workspace.\n\tPythonPackagePath string\n\t// List of modules internal to the interpreter, whether part of stdlib, or\n\t// available as a system installation. A common default for such a list\n\t// would be given by\n\t// `python3 -c \"import sys; print(sorted(sys.stdlib_module_names))\"`.\n\tInternalModuleList map[string]struct{}\n\t// Path to list (one per line; comment char '#') of internal modules.\n\t// Functions as a caching key for InternalModuleList.\n\tInternalModuleListPath string\n\t// Map of import specifiers for external module names to their sources.\n\tExternalModuleMap map[string]ExternalModule\n\t// Path to map of external modules from where ExternalModuleMap is\n\t// read. Functions as a caching key for ExternalModuleMap.\n\tExternalModuleMapPath string\n\t// Name prefix under which the external repositories are defined, e.g. \"pip_\".\n\tExternalRepoNamePrefix string\n\t// Name template to use for naming targets.\n\tNameTemplate string\n}\n```\nConfiguration is configuration for the Python language extension. A default configuration is set through command line flags and their default values. Each directory gets its own copy and the values may be changed by Configurer.Configure().\n\n```go\ntype Configurer struct {\n\t// contains filtered or unexported fields\n}\n```\nConfigurer manages the configuration at root and for each subdirectory.\n\n```go\nfunc (pc *Configurer) CheckFlags(fs *flag.FlagSet, c *config.Config) error\n```\nCheckFlags implements config.Configurer.\n\nIt performs any resource initialization based on the flags, validates the initial configuration, and sets the configuration extension.\n\n```go\nfunc (pc Configurer) Configure(c *config.Config, rel string, f *rule.File)\n```\nConfigure implements config.Configurer.\n\n```go\nfunc (pc Configurer) KnownDirectives() []string\n```\nKnownDirectives implements config.Configurer.\n\n```go\nfunc (pc *Configurer) RegisterFlags(fs *flag.FlagSet, cmd string, c *config.Config)\n```\nRegisterFlags implements config.Configurer.\n\nIt registers the flags to their relevant fields in an initial copy of the Configuration object. The configuration extension is not set yet.\n\n```go\ntype ExternalModule struct {\n\tDist        string // Distribution name.\n\tPkgPath     string // A slash separated path to the package.\n\tModule      string // Name of the module, can be blank for __init__.py (but not when PkgPath is also blank).\n\tBazelTarget string // Bazel target for this import.\n\tType        string // py or so (currently not relevant).\n}\n```\nExternalModule is a Python module available from an external distribution.\n\n```go\ntype Language struct {\n\tConfigurer\n\tResolver\n}\n```\n\n```go\nfunc (l *Language) Fix(c *config.Config, f *rule.File)\n```\nFix implements language.Language.\n\n```go\nfunc (l *Language) GenerateRules(args language.GenerateArgs) language.GenerateResult\n```\nGenerateRules implements language.Language.\n\nGenerates one py\\_library (or py\\_binary) rule for each Python module, including one for \\_\\_init\\_\\_.py with name as the last component of the Python package name. If modules within a package depend on each other, then their src files are included in multiple rules, which allows us to have cyclical dependencies in the package. The inefficiency of repeating src files is expected to be minor because py\\_library is a very thin implementation. An alternative would be to disallow cycles and not repeat src files and depend on the rules for the modules, with the possible exception for \\_\\_init\\_\\_.py where cycles are common.\n\nEach module also depends on the py\\_library rule for the package \\_\\_init\\_\\_.py, and the package \\_\\_init\\_\\_.py depends on its parent package \\_\\_init\\_\\_.py.\n\nREQUIRES: No cyclical dependencies across packages.\n\nREQUIRES: This is not a split namespace package.\n\nREQUIRES: PYTHONSAFEPATH is enabled.\n\n```go\nfunc (l *Language) Kinds() map[string]rule.KindInfo\n```\nKinds implements language.Language.\n\n```go\nfunc (l *Language) Loads() []rule.LoadInfo\n```\nLoads implements language.Language.\n\n```go\ntype Module struct {\n\tparser.Result\n\tImportSpec   string\n\tPkgPath      string\n\tName         string\n\tFilename     string\n\tInPkgDeps    map[*Module]struct{} // Module deps within the package.\n\tExPkgImports []string             // Import statements not satisfied from within the package.\n}\n```\nModule represents a parsed Python module.\n\n```go\nfunc (module *Module) DepsClosure()\n```\nDepsClosure expands the ModuleDeps to get all transitive deps.\n\n```go\nfunc (module Module) GenerateRule(nameTemplate, relPythonRoot string) *rule.Rule\n```\n\n```go\nfunc (module *Module) ProcessImports(moduleMap map[string]*Module, subPackages map[string]struct{})\n```\nProcessImports computes direct InPkgDeps and ExPkgImports.\n\n```go\ntype Resolver struct{}\n```\n\n```go\nfunc (pr Resolver) Embeds(r *rule.Rule, from label.Label) []label.Label\n```\nEmbeds implements resolve.Resolver.\n\n```go\nfunc (pr Resolver) Imports(c *config.Config, r *rule.Rule, f *rule.File) []resolve.ImportSpec\n```\nImports implements resolve.Resolver.\n\nReturns all Python module import specs defined by the files in \"srcs\" attribute.\n\n```go\nfunc (pr Resolver) Name() string\n```\nName implements resolve.Resolve.\n\n```go\nfunc (pr Resolver) Resolve(c *config.Config, ix *resolve.RuleIndex, _ *repo.RemoteCache, r *rule.Rule, imports interface{}, from label.Label)\n```\nResolve implements resolve.Resolver.\n\n","path":"github.com/siddharthab/bazel-gazelle-python/python","name":"python","synopsis":"","isRedistributable":true}
