Compiling PyQt5 App with QtWebEngine - qt

I've been trying to compile an app that uses the QtWebEngine from PyQt5. The app works as intended but it fails when compiling. I've spent a couple of days looking for solution but so far I had no luck. I've installed python from both brew and downloading the package form it's website. I've also installed PyQt5 form brew and pip3 without any luck. After running the pyinstaller script I get the "cannot find QtWebEngineProcess" error. That's fixed by copying the QtWebEngineProcess.app file into the MacOS folder. Subsequentially I made sure that the info.plist file is not a symlink but the actual file. Afterwards I added the "org.qt-project.Qt.QtWebEngineCore" flag to the "CFBundleIdentifier" in the main app info.plist. This resolves the problem of not finding "QtWebEngineProcess" but it brings now the error stated below. I copied the "icudtl.dat" to the MacOS folder as well. I also tried rebuilding the dependencies with the framework itself and making sure I don't have symlinks like stated here. I'm not familiar with the install_name_tool so I'm stuck there. Any ideas? Is anyone able to compile a pyqt app using QtWebEngine at all?
Here's the error I'm facing:
[0201/130544:ERROR:icu_util.cc(162)] Invalid file descriptor to ICU data received.
[0201/130544:FATAL:content_main_runner.cc(714)] Check failed: base::i18n::InitializeICU().
0 QtWebEngineCore 0x000000010d4b62e3 _ZN15QtWebEngineCore20FilePickerController11qt_metacallEN11QMetaObject4CallEiPPv + 12132083
1 QtWebEngineCore 0x000000010d4c9809 _ZN15QtWebEngineCore20FilePickerController11qt_metacallEN11QMetaObject4CallEiPPv + 12211225
2 QtWebEngineCore 0x000000010ce7cb03 _ZN15QtWebEngineCore20FilePickerController11qt_metacallEN11QMetaObject4CallEiPPv + 5605139
3 QtWebEngineCore 0x000000010c918ee4 _ZN15QtWebEngineCore18WebContentsAdapter14faviconManagerEv + 28052
4 QtWebEngineCore 0x000000010c917f48 _ZN15QtWebEngineCore18WebContentsAdapter14faviconManagerEv + 24056
5 QtWebEngineCore 0x000000010c90e3b9 _ZN15QtWebEngineCore18WebContentsAdapterC2EPN7content11WebContentsE + 57
6 QtWebEngineWidgets 0x000000011113ce4e _ZrsR11QDataStreamR17QWebEngineHistory + 1870
7 QtWebEngineWidgets 0x000000011113ec20 _ZN14QWebEnginePageC1EP7QObject + 48
8 QtWebEngineWidgets 0x000000011114ad17 _ZN14QWebEngineView6setUrlERK4QUrl + 55
9 PyQt5.QtWebEngineWidgets.so 0x0000000111100ca3 _ZL26meth_QWebEngineView_setUrlP7_objectS0_ + 99
10 Python 0x00000001080faae9 PyCFunction_Call + 233
11 Python 0x0000000108187a81 PyEval_EvalFrameEx + 35729
12 Python 0x00000001081884fc PyEval_EvalFrameEx + 38412
13 Python 0x0000000108188e90 _PyEval_EvalCodeWithName + 2400
14 Python 0x0000000108188f97 PyEval_EvalCodeEx + 71
15 Python 0x00000001080d577a function_call + 186
16 Python 0x00000001080a28d3 PyObject_Call + 99
17 Python 0x00000001080bd9cc method_call + 140
18 Python 0x00000001080a28d3 PyObject_Call + 99
19 Python 0x00000001081184c1 slot_tp_init + 81
20 Python 0x000000010810ef44 type_call + 212
21 Python 0x00000001080a28d3 PyObject_Call + 99
22 Python 0x0000000108182b65 PyEval_EvalFrameEx + 15477
23 Python 0x0000000108188e90 _PyEval_EvalCodeWithName + 2400
24 Python
0x0000000108188ff1 PyEval_EvalCode + 81
25 Sailor 0x0000000106e52490 Sailor + 9360
26 Sailor 0x0000000106e529f9 Sailor + 10745
27 Sailor 0x0000000106e51464 Sailor + 5220
28 ??? 0x0000000000000003 0x0 + 3
Trace/BPT trap: 5

