JessicaTegner / JustUpdate

An updater framework that just works. JustUpdate uses existing native tools to perform updates.
GNU Lesser General Public License v3.0
7 stars 3 forks source link

Cannot build app because of wrong path #5

Open LukeSavefrogs opened 4 years ago

LukeSavefrogs commented 4 years ago

There is actually a win.exe file but is under ju-repo\\dist\\win.exe

Here is the log:

→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate build .\win.spec
2020-11-11 12:52 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-11 12:52 JustUpdate INFO Building.
2020-11-11 12:52 JustUpdate INFO Build completed.
2020-11-11 12:52 JustUpdate INFO Checking build integrity
2020-11-11 12:52 JustUpdate ERROR Unable to find the build fonder.
[WinError 3] Impossibile trovare il percorso specificato: 'ju-repo\\dist\\win\\win.exe' -> 'ju-repo\\dist\\win\\AutoUpdatingAPP-Test.exe'
2020-11-11 12:52 JustUpdate ERROR [WinError 3] Impossibile trovare il percorso specificato: 'ju-repo\\dist\\win\\win.exe' -> 'ju-repo\\dist\\win\\AutoUpdatingAPP-Test.exe'
JessicaTegner commented 4 years ago

Interesting. Do you mind showing me the content of the spec file? I think (but I'm not sure) it's because JustUpdate expects PyInstaller to produce a "--onedir" build, and the spec file is producing a "--onefile" build instead.

LukeSavefrogs commented 4 years ago

Yes i passed --onefile to the command

LukeSavefrogs commented 4 years ago

The docs said it was obligatory to use --onedir on Mac

JessicaTegner commented 4 years ago

I think I have missed that case on windows, since JustUpdate expects a onedir build, not a onefile build. Let me see what I can do about it.

LukeSavefrogs commented 4 years ago

Thank you for your kindness ^^

LukeSavefrogs commented 4 years ago

I've just found that when passing the --name PyInstaller parameter, JustUpdate produces a spec file called main.py.spec and exits with error during the build:

→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate make-spec --onedir --name "TEST" .\main.py         
2020-11-18 07:26 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-18 07:26 JustUpdate INFO Spec file written.
→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate build .\main.py.spec    
2020-11-18 07:26 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-18 07:26 JustUpdate INFO Building.
204 INFO: PyInstaller: 3.6
204 INFO: Python: 3.8.3
205 INFO: Platform: Windows-10-10.0.19041-SP0
208 INFO: UPX is not available.
Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\pyinstaller.exe\__main__.py", line 9, in <module>
  File "c:\python38\lib\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\python38\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\python38\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\python38\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
    exec(code, spec_namespace)
  File ".\main.py.spec", line 6, in <module>
    a = Analysis(['TEST'],
  File "c:\python38\lib\site-packages\PyInstaller\building\build_main.py", line 191, in __init__
    raise ValueError("script '%s' not found" % script)
ValueError: script 'TEST' not found

2020-11-18 07:26 JustUpdate ERROR Please correct the errors above and try again.

While if i don't pass the --name argument, the name of the spec file is win.spec, which is correct. In fact like this even the buil goes on

→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate make-spec --onedir --windowed .\main.py   
2020-11-18 07:27 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-18 07:27 JustUpdate INFO Spec file written.
→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate build .\win.spec    
2020-11-18 07:27 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-18 07:27 JustUpdate INFO Building.
2020-11-18 07:28 JustUpdate INFO Build completed.
2020-11-18 07:28 JustUpdate INFO Checking build integrity
2020-11-18 07:28 JustUpdate INFO Done

But

When i try to commit to the repo it returns error again:

→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate commit 0.0.1  
2020-11-18 07:28 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-18 07:28 JustUpdate INFO Starting commit process for build version 0.0.1 / 0.0.1.
2020-11-18 07:28 JustUpdate INFO Producing executable
[WinError 2] Impossibile trovare il file specificato
2020-11-18 07:28 JustUpdate ERROR [WinError 2] Impossibile trovare il file specificato

In the docs it's not very clear... Is this the correct sequence?

Steps to reproduce

  1. Init the repo

  2. Create file called main.py

    
    from justupdate.client.client import JustUpdateClient
    from client_config import ClientConfig

if name == "main": client = JustUpdateClient(ClientConfig(), "1.0.0", "stable")

if client.update_available():
    print("An update is available!")
    # proceed to download.
else:
    print("No update available")
    # no update available, we are up to date.

3. Create the spec file

justupdate make-spec --onedir --windowed .\main.py


4. Build the application

justupdate build .\win.spec


5. Launch the commit

justupdate commit 0.0.1


Here goes into error.

## Spec file 
### `win.spec`

-- mode: python ; coding: utf-8 --

block_cipher = None

a = Analysis(['main.py'], pathex=['C:\Users\Luca Salvarani\Desktop\Script\Tests\PyUpdater-Demo'], binaries=[], datas=[], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], 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='win', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, console=False ) coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, upx_exclude=[], name='win')


