How to prevent pyinstaller from adding unneccessary and unrelated files? - pyinstaller

I was puzzled to see that some files and folders are actually ending up in the pyinstaller generated dist folder. For example, the .git in my project root is ending up as dist/Script/mpl-data/.git together with other files from the root directory. Any idea how to prevent that?
The specfile I am using looks like this:
block_cipher = None
a = Analysis(['..\\scripts\\scipt.py'],
pathex=['C:\\Users\\..\\scripts'],
binaries=[],
datas=[...],
hiddenimports=['pkg_resources.py2_warn'],
hookspath=[],
runtime_hooks=[],
excludes=['**/*.git', '**/__cache__', '**/dist', '**/build', '**/InnoSetup'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='Script',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='Script')
I tried to add the directory names to exclude, but that does not work.
The way I am using pyinstaller is from the root directory of my package.
|-package/__init__.py
| |...
|-specfiles/pyinstaller_specfile.spec
|-scripts/mainscript.py
|-hooks/...
|-setup.py
|...
And I call
pyinstaller --onedir --noconfirm specfiles\pyinstaller_specfile.spec --additional-hooks-dir=hooks

What helped was to change the directory from which I ran the pyinstaller.
Instead of the root directory and calling
pyinstaller --onedir --noconfirm specfiles\pyinstaller_specfile.spec --additional-hooks-dir=hooks
I changed into specfiles and called:
pyinstaller --onedir --noconfirm pyinstaller_specfile.spec --additional-hooks-dir=hooks
This changed the location of the dist folder (into specfiles), but prevented all those unneeded files being imported.
Update: Updating to the latest version of pyinstaller worked even better.

Related

No such file or directory - Airflow

I have my airflow project with the structure as below
airflow
|
|----dags
| |----dag.py
|
|----dbt-redshift
|----models
|----model.sql
I have included the dbt-redshift directory in the volumes section as
volumes:
-./dbt-redshift:/opt/airflow/dbt-redshift
And I'm trying to run the dbt inside the DAG using a bash operator
dbt_task = BashOperator(task_id='dbt', bash_command="cd ~/dbt-redshift && dbt run", dag=dag)
But when i execute the DAG i get the error
cd: /home/***/dbt-redshift no such file or directory
I'm not sure I understand how these directories are located inside the airflow project.
You are mounting the volume inside the container to /opt/airflow/dbt-redshift, but the BashOperator references ~/dbt-redshit with ~ resolving to /home/airflow.
(Assuming you are using the apache/airflow image)
Either change the command used by the BashOperator to reference /opt/airflow/dbt-redshift or change the volume to mount to the home directory.

Pyinstaller not able to locate static files

I have created djnago project followong is directory structure of project
mysite
--settings.py
-- urls.py
--wsgi.py
polls(app)
--static
--polls
--images
--templates
--polls
index.html
results.html
admin.py
apps.py
models.py
urls.py
views.py
I have created installer using pyinstaller
that exe runs fine able to load templates
But for static files(css and js),exe giving me error
C:\Users\sanjad\Desktop\testdemo\myinstaller>dist\manage\manage.exe runserver
Performing system checks...
System check identified no issues (0 silenced).
January 03, 2017 - 10:10:15
Django version 1.10.2, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[03/Jan/2017 10:10:18] "GET / HTTP/1.1" 200 346
Not Found: /static/polls/style.css
[03/Jan/2017 10:10:18] "GET /static/polls/style.css HTTP/1.1" 404 2605
Following is my .spec file
# -*- mode: python -*-
block_cipher = None
a = Analysis(['..\\mysite\\manage.py'],
pathex=['C:\\Users\\sanjad\\Desktop\\testdemo\\myinstaller'],
binaries=None,
datas=[
('C:\\Users\\sanjad\\Desktop\\testdemo\\mysite\\polls\\templates\\','polls\\templates'),
('C:\\Users\\sanjad\\Desktop\\testdemo\\mysite\\polls\\static\\','polls\\static')
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='manage',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='manage')
Have you seen the answer given by fpx006 here? https://github.com/pyinstaller/pyinstaller/issues/2368 I made a minor change to it as follows (also posted in that thread).
Add this to my top level urls.py
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT).
I had done the same thing to get my media files served with
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)'
And then add both of those to my spec file, along with my migrations folder as follows:
datas=[('filter/filter/core/migrations','filter/core/migrations'),
('filter/media_root','media_root'),('filter/static','static_root')],
where core is the name of the only app in this Django project, and filter is the name of the project. It is a bit of a hack, but should allow you to distribute your Django app in a .exe and see your beautiful styling.

