Skip to content
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

setup.py must be in sources root #1554

Open
NaaN108 opened this issue Jul 18, 2022 · 3 comments
Open

setup.py must be in sources root #1554

NaaN108 opened this issue Jul 18, 2022 · 3 comments

Comments

@NaaN108
Copy link

NaaN108 commented Jul 18, 2022

the setup.py file must exist in the root import source directory preventing project structures such as src/application where application is the sources root but setup.py is on the same level as src/

package structure

src/
    application/
         __init__.py
        cli/
            __init__.py
            main.py
        controller/
            __init__.py
            math.py
setup.py

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.

  • Platform information: Windows 10
  • OS architecture: amd64
  • cx_Freeze version: 6.11.1
  • Python version: 3.8.10
@marcelotduarte
Copy link
Owner

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
)

@NaaN108
Copy link
Author

NaaN108 commented Aug 4, 2022

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'

@jontis
Copy link

jontis commented Nov 21, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants