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

[Question] AttributeError: 'Extension' object has no attribute '_needs_stub' #4529

Closed
alexhutman opened this issue Jul 31, 2024 · 3 comments
Closed

Comments

@alexhutman
Copy link

alexhutman commented Jul 31, 2024

setuptools version

72.1.0

Python version

Python 3.11.1

OS

Ubuntu

Additional environment information

I am running Ubuntu via a Docker image that is based upon Sage 10.3.

Description

I saw issue #3339 -- I believe my scenario is different. I subclass build_ext, and therefore finalize_options() should be called normally. The build works fine during a normal build (pip install .), however using an editable build (pip install --editable .) produces the aforementioned error.

I have a fix for this lined up here. Please let me know if I am good to send in that PR. The install worked for me after changing those lines.

Expected behavior

I expected it to succeed just as it does while not building in --editable mode.

How to Reproduce

  1. Try this Minimum Example subclass (remembering to install --editable):
class zf_cythonize(build_ext):
    base_directives = dict(
         binding=False,
         language_level=3,
    )
    def run(self):
        dist = self.distribution
        ext_modules = dist.ext_modules
        if ext_modules:
            dist.ext_modules[:] = self.cythonize(ext_modules)
        super().run()

    def cythonize(self, extensions):
        # Run Cython with -Werror on continuous integration services
        # with Python 3.6 or later
        from Cython.Compiler import Options
        Options.warning_errors = False

        compiler_directives = dict(**self.base_directives)
        from Cython.Build.Dependencies import cythonize
        return cythonize(extensions,
                         compiler_directives=compiler_directives)

OR:

  1. Clone this repo and checkout a503769a4020b2a189703ce7e070062153ae1a69
  2. Build normally (docker build -t zeroforcing .). This should succeed with no problems.
  3. Change the Dockerfile to add --editable after pip install: sage -pip install --editable zeroforcing/
  4. Rerun and observe the error

Output

docker build -t zeroforcing .

[+] Building 6.3s (7/7) FINISHED                                                                                       docker:default
 => [internal] load build definition from Dockerfile                                                                             0.0s
 => => transferring dockerfile: 152B                                                                                             0.0s
 => [internal] load metadata for docker.io/sagemath/sagemath:10.3                                                                0.2s
 => [internal] load .dockerignore                                                                                                0.0s
 => => transferring context: 189B                                                                                                0.0s
 => [internal] load build context                                                                                                0.1s
 => => transferring context: 77.12kB                                                                                             0.1s
 => CACHED [1/3] FROM docker.io/sagemath/sagemath:10.3@sha256:aeefedc716b4f475ddc5f8d8140dbb231868b8a2e5882044845c83d41d1014a5   0.0s
 => [2/3] COPY --chown=sage:sage . ./zeroforcing                                                                                 0.2s
 => ERROR [3/3] RUN sage -pip install --editable zeroforcing/                                                                    5.9s
------
 > [3/3] RUN sage -pip install --editable zeroforcing/:
