Skip to content

Commit

Permalink
#486 Initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
brentvollebregt committed Jun 1, 2024
1 parent 4f2fb2d commit 0f4dc32
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
8 changes: 8 additions & 0 deletions auto_py_to_exe/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ def is_file_an_ico(file_path):
return False


@eel.expose
def convert_path_to_absolute(path: str) -> str:
"""Converts a path to an absolute path if it exists. If it doesn't exist, returns the path as is."""
if not os.path.exists(path):
return path
return os.path.abspath(path)


@eel.expose
def import_configuration():
"""Get configuration data from a file"""
Expand Down
1 change: 1 addition & 0 deletions auto_py_to_exe/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
ask_files: () => [],
ask_folder: () => '',
is_file_an_ico: (file_path) => null,
convert_path_to_absolute: (path) => '',
open_output_in_explorer: (output_directory, input_filename, is_one_file) => {},
will_packaging_overwrite_existing: (file_path, manual_name, one_file, output_folder) => true,
package: (command, non_pyinstaller_options) => {},
Expand Down
20 changes: 20 additions & 0 deletions auto_py_to_exe/web/js/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ const getCurrentConfiguration = () => {
}
});

// Convert all relative paths to absolute paths
for (const c of currentConfiguration) {
const option = options.find((o) => o.dest === c.optionDest);
if (option === undefined) {
continue;
}

if ([OPTION_INPUT_VALUE_FILE, OPTION_INPUT_VALUE_DIRECTORY].some((v) => option.allowedInputValues.includes(v))) {
c.valueNew = convertPathToAbsolute(c.value);
}
if (
[OPTION_INPUT_VALUE_DOUBLE_FILE_DEST, OPTION_INPUT_VALUE_DOUBLE_DIRECTORY_DEST].some((v) =>
option.allowedInputValues.includes(v)
)
) {
const [src, dest] = c.value.split(pathSeparator);
c.valueNew = `${convertPathToAbsolute(src)}${pathSeparator}${dest}`;
}
}

return currentConfiguration;
};

Expand Down
2 changes: 1 addition & 1 deletion auto_py_to_exe/web/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const options_ignored = ['help'];
const options_static = ['filenames', 'onefile', 'console', 'icon_file', 'datas'];
const options_overridden = ['specpath', 'distpath', 'workpath', 'noconfirm'];

const options_inputTypeFile = ['runtime_hooks', 'version_file', 'manifest', 'resources', 'splash'];
const options_inputTypeFile = ['runtime_hooks', 'version_file', 'manifest', 'resources', 'splash', 'entitlements_file'];
const options_inputTypeDirectory = ['upx_dir', 'pathex', 'hookspath'];
const options_inputTypeDoubleFileDest = ['datas', 'binaries'];
const options_inputTypeDoubleDirectoryDest = ['datas'];
Expand Down
4 changes: 4 additions & 0 deletions auto_py_to_exe/web/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const isFileAnIco = async (file_path) => {
return await eel.is_file_an_ico(file_path)();
};

const convertPathToAbsolute = async (path) => {
return await eel.convert_path_to_absolute(path)();
};

const chooseOptionString = (optionStrings) => {
// Try not to use compressed flags
if (optionStrings[0].length === 2 && optionStrings.length > 1) {
Expand Down

0 comments on commit 0f4dc32

Please sign in to comment.