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

Build error with the latest setuptool #4539

Closed
justinchuby opened this issue Sep 23, 2022 · 3 comments · Fixed by #5558 or #4879
Closed

Build error with the latest setuptool #4539

justinchuby opened this issue Sep 23, 2022 · 3 comments · Fixed by #5558 or #4879
Assignees
Labels
bug topic: build Issues related to ONNX builds and packages
Milestone

Comments

@justinchuby
Copy link
Contributor

Bug Report

Is the issue related to model conversion?

No

Describe the bug

Building from source with pip install -e . resulted in an error with the latest setuptool.

Running

 SETUPTOOLS_ENABLE_FEATURES="legacy-editable" pip install -e .

works.

System information

  • OS Platform and Distribution (e.g. Linux Ubuntu 16.04): Linux Ubuntu
  • ONNX version (e.g. 1.7): master
  • Python version: 3.10.7
  • GCC/Compiler version (if compiling from source):
  • CMake version:
  • Protobuf version:
  • Visual Studio version (if applicable):
Package                      Version   Editable project location
---------------------------- --------- -------------------------
absl-py                      1.2.0
astunparse                   1.6.3
cachetools                   5.2.0
certifi                      2022.9.14
charset-normalizer           2.1.1
contourpy                    1.0.5
cycler                       0.11.0
etils                        0.8.0
flatbuffers                  2.0.7
fonttools                    4.37.3
gast                         0.4.0
google-auth                  2.11.1
google-auth-oauthlib         0.4.6
google-pasta                 0.2.0
grpcio                       1.48.1
h5py                         3.7.0
idna                         3.4
importlib-resources          5.9.0
jax                          0.3.17
jaxlib                       0.3.15
joblib                       1.2.0
keras                        2.10.0
Keras-Preprocessing          1.1.2
kiwisolver                   1.4.4
libclang                     14.0.6
Markdown                     3.4.1
MarkupSafe                   2.1.1
matplotlib                   3.6.0
numpy                        1.23.3
oauthlib                     3.2.1
onnx                         1.12.0    /workspaces/onnx
opt-einsum                   3.3.0
packaging                    21.3
pandas                       1.5.0
Pillow                       9.2.0
pip                          22.2.2
plotly                       5.10.0
protobuf                     3.19.5
pyasn1                       0.4.8
pyasn1-modules               0.2.8
pyparsing                    3.0.9
python-dateutil              2.8.2
pytz                         2022.2.1
requests                     2.28.1
requests-oauthlib            1.3.1
rsa                          4.9
scikit-learn                 1.1.2
scipy                        1.9.1
seaborn                      0.12.0
setuptools                   65.3.0
six                          1.16.0
tenacity                     8.0.1
tensorboard                  2.10.0
tensorboard-data-server      0.6.1
tensorboard-plugin-wit       1.8.1
tensorflow                   2.10.0
tensorflow-estimator         2.10.0
tensorflow-io-gcs-filesystem 0.27.0
termcolor                    2.0.1
threadpoolctl                3.1.0
torch                        1.12.1
typing_extensions            4.3.0
urllib3                      1.26.12
Werkzeug                     2.2.2
wheel                        0.37.1
wrapt                        1.14.1
zipp                         3.8.1

Reproduction instructions

pip install -e .

Expected behavior

Notes