It worked for me after using this branch and adding some custom patching:
def patch_osx_app():
"""Patch .app to copy missing data and link some libs.
See https://github.com/pyinstaller/pyinstaller/issues/2276
"""
app_path = os.path.join('dist', 'qutebrowser.app')
qtwe_core_dir = os.path.join('.tox', 'pyinstaller', 'lib', 'python3.6',
'site-packages', 'PyQt5', 'Qt', 'lib',
'QtWebengineCore.framework')
# Copy QtWebEngineProcess.app
proc_app = 'QtWebEngineProcess.app'
shutil.copytree(os.path.join(qtwe_core_dir, 'Helpers', proc_app),
os.path.join(app_path, 'Contents', 'MacOS', proc_app))
# Copy resources
for f in glob.glob(os.path.join(qtwe_core_dir, 'Resources', '*')):
dest = os.path.join(app_path, 'Contents', 'Resources')
if os.path.isdir(f):
shutil.copytree(f, os.path.join(dest, f))
else:
shutil.copy(f, dest)
# Link dependencies
for lib in ['QtCore', 'QtWebEngineCore', 'QtQuick', 'QtQml', 'QtNetwork',
'QtGui', 'QtWebChannel', 'QtPositioning']:
dest = os.path.join(app_path, lib + '.framework', 'Versions', '5')
os.makedirs(dest)
os.symlink(os.path.join(os.pardir, os.pardir, os.pardir, 'Contents',
'MacOS', lib),
os.path.join(dest, lib))

