diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..8215875 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include config.toml.default \ No newline at end of file diff --git a/config/__init__.py b/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/config.toml b/config/config.toml.default similarity index 100% rename from config.toml rename to config/config.toml.default diff --git a/setup.py b/setup.py index 1536334..8481895 100644 --- a/setup.py +++ b/setup.py @@ -35,9 +35,10 @@ "Programming Language :: Python :: 3 :: Only", ], keywords="ventoy, updater, os, iso, updater, sisou, cli", # Optional - # package_dir={"superisoupdater": "."}, # Optional packages=find_packages(), # Required py_modules=["sisou"], # Required + include_package_data=True, + package_data={"": ["config.toml.default"]}, python_requires=">=3.10, <4", install_requires=[ "beautifulsoup4==4.12.2", @@ -49,13 +50,6 @@ # "dev": [""], # "test": [""], # }, - # If there are data files included in your packages that need to be - # installed, specify them here. - # package_data={ # Optional - # "sample": ["package_data.dat"], - # }, - # Entry points. The following would provide a command called `sample` which - # executes the function `main` from this package when invoked: entry_points={ # Optional "console_scripts": [ "sisou = sisou:main", @@ -65,4 +59,5 @@ "Bug Reports": "https://github.com/JoshuaVandaele/SuperISOUpdater/issues", "Source": "https://github.com/JoshuaVandaele/SuperISOUpdater/", }, + zip_safe=False, ) diff --git a/sisou.py b/sisou.py index 5312cf3..2517385 100644 --- a/sisou.py +++ b/sisou.py @@ -153,7 +153,36 @@ def main(): setup_logging(args.log_level, args.log_file) - config = parse_config(args.config_file or "config.toml") + config_file = args.config_file + if not config_file: + logging.info( + "No config file specified. Trying to find config.toml in the current directory..." + ) + config_file = os.path.join(os.getcwd(), "config.toml") + + if not os.path.isfile(config_file): + logging.info( + "No config file specified. Trying to find config.toml in the ventoy drive..." + ) + config_file = os.path.join(args.ventoy_path, "config.toml") + + if not os.path.isfile(config_file): + logging.info( + "No config.toml found in the ventoy drive. Generating one from config.toml.default..." + ) + with open( + os.path.join( + os.path.dirname(__file__), "config", "config.toml.default" + ) + ) as default_config_file: + with open(config_file, "w") as new_config_file: + new_config_file.write(default_config_file.read()) + logging.info( + "Generated config.toml in the ventoy drive. Please edit it to your liking and run sisou again." + ) + return + + config = parse_config(config_file) if not config: raise ValueError("Configuration file could not be parsed or is empty")