Building wheels for collected packages: onnx
  Building editable for onnx (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building editable for onnx (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [114 lines of output]
      running editable_wheel
      creating /tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info
      writing /tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/dependency_links.txt
      writing entry points to /tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/entry_points.txt
      writing requirements to /tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/requires.txt
      writing top-level names to /tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/top_level.txt
      writing manifest file '/tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/SOURCES.txt'
      reading manifest file '/tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no files found matching '*.c' under directory 'onnx'
      adding license file 'LICENSE'
      writing manifest file '/tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx.egg-info/SOURCES.txt'
      creating '/tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx-1.12.0.dist-info'
      adding license file "LICENSE" (matched pattern "LICENSE")
      creating /tmp/pip-wheel-2mha55tp/tmpkm5xxdfk/onnx-1.12.0.dist-info/WHEEL
      /tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build_py
      running create_version
      running cmake_build
      Extra cmake args: ['-DONNX_USE_PROTOBUF_SHARED_LIBS=ON']
      Using cmake args: ['/usr/bin/cmake', '-DPYTHON_INCLUDE_DIR=/usr/local/python/3.10.7/include/python3.10', '-DPYTHON_EXECUTABLE=/usr/local/python/3.10.7/bin/python3.10', '-DBUILD_ONNX_PYTHON=ON', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DONNX_NAMESPACE=onnx', '-DPY_EXT_SUFFIX=.cpython-310-x86_64-linux-gnu.so', '-DCMAKE_BUILD_TYPE=Release', '-DONNX_ML=1', '-DONNX_USE_PROTOBUF_SHARED_LIBS=ON', '/workspaces/onnx']
      Generated: /workspaces/onnx/.setuptools-cmake-build/onnx/onnx-ml.proto
      Generated: /workspaces/onnx/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
      Generated: /workspaces/onnx/.setuptools-cmake-build/onnx/onnx-data.proto
      -- Could NOT find pybind11 (missing: pybind11_DIR)
      -- pybind11 v2.9.1
      --
      -- ******** Summary ********
      --   CMake version             : 3.16.3
      --   CMake command             : /usr/bin/cmake
      --   System                    : Linux
      --   C++ compiler              : /usr/bin/c++
      --   C++ compiler version      : 9.4.0
      --   CXX flags                 :  -Wnon-virtual-dtor
      --   Build type                : Release
      --   Compile definitions       : __STDC_FORMAT_MACROS
      --   CMAKE_PREFIX_PATH         :
      --   CMAKE_INSTALL_PREFIX      : /usr/local
      --   CMAKE_MODULE_PATH         :
      --
      --   ONNX version              : 1.12.0
      --   ONNX NAMESPACE            : onnx
      --   ONNX_USE_LITE_PROTO       : OFF
      --   USE_PROTOBUF_SHARED_LIBS  : ON
      --   Protobuf_USE_STATIC_LIBS  : OFF
      --   ONNX_DISABLE_EXCEPTIONS   : OFF
      --   ONNX_WERROR               : OFF
      --   ONNX_BUILD_TESTS          : OFF
      --   ONNX_BUILD_BENCHMARKS     : OFF
      --
      --   Protobuf compiler         : /usr/bin/protoc
      --   Protobuf includes         : /usr/include
      --   Protobuf libraries        : /usr/lib/x86_64-linux-gnu/libprotobuf.so;-lpthread
      --   BUILD_ONNX_PYTHON         : ON
      --     Python version        :
      --     Python executable     : /usr/local/python/3.10.7/bin/python3.10
      --     Python includes       : /usr/local/python/3.10.7/include/python3.10
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /workspaces/onnx/.setuptools-cmake-build
      [  3%] Built target gen_onnx_proto
      [  6%] Built target gen_onnx_data_proto
      [  9%] Built target gen_onnx_operators_proto
      [ 24%] Built target onnx_proto
      [ 96%] Built target onnx
      [100%] Built target onnx_cpp2py_export
      running build_ext
      copying /workspaces/onnx/.setuptools-cmake-build/onnx_cpp2py_export.cpython-310-x86_64-linux-gnu.so -> /tmp/tmpksx5ht08.build-lib/onnx
      Traceback (most recent call last):
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/_distutils/file_util.py", line 40, in _copy_file_contents
          fdst = open(dst, 'wb')
      FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpksx5ht08.build-lib/onnx/onnx_cpp2py_export.cpython-310-x86_64-linux-gnu.so'
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 140, in run
          self._create_wheel_file(bdist_wheel)
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 330, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 261, in _run_build_commands
          self._run_build_subcommands()
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/command/editable_wheel.py", line 288, in _run_build_subcommands
          self.run_command(name)
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/dist.py", line 1217, in run_command
          super().run_command(command)
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 992, in run_command
          cmd_obj.run()
        File "<string>", line 255, in run
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 84, in run
          _build_ext.run(self)
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
          self.build_extensions()
        File "<string>", line 272, in build_extensions
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 351, in copy_file
          return file_util.copy_file(
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/_distutils/file_util.py", line 163, in copy_file
          _copy_file_contents(src, dst)
        File "/tmp/pip-build-env-5rbu00q6/overlay/lib/python3.10/site-packages/setuptools/_distutils/file_util.py", line 42, in _copy_file_contents
          raise DistutilsFileError(
      distutils.errors.DistutilsFileError: could not create '/tmp/tmpksx5ht08.build-lib/onnx/onnx_cpp2py_export.cpython-310-x86_64-linux-gnu.so': No such file or directory
      error: Support for editable installs via PEP 660 was recently introduced
      in `setuptools`. If you are seeing this error, please report to:
      
      https://github.com/pypa/setuptools/issues
      
      Meanwhile you can try the legacy behavior by setting an
      environment variable and trying to install again:
      
      SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building editable for onnx
Failed to build onnx
ERROR: Could not build wheels for onnx, which is required to install pyproject.toml-based projects
@jcwchen
Copy link
Member

jcwchen commented Sep 23, 2022

This break happened after this PR: #4361, probably related to introduced pyproject.toml file. Still investigating.

@jcwchen
Copy link
Member

jcwchen commented Sep 29, 2022

#4558 would be a quick workaround to make onnx build forcely use old legacy development mode for now, but in the long term we should modify the existing build logic to enable the latest editable_mode if it is beneficial.

@jcwchen jcwchen linked a pull request Sep 5, 2023 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Sep 5, 2023
### Description
<!-- - Describe your changes. -->

- Move much of the metadata from setup.py to pyproject.toml. Setuptools
commands are left unchanged.
- Replace `--weekly_build` with the env var `ONNX_PREVIEW_BUILD`.
Version number verified locally and in CI.
	> **Note**
> Due to `pyproject.toml` limitation, we need to use a script to rename
the package for the weekly build.
> On Windows, it is `(Get-Content -Path 'pyproject.toml') |
ForEach-Object { $_ -replace 'name = "onnx"', 'name = "onnx-weekly"' } |
Set-Content -Path 'pyproject.toml'`
> On linux, it is `sed -i 's/name = "onnx"/name = "onnx-weekly"/'
'pyproject.toml'`
	> Tested locally.
- Replace all `setup.py xxx` usage with `pip install` or `python -m
build` according to setuptools' suggestions.
- The MacOS wheel's platform name needs to be tweaked. Previously it was
modified by supplying the `-p` or `--plat-name` option to `setup.py`.
Now that we use `python -m build`, I created an env var
`ONNX_WHEEL_PLATFORM_NAME` and supply it via the `setup` call:
    ```
	setuptools.setup(
	    ...
	    options={"bdist_wheel": {"plat_name": ONNX_WHEEL_PLATFORM_NAME}}
	    if ONNX_WHEEL_PLATFORM_NAME is not None
	    else {},
	)
	```

### Motivation and Context
<!-- - Why is this change required? What problem does it solve? -->
<!-- - If it fixes an open issue, please link to the issue here. -->

https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

> Starting with [PEP 621](https://peps.python.org/pep-0621/), the Python
community selected pyproject.toml as a standard way of specifying
project metadata. Setuptools has adopted this standard and will use the
information contained in this file as an input in the build process.

https://pypi.org/project/pytest-runner/

> It is recommended that you:
> Remove 'pytest-runner' from your setup_requires, preferably removing
the setup_requires option.
> Remove 'pytest' and any other testing requirements from tests_require,
preferably removing the tests_requires option.
> Select a tool to bootstrap and then run tests such as tox.

fix #4878 and #4539

---------

Signed-off-by: Justin Chu <justinchu@microsoft.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
github-merge-queue bot pushed a commit that referenced this issue Sep 5, 2023
### Description
<!-- - Describe your changes. -->

- Move much of the metadata from setup.py to pyproject.toml. Setuptools
commands are left unchanged.
- Replace `--weekly_build` with the env var `ONNX_PREVIEW_BUILD`.
Version number verified locally and in CI.
	> **Note**
> Due to `pyproject.toml` limitation, we need to use a script to rename
the package for the weekly build.
> On Windows, it is `(Get-Content -Path 'pyproject.toml') |
ForEach-Object { $_ -replace 'name = "onnx"', 'name = "onnx-weekly"' } |
Set-Content -Path 'pyproject.toml'`
> On linux, it is `sed -i 's/name = "onnx"/name = "onnx-weekly"/'
'pyproject.toml'`
	> Tested locally.
- Replace all `setup.py xxx` usage with `pip install` or `python -m
build` according to setuptools' suggestions.
- The MacOS wheel's platform name needs to be tweaked. Previously it was
modified by supplying the `-p` or `--plat-name` option to `setup.py`.
Now that we use `python -m build`, I created an env var
`ONNX_WHEEL_PLATFORM_NAME` and supply it via the `setup` call:
    ```
	setuptools.setup(
	    ...
	    options={"bdist_wheel": {"plat_name": ONNX_WHEEL_PLATFORM_NAME}}
	    if ONNX_WHEEL_PLATFORM_NAME is not None
	    else {},
	)
	```

### Motivation and Context
<!-- - Why is this change required? What problem does it solve? -->
<!-- - If it fixes an open issue, please link to the issue here. -->

https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

> Starting with [PEP 621](https://peps.python.org/pep-0621/), the Python
community selected pyproject.toml as a standard way of specifying
project metadata. Setuptools has adopted this standard and will use the
information contained in this file as an input in the build process.

https://pypi.org/project/pytest-runner/

> It is recommended that you:
> Remove 'pytest-runner' from your setup_requires, preferably removing
the setup_requires option.
> Remove 'pytest' and any other testing requirements from tests_require,
preferably removing the tests_requires option.
> Select a tool to bootstrap and then run tests such as tox.

fix #4878 and #4539

---------

Signed-off-by: Justin Chu <justinchu@microsoft.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@jcwchen
Copy link
Member

jcwchen commented Sep 5, 2023

It is still open and waiting for #5558.

@jcwchen jcwchen reopened this Sep 5, 2023
@justinchuby justinchuby self-assigned this Sep 5, 2023
@justinchuby justinchuby added the topic: build Issues related to ONNX builds and packages label Sep 5, 2023
corwinjoy pushed a commit to corwinjoy/onnx that referenced this issue Sep 5, 2023
### Description
<!-- - Describe your changes. -->

- Move much of the metadata from setup.py to pyproject.toml. Setuptools
commands are left unchanged.
- Replace `--weekly_build` with the env var `ONNX_PREVIEW_BUILD`.
Version number verified locally and in CI.
	> **Note**
> Due to `pyproject.toml` limitation, we need to use a script to rename
the package for the weekly build.
> On Windows, it is `(Get-Content -Path 'pyproject.toml') |
ForEach-Object { $_ -replace 'name = "onnx"', 'name = "onnx-weekly"' } |
Set-Content -Path 'pyproject.toml'`
> On linux, it is `sed -i 's/name = "onnx"/name = "onnx-weekly"/'
'pyproject.toml'`
	> Tested locally.
- Replace all `setup.py xxx` usage with `pip install` or `python -m
build` according to setuptools' suggestions.
- The MacOS wheel's platform name needs to be tweaked. Previously it was
modified by supplying the `-p` or `--plat-name` option to `setup.py`.
Now that we use `python -m build`, I created an env var
`ONNX_WHEEL_PLATFORM_NAME` and supply it via the `setup` call:
    ```
	setuptools.setup(
	    ...
	    options={"bdist_wheel": {"plat_name": ONNX_WHEEL_PLATFORM_NAME}}
	    if ONNX_WHEEL_PLATFORM_NAME is not None
	    else {},
	)
	```

### Motivation and Context
<!-- - Why is this change required? What problem does it solve? -->
<!-- - If it fixes an open issue, please link to the issue here. -->

https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

> Starting with [PEP 621](https://peps.python.org/pep-0621/), the Python
community selected pyproject.toml as a standard way of specifying
project metadata. Setuptools has adopted this standard and will use the
information contained in this file as an input in the build process.

https://pypi.org/project/pytest-runner/

> It is recommended that you:
> Remove 'pytest-runner' from your setup_requires, preferably removing
the setup_requires option.
> Remove 'pytest' and any other testing requirements from tests_require,
preferably removing the tests_requires option.
> Select a tool to bootstrap and then run tests such as tox.

fix onnx#4878 and onnx#4539

---------

Signed-off-by: Justin Chu <justinchu@microsoft.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Corwin Joy <corwinjoy@gmail.com>
corwinjoy pushed a commit to corwinjoy/onnx that referenced this issue Sep 5, 2023
### Description
<!-- - Describe your changes. -->

- Move much of the metadata from setup.py to pyproject.toml. Setuptools
commands are left unchanged.
- Replace `--weekly_build` with the env var `ONNX_PREVIEW_BUILD`.
Version number verified locally and in CI.
	> **Note**
> Due to `pyproject.toml` limitation, we need to use a script to rename
the package for the weekly build.
> On Windows, it is `(Get-Content -Path 'pyproject.toml') |
ForEach-Object { $_ -replace 'name = "onnx"', 'name = "onnx-weekly"' } |
Set-Content -Path 'pyproject.toml'`
> On linux, it is `sed -i 's/name = "onnx"/name = "onnx-weekly"/'
'pyproject.toml'`
	> Tested locally.
- Replace all `setup.py xxx` usage with `pip install` or `python -m
build` according to setuptools' suggestions.
- The MacOS wheel's platform name needs to be tweaked. Previously it was
modified by supplying the `-p` or `--plat-name` option to `setup.py`.
Now that we use `python -m build`, I created an env var
`ONNX_WHEEL_PLATFORM_NAME` and supply it via the `setup` call:
    ```
	setuptools.setup(
	    ...
	    options={"bdist_wheel": {"plat_name": ONNX_WHEEL_PLATFORM_NAME}}
	    if ONNX_WHEEL_PLATFORM_NAME is not None
	    else {},
	)
	```

### Motivation and Context
<!-- - Why is this change required? What problem does it solve? -->
<!-- - If it fixes an open issue, please link to the issue here. -->

https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html

> Starting with [PEP 621](https://peps.python.org/pep-0621/), the Python
community selected pyproject.toml as a standard way of specifying
project metadata. Setuptools has adopted this standard and will use the
information contained in this file as an input in the build process.

https://pypi.org/project/pytest-runner/

> It is recommended that you:
> Remove 'pytest-runner' from your setup_requires, preferably removing
the setup_requires option.
> Remove 'pytest' and any other testing requirements from tests_require,
preferably removing the tests_requires option.
> Select a tool to bootstrap and then run tests such as tox.

fix onnx#4878 and onnx#4539

---------

Signed-off-by: Justin Chu <justinchu@microsoft.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Corwin Joy <corwinjoy@gmail.com>
@justinchuby justinchuby added this to the 1.15 milestone Sep 5, 2023
github-merge-queue bot pushed a commit that referenced this issue Sep 7, 2023
Enable editable builds for `pip install -e .` by fixing a path not found
error in `setup.py`.

Previously `Develop` calls `BuildExt` which assumes the directory
`{build_lib}/onnx` exists because `BuildPy` would create it. However
`BuildPy` is not called in editable build, thus not creating the
directory for `BuildExt` to put the artifacts in. This change updates
`BuildExt` to create the directory for its own use independent of
previous steps.

- Remove `CreateVersion` and moved the logic into a function to
parameterize it
- General cleanup and refactor logic

Tested with

```
pip install -e .
pip install .
python -m build
python -m build --sdist
python setup.py develop
```

Reference: pypa/setuptools#3606

Fixes #4539

---------

Signed-off-by: Justin Chu <justinchu@microsoft.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug topic: build Issues related to ONNX builds and packages
Projects
None yet
2 participants