It`s some problem with the QtWebEngine. I believed that exists patch to fix this bug.
You can see other informations in https://github.com/pyinstaller/pyinstaller/issues/2566

The files:
icudtl.dat
qtwebengine_devtools_resources.pak
qtwebengine_resources.pak
qtwebengine_resources_100p.pak
qtwebengine_resources_200p.pak
need to be in .app/Contents/Resources

Related

Karaf `framework.BundleException` on bin/karaf on macos

I installed karaf on my mac for the second time now. The first time I couldn't get the console to connect whenever I would start the runtime (bin/karaf and bin/start/stop) and nada. bin/client wouldn't connect either.
After uninstalling and installing v4.3.6 and then v.4.2.15, I now get the following error whenever trying to fire up karaf:
apache-karaf-4.2.15 /Users/augustoibarrola/Development/apache-karaf-4.2.15/bin/karaf
ERROR: Error parsing system bundle export statement: org.osgi.dto;version="1.0",org.osgi.resource;version="1.0",org.osgi.resource.dto;version="1.0";uses:="org.osgi.dto",org.osgi.framework;version="1.8",org.osgi.framework.dto;version="1.8";uses:="org.osgi.dto",org.osgi.framework.hooks.bundle;version="1.1";uses:="org.osgi.framework",org.osgi.framework.hooks.resolver;version="1.0";uses:="org.osgi.framework.wiring",org.osgi.framework.hooks.service;version="1.1";uses:="org.osgi.framework",org.osgi.framework.hooks.weaving;version="1.1";uses:="org.osgi.framework.wiring",org.osgi.framework.launch;version="1.2";uses:="org.osgi.framework",org.osgi.framework.namespace;version="1.1";uses:="org.osgi.resource",org.osgi.framework.startlevel;version="1.0";uses:="org.osgi.framework",org.osgi.framework.startlevel.dto;version="1.0";uses:="org.osgi.dto",org.osgi.framework.wiring;version="1.2";uses:="org.osgi.framework,org.osgi.resource",org.osgi.framework.wiring.dto;version="1.2";uses:="org.osgi.dto,org.osgi.resource.dto",org.osgi.service.condpermadmin;version="1.1.1";uses:="org.osgi.framework,org.osgi.service.permissionadmin",org.osgi.service.packageadmin;version="1.2";uses:="org.osgi.framework",org.osgi.service.permissionadmin;version="1.2",org.osgi.service.resolver;version="1.0";uses:="org.osgi.resource",org.osgi.service.startlevel;version="1.1";uses:="org.osgi.framework",org.osgi.service.url;version="1.0",org.osgi.util.tracker;version="1.5.1";uses:="org.osgi.framework",org.apache.karaf.version;version="4.2.15",org.apache.karaf.jaas.boot.principal;uses:=javax.security.auth;version="4.2.15",org.apache.karaf.jaas.boot;uses:="javax.security.auth,javax.security.auth.callback,javax.security.auth.login,javax.security.auth.spi,org.osgi.framework";version="4.2.15",org.apache.karaf.info;version="4.2.15",,org.apache.karaf.branding, sun.misc, com.sun.jmx.remote.protocol, com.sun.jmx.remote.protocol.jmxmp, org.apache.karaf.diagnostic.core;uses:=org.osgi.framework;version=4.2.15, org.apache.karaf.diagnostic.core.common;uses:=org.apache.karaf.diagnostic.core;version=4.2.15, org.apache.karaf.jaas.boot.principal;uses:=javax.security.auth;version=4.2.15, org.apache.karaf.jaas.boot;uses:="javax.security.auth,javax.security.auth.callback,javax.security.auth.login,javax.security.auth.spi,org.osgi.framework";version=4.2.15
org.osgi.framework.BundleException: Exported package names cannot be zero length.
at org.apache.felix.framework.util.manifestparser.ManifestParser.normalizeExportClauses(ManifestParser.java:876)
at org.apache.felix.framework.util.manifestparser.ManifestParser.<init>(ManifestParser.java:215)
at org.apache.felix.framework.ExtensionManager.<init>(ExtensionManager.java:261)
at org.apache.felix.framework.Felix.<init>(Felix.java:429)
at org.apache.felix.framework.FrameworkFactory.newFramework(FrameworkFactory.java:28)
at org.apache.karaf.main.Main.launch(Main.java:258)
at org.apache.karaf.main.Main.main(Main.java:180)
Error installing bundle listed in startup.properties with url: mvn:org.apache.karaf.features/org.apache.karaf.features.extension/4.2.15 and startlevel: 1
I've tried setting the org.apache.karaf.features.extension to other levels, and have tried other versions of of the same; nothing works.
My startup.properties looks like this:
# Bundles to be started on startup, with startlevel
mvn\:org.apache.karaf.features/org.apache.karaf.features.extension/4.2.15 = 1
mvn\:org.apache.karaf.services/org.apache.karaf.services.eventadmin/4.2.15 = 5
mvn\:org.apache.felix/org.apache.felix.metatype/1.2.4 = 5
mvn\:org.ops4j.pax.url/pax-url-aether/2.6.7 = 5
mvn\:org.ops4j.pax.logging/pax-logging-log4j2/1.11.13 = 8
mvn\:org.ops4j.pax.logging/pax-logging-api/1.11.13 = 8
mvn\:org.fusesource.jansi/jansi/1.18 = 8
mvn\:org.osgi/org.osgi.util.promise/1.1.1 = 9
mvn\:org.apache.felix/org.apache.felix.coordinator/1.0.2 = 9
mvn\:org.osgi/org.osgi.util.function/1.1.0 = 9
mvn\:org.apache.felix/org.apache.felix.configadmin/1.9.22 = 10
mvn\:org.apache.felix/org.apache.felix.fileinstall/3.7.4 = 11
mvn\:org.apache.karaf.features/org.apache.karaf.features.core/4.2.15 = 15
I am using JDK 11
Does anyone know what I can do to fix this and get karaf running?

How to resolve error " Hunk #2 FAILED at 456. 1 out of 2 hunks FAILED"

I am trying to run the following command in ubuntu terminal
patch -p0 -i adjustmentFile.patch
That is giving the following error
patching file ./src/helpStructures/CastaliaModule.cc
patching file ./src/node/communication/mac/tunableMac/TunableMAC.cc
Hunk #2 FAILED at 456.
1 out of 2 hunks FAILED -- saving rejects to file ./src/node/communication/mac/tunableMac/TunableMAC.cc.rej
I tried almost all the ways suggested in the link Hunk #1 FAILED at 1. What's that mean?. However, nothing worked.
Here is my version detail
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 06 2019 17:31:41)
Included patches: 1-1453
The patch file:
diff -r -u ./src/helpStructures/CastaliaModule.cc ./src/helpStructures/CastaliaModule.cc
--- ./src/helpStructures/CastaliaModule.cc 2010-12-09 09:56:47.000000000 -0300
+++ ./src/helpStructures/CastaliaModule.cc 2011-12-20 00:16:39.944320051 -0300
## -180,6 +180,8 ##
classPointers.resourceManager = getParentModule()->getParentModule()->getSubmodule("ResourceManager");
else if (name.compare("SensorManager") == 0)
classPointers.resourceManager = getParentModule()->getSubmodule("ResourceManager");
+ else if (name.compare("Routing") == 0)
+ classPointers.resourceManager = getParentModule()->getParentModule()->getSubmodule("ResourceManager");
else
opp_error("%s module has no rights to call drawPower() function", getFullPath().c_str());
if (!classPointers.resourceManager)
Only in ./src/helpStructures: CastaliaModule.cc~
diff -r -u ./src/node/communication/mac/tunableMac/TunableMAC.cc ./src/node/communication/mac/tunableMac/TunableMAC.cc
--- ./src/node/communication/mac/tunableMac/TunableMAC.cc 2011-03-30 02:14:34.000000000 -0300
+++ ./src/node/communication/mac/tunableMac/TunableMAC.cc 2011-12-19 23:57:43.894686687 -0300
## -405,6 +405,8 ##
void TunableMAC::fromRadioLayer(cPacket * pkt, double rssi, double lqi)
{
TunableMacPacket *macFrame = dynamic_cast <TunableMacPacket*>(pkt);
+ macFrame->getMacRadioInfoExchange().RSSI = rssi;
+ macFrame->getMacRadioInfoExchange().LQI = lqi;
if (macFrame == NULL){
collectOutput("TunableMAC packet breakdown", "filtered, other MAC");
return;
## -454,7 +456,8 ##
}
case DATA_FRAME:{
- toNetworkLayer(macFrame->decapsulate());
+ cPacket *netPkt = decapsulatePacket(macFrame);
+ toNetworkLayer(netPkt);
collectOutput("TunableMAC packet breakdown", "received data pkts");
if (macState == MAC_STATE_RX) {
cancelTimer(ATTEMPT_TX);
Only in ./src/node/communication/mac/tunableMac: TunableMAC.cc~
Patching takes some changes made to a file X, and applies them to a different instance of file X. That is, suppose you start with generation 1 of file X; you make changes to get generation 2-a, and someone else starts with generation 1 to make generation 2-b. Now you want to take his edits that created his generation 2-b, and apply them to your generation 2-a.
If 'his' changes clash with 'your' changes, they cannot be automatically patched.
You'll need to look at the changes being made in hunk 2.
- toNetworkLayer(macFrame->decapsulate());
+ cPacket *netPkt = decapsulatePacket(macFrame);
+ toNetworkLayer(netPkt);
and figure out what you want the result to look like. Someone needs to know what the result is supposed to be. You can't resolve conflicts without knowledge of intent.

SiriKit crashes: "Use of the class from an app requires the entitlement com.apple.developer.siri."

We have been receiving crash reports say that "Use of the class INPreferences from an app requires the entitlement com.apple.developer.siri. Did you enable the Siri capability in your Xcode project?". But We have absolutely enabled the Siri capability in Xcode, and the APP ID does support the Siri feature, otherwise our app would have crashed all the time. So, why just some devices crashed? This bothers us a lot.
Anyone knows the reason or has encoutered the same problem? We'd appreciate if you can offer some help.
Here is the crash log:
0 CoreFoundation 0x000000018b6fd1b8 ___exceptionPreprocess + 124
1 libobjc.A.dylib 0x000000018a13455c objc_exception_throw + 44
2 Intents 0x00000001a4cd55ac -[INPreferences _siriAuthorizationStatus]
3 libdispatch.dylib 0x000000018a5861bc __dispatch_client_callout + 16
4 libdispatch.dylib 0x000000018a586fb0 dispatch_once_f + 56
5 Intents 0x00000001a4cd51d8 -[INPreferences assertThisProcessHasSiriEntitlement] + 112
6 Intents 0x00000001a4cd57f8 -[INPreferences requestSiriAuthorization:] + 96
7 Intents 0x00000001a4cd5950 +[INPreferences requestSiriAuthorization:] + 80
8 AppName 0x0000000100589cf4 -[AppDelegate _requestAuthorizations] (CAppDelegate.m:802)
9 AppName 0x00000001001b99dc -[SplashView p_didTransitionImageViewAnimations] (SplashView.m:234)
10 AppName 0x0000000100a3adb0 -[SplashView p_disappearImageView] (SplashView.m:395)
11 Foundation 0x000000018c1fa46c __NSFireDelayedPerform + 416
12 CoreFoundation 0x000000018b6ab1d8 ___CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
13 CoreFoundation 0x000000018b6aaeec ___CFRunLoopDoTimer + 872
14 CoreFoundation 0x000000018b6aa7a8 ___CFRunLoopDoTimers + 244
15 CoreFoundation 0x000000018b6a83a4 ___CFRunLoopRun + 1572
16 CoreFoundation 0x000000018b5d62b8 CFRunLoopRunSpecific + 436
17 GraphicsServices 0x000000018d08a198 GSEventRunModal + 172
18 UIKit 0x00000001916167fc -[UIApplication _run] + 684
19 UIKit 0x0000000191611534 UIApplicationMain + 204
20 AppName 0x00000001002a6084 main (main.m:248)
21 libdyld.dylib 0x000000018a5b95b8 _dyld_process_info_notify_release + 36
Use of the class <INPreferences: 0x174238980> from an app requires the entitlement com.apple.developer.siri. Did you enable the Siri capability in your Xcode project?
Seems like you need to share data of main applciaiton with extension, turn on Siri Capability and App Grouping for your app. Also, you have to add Siri feature for your app on developer.apple.com
Go to your Entitlements file and make sure you enabled siri

%R magic no longer works in IPython or Jupyter following update to Canopy Ver 1.7.4.3348

Previously %R and %%R magics were working in IPython and Jupyter python notebooks.
The R terminal version is:
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)
After upgrading to Version 1.7.4.3348 in Enthought Canopy, the notebooks and IPython no longer work. I have tried reinstalling following Installing RKernel and http://irkernel.github.io/installation/, which worked before. I run the command to load the R-extension as per
%load_ext rpy2.ipython
I get the error message as follows:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-691c6d73b073> in <module>()
----> 1 get_ipython().magic(u'load_ext rpy2.ipython')
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
2161 magic_name, _, magic_arg_s = arg_s.partition(' ')
2162 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2163 return self.run_line_magic(magic_name, magic_arg_s)
2164
2165 #-------------------------------------------------------------------------
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
2082 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2083 with self.builtin_trap:
-> 2084 result = fn(*args,**kwargs)
2085 return result
2086
<decorator-gen-64> in load_ext(self, module_str)
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
191 # but it's overkill for just that one bit of state.
192 def magic_deco(arg):
--> 193 call = lambda f, *a, **k: f(*a, **k)
194
195 if callable(arg):
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/magics/extension.pyc in load_ext(self, module_str)
64 if not module_str:
65 raise UsageError('Missing module name.')
---> 66 res = self.shell.extension_manager.load_extension(module_str)
67
68 if res == 'already loaded':
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/extensions.pyc in load_extension(self, module_str)
82 if module_str not in sys.modules:
83 with prepended_to_syspath(self.ipython_extension_dir):
---> 84 __import__(module_str)
85 mod = sys.modules[module_str]
86 if self._call_load_ipython_extension(mod):
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/rpy2/ipython/__init__.py in <module>()
----> 1 from .rmagic import load_ipython_extension
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/rpy2/ipython/rmagic.py in <module>()
57 template_converter = ro.conversion.converter
58 try:
---> 59 from rpy2.robjects import pandas2ri as baseconversion
60 template_converter = template_converter + baseconversion.converter
61 except ImportError:
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/rpy2/robjects/pandas2ri.py in <module>()
7 INTSXP)
8
----> 9 from pandas.core.frame import DataFrame as PandasDataFrame
10 from pandas.core.series import Series as PandasSeries
11 from pandas.core.index import Index as PandasIndex
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/__init__.py in <module>()
20
21 # numpy compat
---> 22 from pandas.compat.numpy_compat import *
23
24 try:
/Users/Llewelyn_home/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pandas/compat/numpy_compat.py in <module>()
13
14 # numpy versioning
---> 15 _np_version = np.version.short_version
16 _np_version_under1p8 = LooseVersion(_np_version) < '1.8'
17 _np_version_under1p9 = LooseVersion(_np_version) < '1.9'
AttributeError: 'module' object has no attribute 'version'
Could it be related to Canopy version of numpy being listed as 1.10.4-1 and the np.version result being 1.11.1 (based on error message)? Any suggestions gratefully received. PS. R works in the console still, plus in terminal and in Jupyter with an R kernel...
The support crew at Enthought examined the version of numpy, then pandas. Reinstalling both did not solve the problem. The unexplained resolution occurred from the pip install theano --upgrade command on the Canopy Terminal. Logging this error as an unexplained issue with %R but with the strong indication that it is about dependency version.

Count total number of lines in a project excluding certain folders or files

Using the command:
wc -l + `find . -name \* -print`
You can get the total number of lines of all files inside a folder.
But imagine you have some folders (for example libraries), which you don't want to count their lines because you didn't write them.
So, how would you count the lines in a project excluding certain folders?
cloc has always been a great friend whenever I need to count lines of src-code. Using 2.6.29 linux kernel as an example:
$ cloc .
26667 text files.
26357 unique files.
2782 files ignored.
http://cloc.sourceforge.net v 1.50 T=168.0 s (140.9 files/s, 58995.0 lines/s)
--------------------------------------------------------------------------------
Language files blank comment code
--------------------------------------------------------------------------------
C 11435 1072207 1141803 5487594
C/C++ Header 10033 232559 368953 1256555
Assembly 1021 35605 41375 223098
make 1087 4802 5388 16542
Perl 25 1431 1648 7444
yacc 5 447 318 2962
Bourne Shell 50 464 1232 2922
C++ 1 205 58 1496
lex 5 222 246 1399
HTML 2 58 0 378
NAnt scripts 1 85 0 299
Python 3 62 77 277
Bourne Again Shell 4 55 22 265
Lisp 1 63 0 218
ASP 1 33 0 136
awk 2 14 7 98
sed 1 0 3 29
XSLT 1 0 1 7
--------------------------------------------------------------------------------
SUM: 23678 1348312 1561131 7001719
--------------------------------------------------------------------------------
With find, you can also "negate" matching conditions with !. For example, if I want to list all the .java files in a directory, excluding those containing Test:
find . -name "*.java" ! -name "*Test*"
Hope this helps!
Edit:
By the way, the -name predicate only filters file names. If you want to filter paths (so you can filter directories), use -path:
find . -path "*.java" ! -path "*Test*"
you could always exclude them by listing out the files using regular expressions,
for example,
*.txt will include only txt files and so on...
I made an NPM package specifically for this usage, which allows you to call a CLI tool and providing the directory path and the folders/files to ignore
it goes like:
npm i -g #quasimodo147/countlines
to get the $ countlines command in your terminal
then you can do
countlines . node_modules build dist

Resources