Closed NaaN108 closed 1 month ago
I have not tested this, but, if your intention it to use setuptools find_package this snippet should match this issue:
from setuptools import find_packages
setup(
# ...,
packages=find_packages(where="src"),
package_dir={"": "src"},
include_package_data=True
)
unfortunately this didn't address the issue after running the packaged application the following error is raised
raceback (most recent call last):
File "C:\Users\Natha Paquette\OneDrive - Sparx Services North America\Documents\AZDevOps\cx_freeze_broken\example_venv\Lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 120, in run
module_init.run(name + "__main__")
File "C:\Users\Natha Paquette\OneDrive - Sparx Services North America\Documents\AZDevOps\cx_freeze_broken\example_venv\Lib\site-packages\cx_Freeze\initscripts\Console.py", line 16, in run
exec(code, module_main.__dict__)
File "src\application\main.py", line 1, in <module>
ModuleNotFoundError: No module named 'application'
I have a similar or the same issue.
reporoot/
src/
main.py
lib/
module1.py
module2.py
if i build from setup.py in reporoot, the appication will not find modules 1 or 2. However, if i put setup.py in reporoot/src and build, it all works. I am open to suggestions that I'm using cx_freeze wrong as well as structured the repo wrong. cx_freeze 6.16.0.dev11 BTW, thanks for the option to build appimages, works like a charm :-) python 3.10 linux x86_64 6.5
setup.py:
import sys
from cx_Freeze import setup, Executable
script_path = "main.py"
include_files = ["lib/"]
exe = Executable(
script=script_path,
)
options = {
"build_exe": {
"includes": [],
"excludes": [],
"packages": ["pyabf", "neo", "tqdm", "sklearn"],
"include_files": include_files
}
}
setup(
name="Brainwash",
version="0.1",
description="",
options=options,
executables=[exe],
base=base
Sorry for the delay. Since the cx_Freeze 7.0 you can use include_path but it is broken for use in setup.py; works only as command line:
python setup.py build_exe --include-path=src
The fixed version will released in the next version.
So for @NaaN108 the setup.py
from cx_Freeze import setup, Executable
options = {
"build_exe": {
"zip_include_packages": ["*"],
"zip_exclude_packages": [],
"build_exe": "dist",
"include_path": ["src"],
}
}
setup(
name="centralized_integrations",
version="0.2",
description="description",
long_description="long description",
long_description_content_type="text/markdown",
author="name",
author_email="email",
url="url to project",
license="BSD 3-Clause License",
options=options,
executables=[Executable("src/application/cli/main.py", base=None)],
)
For @jontis
from cx_Freeze import setup, Executable
script_path = "src/main.py"
exe = Executable(
script=script_path,
)
options = {
"build_exe": {
"includes": [],
"excludes": [],
"packages": ["pyabf", "neo", "tqdm", "sklearn"],
"include_path": ["src", "src/lib"],
}
}
setup(
name="Brainwash",
version="0.1",
description="",
options=options,
executables=[exe],
base=base
)
Release 7.2.3 is out! Documentation
the
setup.py
file must exist in the root import source directory preventing project structures such assrc/application
where application is the sources root butsetup.py
is on the same level assrc/
package structure
cx_freeze_broken.zip
I'd like to have a way to maintain this package structure where src and setup.py are on the same level without changing the import structure.