### `win.spec`

-- mode: python ; coding: utf-8 --

block_cipher = None

a = Analysis(['TEST'], pathex=['C:\Users\Luca Salvarani\Desktop\Script\Tests\PyUpdater-Demo'], binaries=[], datas=[], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], 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='.\main.py', 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='.\main.py')



What would i have to do next? The documentation is not so clear on this point and i couldn't find an example online

Thanks in advance
JessicaTegner commented 4 years ago

Thanks for the additional information. On windows, JustUpdate uses NSIS during the commit process (something that should be installed on the system separately, which isn't that clear from the documentation)

That could be the cause. I'm still working on fixing your issue and improving JustUpdate to make sure it doesn't happen again.

LukeSavefrogs commented 4 years ago

Update

So, i installed NSIS from here and i still got the error:

→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate commit 0.0.1
2020-11-19 05:23 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-19 05:23 JustUpdate INFO Starting commit process for build version 0.0.1 / 0.0.1.
2020-11-19 05:23 JustUpdate INFO Producing executable
[WinError 2] Impossibile trovare il file specificato
2020-11-19 05:23 JustUpdate ERROR [WinError 2] Impossibile trovare il file specificato

I investigated a bit and found that maybe it could be because of these lines in the function _produce_executable_win() where you call makensis: https://github.com/NicklasTegner/JustUpdate/blob/23d35f346b4df351c6011613e7f8ad3764320e24/justupdate/repo/committer.py#L59-L60

In fact, using a new PowerShell session to launch nsis or makensis (even with .exe) fails...

→ C:\Users\Luca Salvarani› makensis
makensis : Termine 'makensis' non riconosciuto come nome di cmdlet, funzione, programma eseguibile o file script. Controllare l'ortografia
del nome o verificare che il percorso sia incluso e corretto, quindi riprovare.
In riga:1 car:1
+ makensis
+ ~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (makensis:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

I then added to the PATH the path where nsis is installed (C:\Program Files (x86)\NSIS) and after closing and reopening the PowerShell, the command now works:

→ C:\Users\Luca Salvarani› makensis
Usage:
  makensis [ option | script.nsi | - ] [...]

Options:
  /CMDHELP [item] prints out help for 'item', or lists all commands
  /HDRINFO prints information about what options makensis was compiled with
  /LICENSE prints the makensis software license
  /VERSION prints the makensis version and exits
  /Px sets the compiler process priority, where x is 5=realtime,4=high,
    3=above normal,2=normal,1=below normal,0=idle
  /Vx verbosity where x is 4=all,3=no script,2=no info,1=no warnings,0=none
  /WX treat warnings as errors
  /Ofile specifies a text file to log compiler output (default is stdout)
  /PAUSE pauses after execution
  /NOCONFIG disables inclusion of <path to makensis.exe>\nsisconf.nsh
  /NOCD disables the current directory change to that of the .nsi file
  /INPUTCHARSET <ACP|OEM|CP#|UTF8|UTF16<LE|BE>>
  /OUTPUTCHARSET <ACP|OEM|CP#|UTF8[SIG]|UTF16<LE|BE>[BOM]>
  /[SAFE]PPO preprocess to stdout/file
  /Ddefine[=value] defines the symbol "define" for the script [to value]
  /Xscriptcmd executes scriptcmd in script (i.e. "/XOutFile inst.exe")
    parameters are processed by order (/Ddef ins.nsi != ins.nsi /Ddef)

For script file name, you can use - to read from the standard input
You can also use - as an option character: -PAUSE as well as /PAUSE
You can use a double-dash to end options processing: makensis -- -ins.nsi

Vscode still didn't find it s i restarted it and BAM:

→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate commit 0.0.1    
2020-11-19 05:42 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-19 05:42 JustUpdate INFO Starting commit process for build version 0.0.1 / 0.0.1.
2020-11-19 05:42 JustUpdate INFO Producing executable
2020-11-19 05:42 JustUpdate INFO Calculating checksum.
2020-11-19 05:42 JustUpdate INFO Looking for existing metadata.
2020-11-19 05:42 JustUpdate INFO Saving updated metadata.
2020-11-19 05:42 JustUpdate INFO Moving executable.
2020-11-19 05:42 JustUpdate INFO Committed version 0.0.1.

Now it works

LukeSavefrogs commented 4 years ago
→ PyUpdater-Demo: [master +3 ~0 -0 !]› justupdate make-spec --onedir --windowed .\main.py
2020-11-19 05:53 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-19 05:53 JustUpdate INFO Spec file written.
→ PyUpdater-Demo: [master +4 ~0 -0 !]› justupdate build .\win.spec
2020-11-19 05:54 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-19 05:54 JustUpdate INFO Building.
2020-11-19 05:55 JustUpdate INFO Build completed.
2020-11-19 05:55 JustUpdate INFO Checking build integrity
2020-11-19 05:55 JustUpdate INFO Done
→ PyUpdater-Demo: [master +4 ~0 -0 !]› justupdate commit 0.0.2        
2020-11-19 05:55 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-19 05:55 JustUpdate INFO Starting commit process for build version 0.0.2 / 0.0.2.
2020-11-19 05:55 JustUpdate INFO Producing executable
2020-11-19 05:55 JustUpdate INFO Calculating checksum.
2020-11-19 05:55 JustUpdate INFO Looking for existing metadata.
2020-11-19 05:55 JustUpdate INFO Saving updated metadata.
2020-11-19 05:55 JustUpdate INFO Moving executable.
2020-11-19 05:55 JustUpdate INFO Committed version 0.0.2.
→ PyUpdater-Demo: [master +4 ~0 -0 !]› justupdate upload -s gh-archive
2020-11-19 05:55 JustUpdate INFO JustUpdate - 1.3.7.
2020-11-19 05:55 JustUpdate INFO Starting upload with gh-archive uploader service.
2020-11-19 05:55 JustUpdate INFO Checking out files for upload.
2020-11-19 05:55 JustUpdate INFO Files to upload: ['ju-repo\\deploy\\AutoUpdatingAPP-Test-0.0.2.exe', 'ju-repo\\deploy\\metadata-win.ju'].      
2020-11-19 05:55 JustUpdate INFO Upload done. Moving uploaded files to archive.

Then i moved the 2 files 'ju-repo\deploy\AutoUpdatingAPP-Test-0.0.1.exe', 'ju-repo\deploy\metadata-win.ju' into the directory specified into the config (deployedFiles) and then i committed and pushed everything to github.

After launching the executable into deployedFiles i get the following error:

image

Am i missing something?

You can check everything i am doing in this repository: https://github.com/LukeSavefrogs/AutoUpdatingAPP-Test

JessicaTegner commented 4 years ago

The update url "https://github.com/LukeSavefrogs/AutoUpdatingAPP-Test/deployedFiles" does not exist, and I think that is why you are getting that fatal error (but I'm not sure). Try setting the update url to "https://raw.githubusercontent.com/LukeSavefrogs/AutoUpdatingAPP-Test/main/deployedFiles/" instead.

I'm also working on adding a new command to JustUpdate, that will check if everything is okay, so problems like yours wont happen again.