What files can I delete after creating .exe file with pyinstaller in order not to damage the application?
The directory contains:
.idea/
__pycache__/
build/
dist/
venv/
main.py
main.spec
...as also shown in this graphical listing:
You can delete build and dist, after you got the exe out. __pycache__ is created by python every time you run the application.
Related
I have a private pip package located in my virtual environment site-packages folder and I'd like to cythonize it for a speed boost and added protection.
My script successfully converts the files to .c, however, it places the build/ folder for the temporary .so files locally. It then tries to copy those .so files locally to a folder that does not exist. Instead, I want it to copy those files over to the venv site-packages/ python package where it had just created the .c files.
Is there a way I can specify where to copy those files over?
Or can I specify where that build folder gets created?
my_app/ (working dir/main program folder)
├── app_gui/ (my application)
├── build/ (build folder generated by cython)
virtualenvs/lib/python/site-packages/
├── my_pip_installed_package/
├── folder/
def main():
all_files = get_all_files(BASE_DIR)
py_files = [file for file in all_files if file.suffix =='.py']
py_file_strings = convert_to_str(py_files)
setup(ext_modules=cythonize(py_file_strings, compiler_directives={"language_level": "3"}))
I found what I would call a workaround to do this. Instead of running my cythonize script locally on the main application, I changed directories to the site-packages folder, changed where BASE_DIR points to and ran the script from there.
I have a project structure like this:
bin/
here I hold binaries, that "main.py" needs
those binaries are mostly shell scripts
src/
__init__.py (empty file, but pyinstaller needs it)
main.py (ENTRY POINT FOR APP)
main.glade (GTK Glade file for GUI)
funcs.py
setup.py (I configured it in order to use "import" reference from project's root)
assets/
here I hold *.svg images, that "main.py" uses
utils/
here I hold *.txt files, that "main.py" uses
Question: HOW do I compile all those files into ONE executable, which I could place into /usr/bin directory in order to execute it from EVERYWHERE?
What I do have tried so far is this:
pyinstaller --onefile main.py
It indeed creates me ONE executable file, however it only compiled all *.py files into ONE executable no all those images, text files and other binaries. Is there a way to do it, though? OR there is an another good option to somehow PACK this project and place it into /usr/bin?
Thank you in advance, cheers!
I have a django project and i want to create the .pyc files and remove the source code. My project folder name is mysite and I ran the command python -m compileall mysite. The .pyc files are created. After that i tried to run my project with python __pycache__/manage.cpython-37.pyc runserver command but i've got an error such as ModuleNotFoundError: No module named 'mysite'
There are two things I would like to ask about this. First, how can I solve this problem and run my project with .pyc file? Secondly, is it enough to move the .pyc files created to a separate folder in accordance with the django project structure?
First of all, I created a new folder in another directory such as a new django project and i created my app folders, static folder, templates folder etc. manually as the same as my django project architecture that I created before.
Then, I moved the .pyc files that I created with the compileall command to my new project folders.
As you know, while creating .pyc files, a .cpython-37 section is added to the file names automatically (for example, manage.py -> manage.cpython-37.pyc). I removed that section and i converted them to manage.pyc, views.pyc, etc.
So my file structure was like this:
mysite/
manage.pyc
mysite/
__init__.pyc
settings.pyc
urls.pyc
wsgi.pyc
app/
migrations/
__init__.pyc
__init__.pyc
admin.pyc
apps.pyc
models.pyc
tests.pyc
views.pyc
...
After I created this django project structure with .pyc files, i ran the python manage.pyc runserver command and it works.
create_product
src
common
util.py
config
config.properities
templates
template1.txt
create_product.py
Python36
I'm using the above dir structure. While use the below command:
pyinstaller create_product.py
It creates the exe file inside the dist/create_product folder. But exe file requires for config folder and templates folder which contains the .properties and .txt file. By default these folders are not copied into the dist/create_product. If manually copied it works fine.
How to copy the two folders by pyinstaller command itself?
I have a pycharm project with the following shape:
my_project:
setup.py
config_files:
config1.yaml
config2.yaml
my_package:
__init__.py
main.py
When I run my main.py from pycharm, I am able to access my config1.yaml file using the following path: ../config_files/config1.yaml.
My goal is to build the package, then install it on my cloud machine and run the program. But the setup.py does not copy the config files where they are in my pycharm project.
My question is: what can I do to be sure that these files are correctly copied?