-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[BUG] SetUpTools Auto Discovery - Won’t Disable #4703
Comments
Hi @ehkristen , could you please provide a mimum reproducible example so that we can investigate the issue? |
setuptools version Python version OS Additional environment information Description The relevant directory structure is as follows: .../src/backend:
I have a build.cmd file (with a _build.cmd file) which tries to install the modules/packages and then it is expected for it to import all the packages/ modules. The setup.py is: from setuptools import setup
Expected behavior How to Reproduce error: Multiple top-level modules discovered in a flat-layout: ['package_a', 'package_b', 'package_c', 'package_d', 'package_e', 'files'].
However, as of yet I have been unable to find any combination of setup.py options that allows the packages to be installed and all modules to be imported with a successful build. Either installation fails with the above error about the flat-layout, or the When I try to change the structure of the project, which is a less than desirable option, I am able to have the build go through, but the resulting executable Did I simply just not find the right combination of configuration to make this work? (I tried different options for numerous hours and even looked through the setuptools source code.) Output |
Umm... we probably need to further simplify this reproducer. As described in minimum reproducible example, we should remove anything that is not related to the investigation of the problem. This includes removing There seems to be a conceptual error in your The first time it includes In general it does not make sense to call the Also, please do not import Please find bellow a small example of how the example project would work once fixed the points discussed above and removed the unrelated > docker run --rm -it python:3.11-bookworm /bin/bash
mkdir /tmp/proj && cd /tmp/proj
mkdir package_a package_b package_c package_d package_e
touch package_a/__init__.py package_a/package_a.py
touch package_b/__init__.py package_b/package_b.py
touch package_c/__init__.py package_c/package_c.py
touch package_d/__init__.py package_d/package_d.py
touch package_e/__init__.py package_e/package_e.py
touch module_a.py
touch module_b.py
touch module_c.py
touch main.py
cat <<EOF > setup.py
import setuptools
setuptools.setup(
name="package",
author="<Name>",
author_email="<name>@<company>.com",
description="<description>",
long_description="long_description",
long_description_content_type="text/markdown",
packages= ['package_a', 'package_b', 'package_c', 'package_d', 'package_e'],
package_dir={"package_a":"package_a", "package_b":"package_b",
"package_c":"package_c", "package_d":"package_d",
"package_e":"package_e"},
py_modules=[ "module_a", "module_b", "module_c"],
# data_files=[ <os.walk of the file directory location, gathers all the file directories> ],
python_requires=">=3.6",
)
EOF
cat <<EOF > pyproject.toml
[build-system]
requires = ["setuptools>=75.2"]
build-backend = "setuptools.build_meta"
EOF
apt update -y
apt install tree
tree
# .
# ├── main.py
# ├── module_a.py
# ├── module_b.py
# ├── module_c.py
# ├── package_a
# │ ├── __init__.py
# │ └── package_a.py
# ├── package_b
# │ ├── __init__.py
# │ └── package_b.py
# ├── package_c
# │ ├── __init__.py
# │ └── package_c.py
# ├── package_d
# │ ├── __init__.py
# │ └── package_d.py
# ├── package_e
# │ ├── __init__.py
# │ └── package_e.py
# ├── pyproject.toml
# └── setup.py
python -m pip install .
# ...
# Successfully built package
# Installing collected packages: package
# Successfully installed package-0.0.0 Could you please try fixing the points discussed above? Let me know how it goes and feel free to close the issue if the changes suggested above are enough to fix the problems. Otherwise, if you want more help with the investigation, please make sure to provide an updated version of the reproducer, reduced to the minimum (without dependencies not maintained by setuptools such as |
Hi, sorry for the confusion! the second call at the bottom is part of the second portion of my setup call and is used to signify that I want the executable to be set to main.py (I did not include the parts below that line). The second call is using the distutils.core.setup the second call looks like this: Having both calls was not an issue with python 3.8 |
Hi @ehkristen , many things might be happening since you last tried with 3.8, including things "accidentally working", changes in the version of Please make sure that you include Moreover it is a good idea to have a look at any deprecation warnings and try to tackle them. If you don't plan to submit a new version of the reproducer, let's close this issue because we have exhausted the investigation for the given example. As I showed in my previous comment, once you fix the |
Hi @abravalheri , so I reworked everything, utilizing py2exe.freeze, but I'm experiencing an issue where the zipped library does not include the base python modules that are called in the script? (Example |
Hi @ehkristen, I will not be able to assist you with
|
Hi @abravalheri , is it possible to use setuptools to create an executable? From my understanding it does not make the executable? |
Setuptools allows specifying executable scripts to be installed alongside packages via entry-points: https://setuptools.pypa.io/en/latest/userguide/entry_point.html . Other than that, setuptools does not natively support creating single file executables. Other tools may use setuptools as an underlying step in this process, but that logic is not implemented in the setuptools repository. |
I’m experiencing an issue with setuptools, specifically that my directory layout is upsetting the auto discovery feature (for my packages and modules). The error I get is shown above, which instructs me to do one of three listed options… Option 2 is not an option for me. I tried setting up custom discovery which did not work (it still complained about the layout and ignored the exclude call). I also tried explicitly listing out the packages and modules, but it seemingly still tries to use auto discovery regardless….
I had my script working setuptools (using setup.py) with Python 3.8, but this issue is now occurring after upgrading to 3.11
Originally posted by @ehkristen in #4013 (comment)
The text was updated successfully, but these errors were encountered: