python Sphinx not recognizing modules inside project - python-sphinx

I am trying to create autodoc for my python project. the problem is that when I am trying to do make html it's not working...
my project tree looks like -
- docs
- EDA_miner
When the EDA miner contains all the code
https://pasteboard.co/If8dT8AS.png - project tree
in the sphinx's conf.py I configured like -
sys.path.insert(0, os.path.abspath('../..'))
but when I am trying to generate using make html I get
WARNING: autodoc: failed to import module 'app' from module 'EDA_miner';
the following exception was raised:
No module named 'server'
WARNING: autodoc: failed to import module 'menus' from module 'EDA_miner';
the following exception was raised:
No module named 'server'
when I am opening ipython and importing server.py it succeed, how am I doing wrong ?

Make to run make html from within your virtual environment (or just be sure to have all your python dependencies installed)

Related

Go Dependency Error in SAM application when building with AWS Toolkit

I have a SAM application that has several endpoints (with their own module) and a seperate module in the same project that has helper functions, services etc.
When building the project with sam build, which should build and deploy all endpoints at once, it causes an error in the build process. The dependencies are definitely included in all related go.mod/go.sum files.
Here's the error:
Running GoModulesBuilder:Build
Build Failed
Error: GoModulesBuilder:Build - Builder Failed: ..\..\service\matchService.go:10:2: missing go.sum entry for module providing package github.com/aws/aws-sdk-go/aws (imported by testmodule/service); to add:
go get testmodule/service#v1.0.0
..\..\service\matchService.go:11:2: missing go.sum entry for module providing package github.com/aws/aws-sdk-go/aws/session (imported by testmodule/service); to add: go get testmodule/service#v1.0.0
If I execute sam build in the endpoint folder directly it works flawless however!
This is the basic folder structure of the project:
/api/matches/endpoint-a/main.go
/api/matches/endpoint-a/go.mod <- requires matchService of "testmodule" which lies in /, also requires aws-sdk-go indirectly
/api/matches/endpoint-a/go.sum
/services/matchService
/go.mod <- requires github.com/aws/aws-sdk-go/aws
/go.sum
/template.yaml <- includest AWS::Serverless::Function for endpoint-a

golang module name change causes local tests to fail

I have a fork of someone's code. Their module name is formatted like so:
module github.com/foo/bar/v3
I've made some changes locally and have updated the local go.mod to be v4 instead of v3 but this now causes the running of the tests locally to fail (see below, I've genericized the output).
Note: the go.sum at this point is empty.
$ go test -v
go: finding module for package github.com/foo/bar/v3
go: found github.com/foo/bar/v3 in github.com/foo/bar/v3 v3.0.0
# github.com/foo/bar/v4_test [github.com/foo/bar/v4.test]
./some_test.go:232:19: x.Y undefined (type *package.Example has no field or method Y)
FAIL github.com/foo/bar/v4 [build failed]
I'm not sure why it's trying to locate the actual v3 version of the package, and thus updating the go.sum to include it?
I can see from the test file that this package uses a different package name (e.g. package foo_test) so it doesn't rely on the exported data structures to exist when writing their test code. So maybe that's why this happens? it sees the reference to x.Y and then goes to lookup x in github.
But then I'm not sure why the test would run fine when I was using the v3 reference in the go.mod file?
Any ideas on what's happening here and what the right process should be for bumping a go module when you're working on a forked project?
Thanks.
If you change your module name in go.mod file, you have to replace all your import path with the updated module name.
As you replaced your module github.com/foo/bar/v3 with github.com/foo/bar/v4, you must find and replace all your reference of github.com/foo/bar/v3 with github.com/foo/bar/v4 throughout the whole project.
Then your $ go test -v should run properly.

How to add numpy to required dependencies in autodoc

I get an error when trying to generate the documentation in readthedocs.org, autodoc is failing to import a set of functions with the following error message:
WARNING: autodoc: failed to import function 'open_template' from module 'pypyt'; the following exception was raised:
Missing required dependencies ['numpy']
I'm using the requirements file, so the environment is actually installing numpy. I've tried to mock it, autodoct_mock_imports, autodoct_warningiserro, suppress_warnings, but no has worked.
The conf.py file I use is in the repo below
https://github.com/llulai/pypyt/blob/master/docs/conf.py
Anything I haven't tried yet?
thanks
ps: when I run it locally, it works without any problems

Go module init without VCS/Git fails with cannot determine module path

I'm trying to initialize a new go project with go module (using go 1.11). I don't plan to publish it in github or elsewhere, it is just a temporary/test project with only main package.
Whenever I try to run go mod init in a directory (that's outside my $GOPATH), I get this error:
go: cannot determine module path for source directory /Users/... (outside GOPATH, no import comments)
Is it not possible to init module without using git (or other VCS)? Or is there any workaround?
Is it not possible to init module without using git (or other VCS)? Or
is there any workaround?
Yes, it is possible to init the modules without using VSC, initializing the module does not have to do anything with git or any other VCS.
This error occurs when the module name is not entered while init the module so to generate a module modulename write this command.
$ go mod init modulename
The content of the go.mod would be
module modulename
EDIT:
To use the modules from local repository use the replace directive
In your main module where you are checking your local module add the following lines
replace "X" v0.0.0 => "{location To your local module}"
require "X" v0.0.0
And then in your main project, import package util from module X you can simply do:
import "X/util"
Now when you will do go build it will look for this local module on the location you have given in the mod file of the main project.
For more explanation

Swift app: “Missing required module” when importing framework that imports static library

Here’s my setup:
Static library of Objective C code called Stat.
A Swift framework that uses code from Stat in its own classes (this framework is called Dyn). The static library and this framework are in the same Xcode project.
A Mac app / project that has the above project as a subproject and which links to Dyn.
In my app I have code like:
import Cocoa
import Dyn
...
SomeDynClass().doSomething()
However, when I try to compile I get an error when I import Dyn. The error is
error: missing required module ‘Stat'
It appears my app can find my framework just fine, but it somehow needs to find a module for my static library, too?
Stat has a module file that’s pretty basic:
module Stat {
header "Stat.h"
export *
}
I think I need to point my Mac app’s framework search paths at Stat but I don’t know why and I don’t know how. How do I solve this?
Select your Target, then go into Build Settings and set the Import Paths within the Swift Compiler - Search Paths section:
${SRCROOT}/Stat
Normally the module would be named the same as the library, however, I'm not sure how you've setup the directory with the module.map (it could be named Dyn perhaps, in which case the Import Path would reflect that name.
Build Settings > Swift Compiler > Search Paths:
${SRCROOT}/(directory with module.map) should resolve itself once
you press enter or tab..
I got the same error when in my unit tests project which involves SQLite3 package. After I add the package, unit tests always throw out error saying "missing required module SQLiteObjc"
I had it fixed by toggle "Force Package Info Generation" on and off in my Unit Tests Target's build setting

Resources