How do you exclude file extensions from command-line JSHint?

I'm trying to exclude *.min.js and *.intellisense.js files from being linted by command-line jshint. I'm passing in a .jshintignore file via --exclude-path that looks like this:
*.min.js
*.intellisense.js
**.min.js
**.intellisense.js
**/*.min.js
**/*.intellisense.js
**\*.min.js
**\*.intellisense.js
None of the patterns seem to be matching. Versions: Node v5.3.0, jshint v2.8.0.
The full command that I'm running (in a dir like D:\Projects\SomeWeb\):
D:\utils\nodejs\node.exe D:\utils\nodejs\node_modules\jshint\bin\jshint --verbose --show-non-errors --exclude-path D:\utils\nodejs\.jshintignore .
Update #1:
As a workaround, I'm using this powershell command:
powershell -nologo -noprofile -command "Get-ChildItem -Include *.js -Exclude *.min.js,*-vsdoc.js,*.intellisense.js -Recurse | % { D:\utils\nodejs\node D:\utils\nodejs\node_modules\jshint\bin\jshint --verbose --show-non-errors $_.FullName }"

Command 'generate' not found, compiling with rebar

I am following this blog:
http://maplekeycompany.blogspot.se/2012/03/very-basic-cowboy-setup.html
In short, I am trying to compile an application with rebar just as the person in the blog.
Everything goes smoothly until I want to run the command:
./rebar get-deps compile generate
This then give me the following errors and warnings,
> User#user-:~/simple_server/rebar$ ./rebar get-deps compile generate
> ==> rebar (get-deps)
> ==> rebar (compile) Compiled src/simple_server.erl Compiled src/simple_server_http.erl src/simple_server_http_static.erl:5:
> Warning: behaviour cowboy_http_handler undefined Compiled
> src/simple_server_http_static.erl
> src/simple_server_http_catchall.erl:2: Warning: behaviour
> cowboy_http_handler undefined Compiled
> src/simple_server_http_catchall.erl WARN: 'generate' command does not
> apply to directory /home/harri/simple_server/rebar Command 'generate'
> not understood or not applicable
I have found a similar post with the same error:
Command 'generate' not understood or not applicable
I think the problem is in the reltool.config but do not know how to proceed, I changed the path to the following: {lib_dirs, ["home/user/simple_server/rebar"]}
Is there a problem with the path? How can rebar get access to all the src files and also the necessary rebar file to compile and build the application?
You need to make sure your directory structure and its contents are arranged so that rebar knows how to build everything in your system and generate a release for it. Your directory structure should look like this:
project
|
-- rel
|
-- deps
|
-- apps
|
-- myapp
| |
| -- src
| -- priv
|
-- another_app
The rel directory holds all the information needed to generate a release, and the apps directory is where the applications that make up your project live. Application dependencies live in the deps directory. Each app such as myapp and another_app under the apps directory can have their own rebar.config files. While two or more such applications are possible here, normally you'd have just one and all others would be dependencies.
In the top-level project directory there's also a rebar.config file with contents that look like this:
{sub_dirs, ["rel", "apps/myapp", "apps/another_app"]}.
{lib_dirs, ["apps"]}.
If necessary, you can use rebar to generate your apps from application skeletons:
cd apps
mkdir myapp another_app
( cd myapp && rebar create-app appid=myapp )
( cd another_app && rebar create-app appid=another_app )
If an application has dependencies, you'll have to add a rebar.config to its directory and declare each dependency there. For example, if myapp depends on application foo version 1.2, create apps/myapp/rebar.config with these contents:
{deps,
[{foo, "1.*", {git, "git://github.com/user/foo.git", {tag, "foo-1.2"}}}]
}.
When you run rebar get-deps, rebar will populate the top-level deps directory to hold all dependencies, creating deps if necessary. The top-level rebar.config can also declare dependencies if necessary.
You also need to generate a node, necessary for your releases:
cd ../rel
rebar create-node nodeid=project
You then need to modify the reltool.config file generated by the previous step. You need to change
{lib_dirs, []},
to
{lib_dirs, ["../apps", "../deps"]},
and just after the line {incl_cond, derived}, add {mod_cond, derived}, so that releases contain only the applications needed for correct execution.
Next, wherever the atom 'project' appears, you need to replace it with the applications under the apps directory. For our example, we'd change this part:
{rel, "project", "1",
[
kernel,
stdlib,
sasl,
project
]},
to this:
{rel, "project", "1",
[
kernel,
stdlib,
sasl,
myapp,
another_app
]},
and change this part:
{app, project, [{mod_cond, app}, {incl_cond, include}]}
to this:
{app, myapp, [{mod_cond, app}, {incl_cond, include}]},
{app, another_app, [{mod_cond, app}, {incl_cond, include}]}
You might also need to add the line:
{app, hipe, [{incl_cond, exclude}]},
to exclude the hipe application since sometimes it causes errors during release generation or when trying to run the release. Try without it first, but add it if you see errors related to hipe when generating a release, or if attempts to run the generated release result in this sort of error:
{"init terminating in do_boot",{'cannot load',elf_format,get_files}}
you'll need to add it.
With all this in place you can now execute:
rebar get-deps compile generate
and you should be able to successfully generate the release. Note that running rebar generate at the top level rather than in the rel dir will result in a harmless warning like this, which you can ignore:
WARN: 'generate' command does not apply to directory /path/to/project
Finally, you can run the release. Here's how to run it with an interactive console:
$ ./rel/project/bin/project console
Exec: /path/to/project/rel/project/erts-6.2/bin/erlexec -boot /path/to/project/rel/project/releases/1/project -mode embedded -config /path/to/project/rel/project/releases/1/sys.config -args_file /path/to/project/rel/project/releases/1/vm.args -- console
Root: /path/to/project/rel/project
Erlang/OTP 17 [erts-6.2] [source] [64-bit] [smp:8:8] [async-threads:10] [kernel-poll:false]
Eshell V6.2 (abort with ^G)
(project#127.0.0.1)1>
or you could run ./rel/project/bin/project start to start it in the background. Run ./rel/project/bin/project with no arguments to see all available options.

Error with wp and sass/compass

So, I'm trying to set up my wp theme for use with sass.
I've renamed style.css to style.scss and put it in a folder called 'sass'.
Then I made a file called config.rb. In it I wrote
/* config.rb in the theme's root. */
css_dir = "/"
sass_dir = "sass"
output_style = :compressed
I then try to use compas.app to watch the folder (that is on a FTP server, mounted in Finder). I choose the root folder of the theme and press ok. After two seconds I get an error:
'(RegexpError) target of repeat operator is not specified: /* config.rb in the theme's root. */
org/jruby/RubyKernel.java:1112:in eval'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/serialization.rb:24:inparse_string'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/serialization.rb:15:in _parse'
org/jruby/RubyIO.java:1139:inopen'
org/jruby/RubyKernel.java:296:in open'
file:/Applications/compass.app/Contents/Resources/Java/lib/java/jruby-complete.jar!/META-INF/jruby.home/lib/ruby/1.8/open-uri.rb:32:inopen'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/serialization.rb:14:in _parse'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/file_data.rb:7:innew_from_file'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/inheritance.rb:204:in with_defaults'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/file_data.rb:6:innew_from_file'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/helpers.rb:42:in configuration_for'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/configuration/helpers.rb:97:inadd_project_configuration'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/commands/project_base.rb:31:in add_project_configuration'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/commands/project_base.rb:25:inconfigure!'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/commands/project_base.rb:15:in initialize'
/Applications/compass.app/Contents/Resources/lib/ruby/compass_0.12/compass-0.12.2/lib/compass/commands/update_project.rb:37:ininitialize'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/ui/tray.rb:417:in watch'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/app.rb:207:intry'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/ui/tray.rb:412:in watch'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/ui/tray.rb:153:inopen_dir_handler'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/ui/tray.rb:71:in run'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/main.rb:115:inrun_tray'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/main.rb:131:in (root)'
org/jruby/RubyKernel.java:1062:inrequire'
file:/Applications/compass.app/Contents/Resources/Java/compass-app.jar!/main.rb:1:in `(root)''
You'll have to debug it.
First, download your theme to a local drive and run compass compile on it.
Then run Compass.App on it.
Then run compass watch on the remote folder.
On which step does the problem occur?

Resources