"Package init file not found (or not a regular file)" - error when building sdist for namespace package - python-3.x

I have a namespace package with folder structure as:
CompanyName\DepartmentName\SubDepartmentName\PkgName
Python 3.3 onwards supports namespace packages so I have not place the __init__.py files in the following folders:
CompanyName
DepartmentName
SubDepartmentName
In the setup.py I have place the following piece of code setuptools.find_namespace_packages() instead of setuptools.find_packages().
When I try to build the sdist, using the following commands:
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools wheel
python setup.py sdist
I get the following error:
package init file 'CompanyName\__init__.py' not found (or not a regular file)
package init file 'CompanyName\DepartmentName\__init__.py' not found (or not a regular file)
package init file 'CompanyName\DepartmentName\SubDepartmentName\__init__.py' not found (or not a regular file)
I have the task setup as part of azure devops pipeline's command line task and have set 'Fail on standard error' to true. The pipeline fails due to the above error.

Though Package init file not found (or not a regular file) is more like a warning than an error locally, it will cause the build pipeline to fail if you set Fail on standard error to true when using VSTS.
Locally:
VSTS with Fail on standard error to default false:
VSTS with Fail on standard error to true:
1.For this, you can choose to turn-off the option(Fail on standard error) cause the python namespace package can be generated successfully though that message occurs. So in this situation, I think you can suppress that message.
2.Also, another direction is to resolve the message when generating the package. Since the cause of the message has something to do with your definitions in your setup.py file, you should use setuptools.find_namespace_packages() like this document suggests.
Because mynamespace doesn’t contain an init.py, setuptools.find_packages() won’t find the sub-package. You must use setuptools.find_namespace_packages() instead or explicitly list all packages in your setup.py.
In addition: It's not that recommended to remove all __init__.py files in packages, check this detailed description from AndreasLukas: If you want to run a particular initialization script when the package or any of its modules or sub-packages are imported, you still require an init.py file.

Related

Ignoring specific child dependency while building a python package

I am using APScheduler to run some background tasks periodically and I use python 3.8.10
but with our pyproject.toml based projects build fails to add this dependency(APScheduler==3.9.1) from requirement.txt with the following error
*ERROR: Could not build wheels for backports.zoneinfo, which is required to install pyproject.toml-based projects
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1*
It looks like the backports.zoneinfo expects the python version to be 3.8.9 but we use 3.8.10 and they recommend us to ignore backports.zoneinfo;python_version<"3.9" but not sure how can i do that using project.toml or tox.ini file that uses requirements.txt. i just want to ignore this child dependency library backports.zoneinfo from APAscheduler, Any idea?

publish packages in conda forge receive error 'MY PACKAGE requires pathlib, which is not installed'

This is quite strange as pathlib seems already built in python > 3.4, anyone got an idea what raises the error?
ps. Package is already in pypi, the recipe was created directly from grayskull.

Error from Azure function: ModuleNotFoundError

I followed the official documentation to set up my requirements.txt file. My understanding was that the function should be able to use modules if they are in requirements.txt. Here is an example of what that file looks like, with all the modules and their versions written in this way:
azure-common==1.1.12
azure-keyvault==1.0.0
azure-mgmt-keyvault==1.0.0
azure-mgmt-nspkg==2.0.0
azure-mgmt-resource==1.2.2
azure-storage-blob==12.3.1
azure-mgmt-subscription==0.5.0
azure-mgmt-network==10.2.0
azure-functions==1.2.1
However, when I look at the function's logs, I can see that it keeps throwing the error, "ModuleNotFoundError: No module named 'azure.common'". This is the first module I try to import in __init__.py. What am I doing wrong?
It seems the modules you use in your function are all old version(such as azure-common==1.1.12, azure-keyvault==1.0.0.....). So could you please install the modules with the latest version. You can search them on this page and for example if install the latest azure-common module, just run the command pip install azure-common(no need the version number) it will install the latest version of the module.
And then use the command below in your VS code to generate the "requirements.txt" automatically.
pip freeze > requirements.txt
Then deploy the function code from local to azure by the command:
func azure functionapp publish <function app name> --build remote
It will deploy the code to azure and install the modules according to the content in the "requirements.txt" which you generated just now.
Hope it helps~

Installing a package with cabal doesn't work (random)

I'm using Windows 10. I downloaded Cabal.exe, put it in my ghc-8.8.1\bin\ directory and ran it with command cabal update. It did nothing for a while, then it ended without any messages.
Now when I run cabal install random (trying to install package "random"), I get the following error:
cabal: Error: Could not find module: System.Random with any suffix:
["gc","chs","hsc","x","y","ly","cpphs","hs","lhs","hsig","lhsig"]. If the
module is autogenerated it should be added to 'autogen-modules'.
I have no clue why it does this.
I also tried installing the package manually (following the steps from here) - downloaded package random-1.1.tar.gz and ran:
cd filepathtopackage
c:\Program Files\Apps\ghc-8.8.1\bin\runhaskell.exe Setup configure
This for a change gives me the following error:
| C:\Program Files\Apps\ghc-8.8.1\lib\Cabal-3.0.0.0\HSCabal-3.0.0.0.o: unknown symbol '.file'
Setup: Setup: unable to load package 'Cabal-3.0.0.0'
When I run ghc-pkg list, Cabal is in there, so again, no clue why it does this.
Does anyone have any tips on how to resolve this?

CFFI compiled libpango with dependencies? (thai/fribidi/datrie)

I'm trying to setup a precompiled package for aws lambda, which must contain all the required libraries inside it.
My dependencies are : pango and cairo
So, what I did was go to https://fedora.pkgs.org and download the 64 versions of those, but then when I first executed my code (WeasyPrint/cffi) it gave me the following :
OSError: cannot load library 'pango-1.0': libthai.so.1: cannot open
shared object file: No such file or directory. Additionally,
ctypes.util.find_library() did not manage to locate a library called
'pango-1.0'
So I just went the the same website mentioned above, downloaded libthai, and then it gave the same error for libfridi, and then for libdatrie.
I'm just afraid this will never stop, is there any compiled pango with all these dependencies?
Worth nothing that I have absolute no clue what I'm doing, just sorta trying to get this to work.

Resources