0.797 Obtaining file:///home/sage/zeroforcing
0.798   Preparing metadata (setup.py): started
1.033   Preparing metadata (setup.py): finished with status 'done'
1.068 Requirement already satisfied: setuptools>=60.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from zeroforcing==0.1.1) (69.0.2)
1.069 Requirement already satisfied: sagemath-standard in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from zeroforcing==0.1.1) (10.3)
1.070 Requirement already satisfied: Cython in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from zeroforcing==0.1.1) (3.0.7)
1.114 Requirement already satisfied: sage-conf~=10.3 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (10.3)
1.115 Requirement already satisfied: six>=1.15.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (1.16.0)
1.116 Requirement already satisfied: conway-polynomials>=0.8 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (0.8)
1.117 Requirement already satisfied: cypari2>=2.1.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (2.1.4)
1.118 Requirement already satisfied: cysignals>=1.10.2 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (1.11.4)
1.119 Requirement already satisfied: gmpy2~=2.1.b999 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (2.2.0a1)
1.120 Requirement already satisfied: jupyter_core>=4.6.3 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (5.3.2)
1.121 Requirement already satisfied: lrcalc~=2.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (2.1)
1.122 Requirement already satisfied: memory_allocator in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (0.1.3)
1.123 Requirement already satisfied: numpy>=1.19 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (1.26.3)
1.123 Requirement already satisfied: pkgconfig in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (1.5.5)
1.125 Requirement already satisfied: pplpy>=0.8.6 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (0.8.9)
1.125 Requirement already satisfied: primecountpy in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (0.1.0)
1.126 Requirement already satisfied: requests>=2.13.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (2.31.0)
1.127 Requirement already satisfied: ipython>=7.13.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (8.18.1)
1.128 Requirement already satisfied: pexpect>=4.8.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (4.9.0)
1.130 Requirement already satisfied: sphinx<8,>=5.2 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (7.2.6)
1.131 Requirement already satisfied: networkx<3.3,>=2.4 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (3.2.1)
1.132 Requirement already satisfied: scipy>=1.5 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (1.11.4)
1.133 Requirement already satisfied: sympy<2.0,>=1.6 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (1.12)
1.134 Requirement already satisfied: matplotlib>=3.5.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (3.8.0)
1.134 Requirement already satisfied: pillow>=7.2.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (10.1.0)
1.135 Requirement already satisfied: mpmath>=1.1.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (1.3.0)
1.136 Requirement already satisfied: ipykernel>=5.2.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (6.27.1)
1.137 Requirement already satisfied: jupyter-client in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (8.3.1)
1.138 Requirement already satisfied: ipywidgets>=7.5.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (8.1.1)
1.139 Requirement already satisfied: fpylll>=0.5.9 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (0.6.0)
1.140 Requirement already satisfied: ptyprocess>0.5 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sagemath-standard->zeroforcing==0.1.1) (0.7.0)
1.165 Requirement already satisfied: comm>=0.1.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (0.1.4)
1.166 Requirement already satisfied: debugpy>=1.6.5 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (1.8.0)
1.168 Requirement already satisfied: matplotlib-inline>=0.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (0.1.6)
1.168 Requirement already satisfied: nest-asyncio in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (1.5.8)
1.169 Requirement already satisfied: packaging in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (23.2)
1.170 Requirement already satisfied: psutil in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (5.9.6)
1.170 Requirement already satisfied: pyzmq>=20 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (25.1.1)
1.171 Requirement already satisfied: tornado>=6.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (6.4)
1.172 Requirement already satisfied: traitlets>=5.4.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipykernel>=5.2.1->sagemath-standard->zeroforcing==0.1.1) (5.14.0)
1.222 Requirement already satisfied: decorator in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (5.1.1)
1.224 Requirement already satisfied: jedi>=0.16 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (0.19.1)
1.225 Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (3.0.43)
1.226 Requirement already satisfied: pygments>=2.4.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (2.17.2)
1.228 Requirement already satisfied: stack-data in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (0.6.3)
1.242 Requirement already satisfied: widgetsnbextension~=4.0.9 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipywidgets>=7.5.1->sagemath-standard->zeroforcing==0.1.1) (4.0.9)
1.243 Requirement already satisfied: jupyterlab-widgets~=3.0.9 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from ipywidgets>=7.5.1->sagemath-standard->zeroforcing==0.1.1) (3.0.9)
1.265 Requirement already satisfied: python-dateutil>=2.8.2 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from jupyter-client->sagemath-standard->zeroforcing==0.1.1) (2.8.2)
1.279 Requirement already satisfied: platformdirs>=2.5 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from jupyter_core>=4.6.3->sagemath-standard->zeroforcing==0.1.1) (4.1.0)
1.288 Requirement already satisfied: contourpy>=1.0.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from matplotlib>=3.5.1->sagemath-standard->zeroforcing==0.1.1) (1.1.1)
1.289 Requirement already satisfied: cycler>=0.10 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from matplotlib>=3.5.1->sagemath-standard->zeroforcing==0.1.1) (0.11.0)
1.292 Requirement already satisfied: fonttools>=4.22.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from matplotlib>=3.5.1->sagemath-standard->zeroforcing==0.1.1) (4.42.1)
1.293 Requirement already satisfied: kiwisolver>=1.0.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from matplotlib>=3.5.1->sagemath-standard->zeroforcing==0.1.1) (1.4.5)
1.295 Requirement already satisfied: pyparsing>=2.3.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from matplotlib>=3.5.1->sagemath-standard->zeroforcing==0.1.1) (3.1.1)
1.340 Requirement already satisfied: charset-normalizer<4,>=2 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from requests>=2.13.0->sagemath-standard->zeroforcing==0.1.1) (3.3.2)
1.341 Requirement already satisfied: idna<4,>=2.5 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from requests>=2.13.0->sagemath-standard->zeroforcing==0.1.1) (3.6)
1.341 Requirement already satisfied: urllib3<3,>=1.21.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from requests>=2.13.0->sagemath-standard->zeroforcing==0.1.1) (2.1.0)
1.342 Requirement already satisfied: certifi>=2017.4.17 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from requests>=2.13.0->sagemath-standard->zeroforcing==0.1.1) (2023.11.17)
1.381 Requirement already satisfied: sphinxcontrib-applehelp in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (1.0.8)
1.381 Requirement already satisfied: sphinxcontrib-devhelp in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (1.0.6)
1.382 Requirement already satisfied: sphinxcontrib-jsmath in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (1.0.1)
1.383 Requirement already satisfied: sphinxcontrib-htmlhelp>=2.0.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (2.0.5)
1.384 Requirement already satisfied: sphinxcontrib-serializinghtml>=1.1.9 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (1.1.10)
1.385 Requirement already satisfied: sphinxcontrib-qthelp in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (1.0.7)
1.386 Requirement already satisfied: Jinja2>=3.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (3.1.3)
1.387 Requirement already satisfied: docutils<0.21,>=0.18.1 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (0.20.1)
1.388 Requirement already satisfied: snowballstemmer>=2.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (2.2.0)
1.388 Requirement already satisfied: babel>=2.9 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (2.14.0)
1.389 Requirement already satisfied: alabaster<0.8,>=0.7 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (0.7.16)
1.390 Requirement already satisfied: imagesize>=1.3 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (1.4.1)
1.493 Requirement already satisfied: parso<0.9.0,>=0.8.3 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from jedi>=0.16->ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (0.8.3)
1.498 Requirement already satisfied: MarkupSafe>=2.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from Jinja2>=3.0->sphinx<8,>=5.2->sagemath-standard->zeroforcing==0.1.1) (2.1.4)
1.522 Requirement already satisfied: wcwidth in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (0.2.12)
1.620 Requirement already satisfied: executing>=1.2.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from stack-data->ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (1.2.0)
1.620 Requirement already satisfied: asttokens>=2.1.0 in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from stack-data->ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (2.4.1)
1.621 Requirement already satisfied: pure-eval in ./sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages (from stack-data->ipython>=7.13.0->sagemath-standard->zeroforcing==0.1.1) (0.2.2)
2.404 Installing collected packages: zeroforcing
2.405   Running setup.py develop for zeroforcing
5.810     error: subprocess-exited-with-error
5.810
5.810     × python setup.py develop did not run successfully.
5.810     Γöé exit code: 1
5.810     Γò░ΓöÇ> [102 lines of output]
5.810         running develop
5.810         /home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/develop.py:39: EasyInstallDeprecationWarning: easy_install command is deprecated.
5.810         !!
5.810
5.810                 ********************************************************************************
5.810                 Please avoid running ``setup.py`` and ``easy_install``.
5.810                 Instead, use pypa/build, pypa/installer or other
5.810                 standards-based tools.
5.810
5.810                 See https://github.com/pypa/setuptools/issues/917 for details.
5.810                 ********************************************************************************
5.810
5.810         !!
5.810           easy_install.initialize_options(self)
5.810         /home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
5.810         !!
5.810
5.810                 ********************************************************************************
5.810                 Please avoid running ``setup.py`` directly.
5.810                 Instead, use pypa/build, pypa/installer or other
5.810                 standards-based tools.
5.810
5.810                 See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
5.810                 ********************************************************************************
5.810
5.810         !!
5.810           self.initialize_options()
5.810         running egg_info
5.810         writing src/zeroforcing.egg-info/PKG-INFO
5.810         writing dependency_links to src/zeroforcing.egg-info/dependency_links.txt
5.810         writing requirements to src/zeroforcing.egg-info/requires.txt
5.810         writing top-level names to src/zeroforcing.egg-info/top_level.txt
5.810         reading manifest file 'src/zeroforcing.egg-info/SOURCES.txt'
5.810         reading manifest template 'MANIFEST.in'
5.810         no previously-included directories found matching 'build'
5.810         no previously-included directories found matching 'dist'
5.810         adding license file 'LICENSE'
5.810         writing manifest file 'src/zeroforcing.egg-info/SOURCES.txt'
5.810         running build_ext
5.810         INFO: Disabling color, you really want to install colorlog.
5.810         Disabling color, you really want to install colorlog.
5.810         Compiling src/zeroforcing/fastqueue.pyx because it changed.
5.810         Compiling src/zeroforcing/metagraph.pyx because it changed.
5.810         [1/2] Cythonizing src/zeroforcing/fastqueue.pyx
5.810         [2/2] Cythonizing src/zeroforcing/metagraph.pyx
5.810         running build_cython
5.810         Enabling Cython debugging support
5.810         Updating Cython code....
5.810         Finished Cythonizing, time: 0.09 seconds.
5.810         building 'zeroforcing.fastqueue' extension
5.810         building 'zeroforcing.metagraph' extension
5.810         Executing 2 commands (using 1 thread)
5.810         [1/2] creating build/temp.linux-x86_64-cpython-311/src
5.810         creating build/temp.linux-x86_64-cpython-311/src/zeroforcing
5.810         gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -g -O2 -fPIC -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11 -c src/zeroforcing/fastqueue.c -o build/temp.linux-x86_64-cpython-311/src/zeroforcing/fastqueue.o
5.810         gcc -shared -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -Wl,-rpath,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -L. -Wl,-rpath,. -L/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib build/temp.linux-x86_64-cpython-311/src/zeroforcing/fastqueue.o -L/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -o build/lib.linux-x86_64-cpython-311/zeroforcing/fastqueue.cpython-311-x86_64-linux-gnu.so
5.810         [2/2] gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -g -O2 -fPIC -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/data_structures -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/cysignals -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11 -c src/zeroforcing/metagraph.c -o build/temp.linux-x86_64-cpython-311/src/zeroforcing/metagraph.o
5.810         gcc -shared -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -Wl,-rpath,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -L. -Wl,-rpath,. -L/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib build/temp.linux-x86_64-cpython-311/src/zeroforcing/metagraph.o -L/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -lgmp -o build/lib.linux-x86_64-cpython-311/zeroforcing/metagraph.cpython-311-x86_64-linux-gnu.so -lpari
5.810         Time to execute 2 commands: 2.12 seconds.
5.810         Total time spent compiling C/C++ extensions: 2.12 seconds.
5.810         copying build/lib.linux-x86_64-cpython-311/zeroforcing/fastqueue.cpython-311-x86_64-linux-gnu.so -> src/zeroforcing
5.810         Traceback (most recent call last):
5.810           File "<string>", line 2, in <module>
5.810           File "<pip-setuptools-caller>", line 34, in <module>
5.810           File "/home/sage/zeroforcing/setup.py", line 112, in <module>
5.810             main()
5.810           File "/home/sage/zeroforcing/setup.py", line 109, in main
5.810             setup(**get_setup_parameters(extensions))
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
5.810             return distutils.core.setup(**attrs)
5.810                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
5.810             return run_commands(dist)
5.810                    ^^^^^^^^^^^^^^^^^^
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
5.810             dist.run_commands()
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
5.810             self.run_command(cmd)
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
5.810             super().run_command(command)
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
5.810             cmd_obj.run()
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/develop.py", line 33, in run
5.810             self.install_for_development()
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/develop.py", line 108, in install_for_development
5.810             self.run_command('build_ext')
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
5.810             self.distribution.run_command(command)
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
5.810             super().run_command(command)
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
5.810             cmd_obj.run()
5.810           File "/home/sage/zeroforcing/setup.py", line 43, in run
5.810             super().run()
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage_setup/command/sage_build_ext.py", line 26, in run
5.810             build_ext.run(self)
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 91, in run
5.810             self.copy_extensions_to_source()
5.810           File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 114, in copy_extensions_to_source
5.810             if ext._needs_stub:
5.810                ^^^^^^^^^^^^^^^
5.810         AttributeError: 'Extension' object has no attribute '_needs_stub'
5.810         [end of output]
5.810
5.810     note: This error originates from a subprocess, and is likely not a problem with pip.
5.815 error: subprocess-exited-with-error
5.815
5.815 × python setup.py develop did not run successfully.
5.815 Γöé exit code: 1
5.815 Γò░ΓöÇ> [102 lines of output]
5.815     running develop
5.815     /home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/develop.py:39: EasyInstallDeprecationWarning: easy_install command is deprecated.
5.815     !!
5.815
5.815             ********************************************************************************
5.815             Please avoid running ``setup.py`` and ``easy_install``.
5.815             Instead, use pypa/build, pypa/installer or other
5.815             standards-based tools.
5.815
5.815             See https://github.com/pypa/setuptools/issues/917 for details.
5.815             ********************************************************************************
5.815
5.815     !!
5.815       easy_install.initialize_options(self)
5.815     /home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
5.815     !!
5.815
5.815             ********************************************************************************
5.815             Please avoid running ``setup.py`` directly.
5.815             Instead, use pypa/build, pypa/installer or other
5.815             standards-based tools.
5.815
5.815             See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
5.815             ********************************************************************************
5.815
5.815     !!
5.815       self.initialize_options()
5.815     running egg_info
5.815     writing src/zeroforcing.egg-info/PKG-INFO
5.815     writing dependency_links to src/zeroforcing.egg-info/dependency_links.txt
5.815     writing requirements to src/zeroforcing.egg-info/requires.txt
5.815     writing top-level names to src/zeroforcing.egg-info/top_level.txt
5.815     reading manifest file 'src/zeroforcing.egg-info/SOURCES.txt'
5.815     reading manifest template 'MANIFEST.in'
5.815     no previously-included directories found matching 'build'
5.815     no previously-included directories found matching 'dist'
5.815     adding license file 'LICENSE'
5.815     writing manifest file 'src/zeroforcing.egg-info/SOURCES.txt'
5.815     running build_ext
5.815     INFO: Disabling color, you really want to install colorlog.
5.815     Disabling color, you really want to install colorlog.
5.815     Compiling src/zeroforcing/fastqueue.pyx because it changed.
5.815     Compiling src/zeroforcing/metagraph.pyx because it changed.
5.815     [1/2] Cythonizing src/zeroforcing/fastqueue.pyx
5.815     [2/2] Cythonizing src/zeroforcing/metagraph.pyx
5.815     running build_cython
5.815     Enabling Cython debugging support
5.815     Updating Cython code....
5.815     Finished Cythonizing, time: 0.09 seconds.
5.815     building 'zeroforcing.fastqueue' extension
5.815     building 'zeroforcing.metagraph' extension
5.815     Executing 2 commands (using 1 thread)
5.815     [1/2] creating build/temp.linux-x86_64-cpython-311/src
5.815     creating build/temp.linux-x86_64-cpython-311/src/zeroforcing
5.815     gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -g -O2 -fPIC -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11 -c src/zeroforcing/fastqueue.c -o build/temp.linux-x86_64-cpython-311/src/zeroforcing/fastqueue.o
5.815     gcc -shared -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -Wl,-rpath,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -L. -Wl,-rpath,. -L/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib build/temp.linux-x86_64-cpython-311/src/zeroforcing/fastqueue.o -L/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -o build/lib.linux-x86_64-cpython-311/zeroforcing/fastqueue.cpython-311-x86_64-linux-gnu.so
5.815     [2/2] gcc -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wno-unused -g -O2 -fPIC -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/data_structures -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/cysignals -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/cpython -I/home/sage/sage/local/var/lib/sage/venv-python3.11.1/include/python3.11 -c src/zeroforcing/metagraph.c -o build/temp.linux-x86_64-cpython-311/src/zeroforcing/metagraph.o
5.815     gcc -shared -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -Wl,-rpath,/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -L. -Wl,-rpath,. -L/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib -Wl,-rpath-link,/home/sage/sage/local/lib -L/home/sage/sage/local/lib -Wl,-rpath,/home/sage/sage/local/lib build/temp.linux-x86_64-cpython-311/src/zeroforcing/metagraph.o -L/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib -lgmp -o build/lib.linux-x86_64-cpython-311/zeroforcing/metagraph.cpython-311-x86_64-linux-gnu.so -lpari
5.815     Time to execute 2 commands: 2.12 seconds.
5.815     Total time spent compiling C/C++ extensions: 2.12 seconds.
5.815     copying build/lib.linux-x86_64-cpython-311/zeroforcing/fastqueue.cpython-311-x86_64-linux-gnu.so -> src/zeroforcing
5.815     Traceback (most recent call last):
5.815       File "<string>", line 2, in <module>
5.815       File "<pip-setuptools-caller>", line 34, in <module>
5.815       File "/home/sage/zeroforcing/setup.py", line 112, in <module>
5.815         main()
5.815       File "/home/sage/zeroforcing/setup.py", line 109, in main
5.815         setup(**get_setup_parameters(extensions))
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/__init__.py", line 103, in setup
5.815         return distutils.core.setup(**attrs)
5.815                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
5.815         return run_commands(dist)
5.815                ^^^^^^^^^^^^^^^^^^
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
5.815         dist.run_commands()
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
5.815         self.run_command(cmd)
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
5.815         super().run_command(command)
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
5.815         cmd_obj.run()
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/develop.py", line 33, in run
5.815         self.install_for_development()
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/develop.py", line 108, in install_for_development
5.815         self.run_command('build_ext')
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
5.815         self.distribution.run_command(command)
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/dist.py", line 963, in run_command
5.815         super().run_command(command)
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
5.815         cmd_obj.run()
5.815       File "/home/sage/zeroforcing/setup.py", line 43, in run
5.815         super().run()
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage_setup/command/sage_build_ext.py", line 26, in run
5.815         build_ext.run(self)
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 91, in run
5.815         self.copy_extensions_to_source()
5.815       File "/home/sage/sage/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 114, in copy_extensions_to_source
5.815         if ext._needs_stub:
5.815            ^^^^^^^^^^^^^^^
5.815     AttributeError: 'Extension' object has no attribute '_needs_stub'
5.815     [end of output]
5.815
5.815 note: This error originates from a subprocess, and is likely not a problem with pip.
------
Dockerfile:5
--------------------
   3 |     COPY --chown=sage:sage . ./zeroforcing
   4 |
   5 | >>> RUN sage -pip install --editable zeroforcing/
   6 |
--------------------
ERROR: failed to solve: process "/bin/sh -c sage -pip install --editable zeroforcing/" did not complete successfully: exit code: 1
@alexhutman alexhutman added bug Needs Triage Issues that need to be evaluated for severity and status. labels Jul 31, 2024
@abravalheri
Copy link
Contributor

abravalheri commented Jul 31, 2024

Hi @alexhutman, I think the preferred solution here is very similar to the one in #3339: finalize_options() (and super().finalize_options() if the method is being overwritten) should be called before the command is used.

In principle editable_wheel does call finalize_options of any build command via https://github.com/pypa/setuptools/blob/v72.1.0/setuptools/command/editable_wheel.py#L301 (see https://github.com/pypa/setuptools/blob/v72.1.0/setuptools/_distutils/cmd.py#L303 and https://github.com/pypa/setuptools/blob/v72.1.0/setuptools/_distutils/cmd.py#L111).

So my question is: is the class that you are inheriting build_ext from setuptools itself? Or if not, does that class calls super().finalize_options()? A quick look into https://github.com/sagemath/sage/blob/10.4/src/sage_setup/command/sage_build_ext.py#L20 seems to indicate that this is true...

So, I realised that you are editing the ext_modules property after finalize_options() has already been called. That seems to be the origin of the problem because it puts the command and extension objects in an inconsistent state.

Could you please make sure that you modify ext_modules before finalize_options has been called?

@abravalheri abravalheri removed bug Needs Triage Issues that need to be evaluated for severity and status. labels Jul 31, 2024
@abravalheri abravalheri changed the title [BUG] AttributeError: 'Extension' object has no attribute '_needs_stub' [Question] AttributeError: 'Extension' object has no attribute '_needs_stub' Jul 31, 2024
@alexhutman
Copy link
Author

Hi @abravalheri, my mistake -- apologies for the noise. I was looking at this note in the setuptools docs:

Side effects SHOULD only take place when run is executed, for example, creating new files or writing to the terminal output

The code works great now that the Cythonization is in finalize_options(). This makes sense now that you bring up the inconsistent state. Thank you for your help!

@abravalheri
Copy link
Contributor

You probably could also try to re-run finalize_options() again if you modify the command options/attributes, but I have not checked that.

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

2 participants