-
-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependency file is not a file: ./requirements.txt #75
Comments
Sorry about that! I'll improve documentation but when you don't use the recommended installation mechanism file paths must be absolute. |
Thanks a lot for the fast answer. That was in fact the reason. I agree that using I created a new Powershell script that seems to work great. I would suggest adding it to the docs as an example, maybe it can be improved though. I think it would be great for beginners, I needed some time to get it to work 😅. One could maybe also make it compatible with Linux for easy cross-compilation. # This is supposed to be executed in the root of the project
# Export poetry requirements to requirements.txt
poetry export -f requirements.txt --output requirements.txt
# Now set environment variables properly in powershell
$env:PYAPP_PROJECT_VERSION="0.1.0"
$env:PYAPP_PROJECT_NAME="pyappexample"
# Set the path to the requirements.txt file, it is the absolute path of ./requirements.txt
$env:PYAPP_PROJECT_DEPENDENCY_FILE="$((Get-Item -Path "./requirements.txt").FullName)"
$env:PYAPP_EXEC_SCRIPT="$((Get-Item -Path "./pyappexample/circle.py").FullName)"
if (!(Test-Path -Path "./pyapp-latest")) {
# Download the zip file from the URL
Invoke-WebRequest https://github.com/ofek/pyapp/releases/latest/download/source.zip -OutFile pyapp-source.zip
Expand-Archive -Path ./pyapp-source.zip -DestinationPath .
Move-Item -Path ./pyapp-v* -Destination ./pyapp-latest
Remove-Item -Path ./pyapp-source.zip
}
# Change the current directory to the extracted folder
Set-Location -Path ./pyapp-latest
cargo build --release
# Move Item and rename it to $env:PYAPP_PROJECT_NAME.exe, overwrite if exists
Move-Item target\release\pyapp.exe ..\$env:PYAPP_PROJECT_NAME.exe -Force
# Change the current directory to the root of the project
Set-Location -Path .. I haven't explored it beyond this toy example yet, but this seems significantly easier to use than pyinstaller so far, amazing that you created this. |
I tested a bit more and discovered that one can't import functions from other .py files in the same folder as the main script. So if I have a parallel file |
Yes the easiest solution for that is to turn your scripts into a package. You can then either publish and install from PyPI or if private just build and point to the path to the wheel: https://ofek.dev/pyapp/latest/config/#project-embedding |
Thanks for the hint. My final version of the powershell script now finally works! (I think.) It is here: # This is supposed to be executed in the root of the project
# The executable will execute this function when it starts
$env:PYAPP_EXEC_SPEC="pyappexample.circle:run"
$executable_name = "pyappexample"
# We are building the wheel with poetry
if (Test-Path -Path "./dist") {
Remove-Item -Path ./dist -Recurse -Force
}
poetry build
# Get the full path of the wheel file in the dist directory
$wheel_file = (Get-Item -Path "./dist/*.whl").FullName
# Print wheel file path
Write-Host "Wheel file path: $wheel_file"
$env:PYAPP_PROJECT_PATH=$wheel_file
# if check if pyapp-latest folder not exists
if (!(Test-Path -Path "./pyapp-latest")) {
# Download the zip file from the URL
Invoke-WebRequest https://github.com/ofek/pyapp/releases/latest/download/source.zip -OutFile pyapp-source.zip
# Extract the zip file to the temporary folder using Expand-Archive
Expand-Archive -Path ./pyapp-source.zip -DestinationPath .
# Move the extracted folder to the desired location and rename it
Move-Item -Path ./pyapp-v* -Destination ./pyapp-latest
Remove-Item -Path ./pyapp-source.zip
}
# Change the current directory to the extracted folder
Set-Location -Path ./pyapp-latest
cargo build --release
# Move Item and rename it to $env:PYAPP_PROJECT_NAME.exe, overwrite if exists
Move-Item target\release\pyapp.exe ..\$executable_name.exe -Force
# Change the current directory to the root of the project
Set-Location -Path .. |
Nice! |
Thanks for the powershell script, this is exactly what I was looking for! When I try the single-project-embedded method or use this script I get this error:
Write-Host "Wheel file path: $wheel_file" prints a valid output to the .whl file. Any ideas? |
@quinnhornblow Does https://github.com/Vuizur/pyappexample work for you? If yes, the issue could be the executable name or the file path - does it contain any weird characters? |
Yes that does work. I've created a fork of your example to replicate my issue here. The main change is that I'm using setuptools instead of poetry. I don't really know how they differ, setuptools is just what we use where I work. Changes:
When running build_with_pyapp.ps1 the .whl file builds successfully, but process fails at 'cargo build' with the ASCII error mentioned above. Although the process does succeed if I run in debug mode without the --release tag. |
Maybe I'm beating around a dead bush, but something similar came up in
|
Thanks a lot for developing this project! I am very excited to try it.
I wanted to use it with a simple example project using poetry. I am trying to do it on Windows and have the following powershell file (build_with_pyapp.ps1).
Unfortunately I am getting the following error:
I am executing the powershell script from the root directory, where my requirements.txt file is located.
Have a great day!
The text was updated successfully, but these errors were encountered: