packaging-problems icon indicating copy to clipboard operation
packaging-problems copied to clipboard

Trouble following packaging libraries tutorial

Open aisyesm opened this issue 4 years ago • 12 comments

Thank you for providing feedback on Python packaging!

To help us help you, please fill out as much of the following as you can. If a question is not relevant, feel free to skip it.

  1. What is your operating system and version?

macOS Big Sur 11.2.2

  1. What is your Python version?

Python 3.8.3

  1. What version of pip do you have?

pip 21.0.1

  1. If following an online tutorial or guide, please provide a link to the page or section giving you trouble:

https://packaging.python.org/tutorials/packaging-projects/

  1. Could you describe your issue in as much detail as possible?

I ran a command 'python3 -m build' in order to generate distribution archives. Received the following output:

(base) ais@Aiss-MacBook-Pro-2 packaging_tutorial % python3 -m build
Uninstalling setuptools-41.2.0:
  Successfully uninstalled setuptools-41.2.0
Collecting wheel (from -r /var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-reqs-lmxg0e97.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl
Collecting setuptools>=42 (from -r /var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-reqs-lmxg0e97.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/0c/12/18eda60a1b961e0248e1b1e3ec1ff417420596dc7edf3614ef58a7a8cf6a/setuptools-54.1.2-py3-none-any.whl
Installing collected packages: wheel, setuptools
Successfully installed setuptools-54.1.2 wheel-0.36.2
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
running egg_info
writing src/example_pkg_ais.egg-info/PKG-INFO
writing dependency_links to src/example_pkg_ais.egg-info/dependency_links.txt
writing top-level names to src/example_pkg_ais.egg-info/top_level.txt
reading manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
writing manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
running egg_info
writing src/example_pkg_ais.egg-info/PKG-INFO
writing dependency_links to src/example_pkg_ais.egg-info/dependency_links.txt
writing top-level names to src/example_pkg_ais.egg-info/top_level.txt
reading manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
writing manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
running sdist
running egg_info
writing src/example_pkg_ais.egg-info/PKG-INFO
writing dependency_links to src/example_pkg_ais.egg-info/dependency_links.txt
writing top-level names to src/example_pkg_ais.egg-info/top_level.txt
reading manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
writing manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
running check
creating example-pkg-ais-0.0.1
creating example-pkg-ais-0.0.1/src
creating example-pkg-ais-0.0.1/src/example_pkg
creating example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying files to example-pkg-ais-0.0.1...
copying README.md -> example-pkg-ais-0.0.1
copying pyproject.toml -> example-pkg-ais-0.0.1
copying setup.cfg -> example-pkg-ais-0.0.1
copying setup.py -> example-pkg-ais-0.0.1
copying src/example_pkg/__init__.py -> example-pkg-ais-0.0.1/src/example_pkg
copying src/example_pkg_ais.egg-info/PKG-INFO -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying src/example_pkg_ais.egg-info/SOURCES.txt -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying src/example_pkg_ais.egg-info/dependency_links.txt -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying src/example_pkg_ais.egg-info/top_level.txt -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
Writing example-pkg-ais-0.0.1/setup.cfg
Creating tar archive
removing 'example-pkg-ais-0.0.1' (and everything under it)
running sdist
running egg_info
writing src/example_pkg_ais.egg-info/PKG-INFO
writing dependency_links to src/example_pkg_ais.egg-info/dependency_links.txt
writing top-level names to src/example_pkg_ais.egg-info/top_level.txt
reading manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
writing manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
running check
creating example-pkg-ais-0.0.1
creating example-pkg-ais-0.0.1/src
creating example-pkg-ais-0.0.1/src/example_pkg
creating example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying files to example-pkg-ais-0.0.1...
copying README.md -> example-pkg-ais-0.0.1
copying pyproject.toml -> example-pkg-ais-0.0.1
copying setup.cfg -> example-pkg-ais-0.0.1
copying setup.py -> example-pkg-ais-0.0.1
copying src/example_pkg/__init__.py -> example-pkg-ais-0.0.1/src/example_pkg
copying src/example_pkg_ais.egg-info/PKG-INFO -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying src/example_pkg_ais.egg-info/SOURCES.txt -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying src/example_pkg_ais.egg-info/dependency_links.txt -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
copying src/example_pkg_ais.egg-info/top_level.txt -> example-pkg-ais-0.0.1/src/example_pkg_ais.egg-info
Writing example-pkg-ais-0.0.1/setup.cfg
Creating tar archive
removing 'example-pkg-ais-0.0.1' (and everything under it)
Uninstalling setuptools-41.2.0:
  Successfully uninstalled setuptools-41.2.0
Collecting wheel (from -r /var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-reqs-aovu803s.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl
Collecting setuptools>=42 (from -r /var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-reqs-aovu803s.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/0c/12/18eda60a1b961e0248e1b1e3ec1ff417420596dc7edf3614ef58a7a8cf6a/setuptools-54.1.2-py3-none-any.whl
Installing collected packages: wheel, setuptools
Successfully installed setuptools-54.1.2 wheel-0.36.2
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
running egg_info
writing src/example_pkg_ais.egg-info/PKG-INFO
writing dependency_links to src/example_pkg_ais.egg-info/dependency_links.txt
writing top-level names to src/example_pkg_ais.egg-info/top_level.txt
reading manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
writing manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
running egg_info
writing src/example_pkg_ais.egg-info/PKG-INFO
writing dependency_links to src/example_pkg_ais.egg-info/dependency_links.txt
writing top-level names to src/example_pkg_ais.egg-info/top_level.txt
reading manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
writing manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
Requirement already satisfied: wheel in /private/var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-env-25zahyc_/lib/python3.8/site-packages (from -r /var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-reqs-nh7uex_m.txt (line 1)) (0.36.2)
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
running bdist_wheel
running build
running build_py
installing to build/bdist.macosx-10.9-x86_64/wheel
running install
running install_lib
creating build/bdist.macosx-10.9-x86_64/wheel
creating build/bdist.macosx-10.9-x86_64/wheel/example_pkg
copying build/lib/example_pkg/__init__.py -> build/bdist.macosx-10.9-x86_64/wheel/example_pkg
running install_egg_info
running egg_info
writing src/example_pkg_ais.egg-info/PKG-INFO
writing dependency_links to src/example_pkg_ais.egg-info/dependency_links.txt
writing top-level names to src/example_pkg_ais.egg-info/top_level.txt
reading manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
writing manifest file 'src/example_pkg_ais.egg-info/SOURCES.txt'
Copying src/example_pkg_ais.egg-info to build/bdist.macosx-10.9-x86_64/wheel/example_pkg_ais-0.0.1-py3.8.egg-info
running install_scripts
adding license file "LICENSE" (matched pattern "LICEN[CS]E*")
creating build/bdist.macosx-10.9-x86_64/wheel/example_pkg_ais-0.0.1.dist-info/WHEEL
creating '/Users/ais/Desktop/packaging_tutorial/dist/tmpuit_e_ym/example_pkg_ais-0.0.1-py3-none-any.whl' and adding 'build/bdist.macosx-10.9-x86_64/wheel' to it
adding 'example_pkg/__init__.py'
adding 'example_pkg_ais-0.0.1.dist-info/LICENSE'
adding 'example_pkg_ais-0.0.1.dist-info/METADATA'
adding 'example_pkg_ais-0.0.1.dist-info/WHEEL'
adding 'example_pkg_ais-0.0.1.dist-info/top_level.txt'
adding 'example_pkg_ais-0.0.1.dist-info/RECORD'
removing build/bdist.macosx-10.9-x86_64/wheel
running bdist_wheel
running build
running build_py
installing to build/bdist.macosx-10.9-x86_64/wheel
running install
running install_lib
copying build/lib/example_pkg/__init__.py -> build/bdist.macosx-10.9-x86_64/wheel/example_pkg
error: could not create 'build/bdist.macosx-10.9-x86_64/wheel/example_pkg/__init__.py': No such file or directory
Traceback (most recent call last):
  File "/Users/ais/opt/anaconda3/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-env-25zahyc_/bin/python', '/Users/ais/opt/anaconda3/lib/python3.8/site-packages/pep517/in_process/_in_process.py', 'build_wheel', '/var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/tmp50155m1o']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ais/opt/anaconda3/lib/python3.8/site-packages/build/__init__.py", line 309, in _call_backend
    raise BuildBackendException(exception)
build.BuildBackendException: Backend operation failed: CalledProcessError(1, ['/var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-env-25zahyc_/bin/python', '/Users/ais/opt/anaconda3/lib/python3.8/site-packages/pep517/in_process/_in_process.py', 'build_wheel', '/var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/tmp50155m1o'])

ERROR Backend operation failed: CalledProcessError(1, ['/var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/build-env-25zahyc_/bin/python', '/Users/ais/opt/anaconda3/lib/python3.8/site-packages/pep517/in_process/_in_process.py', 'build_wheel', '/var/folders/8j/kcp9y9fj2_57_v887gks8snm0000gn/T/tmp50155m1o'])

aisyesm avatar Mar 17 '21 08:03 aisyesm

After looking at other open issues here, I have managed resolve mine by deleting 'setup.py' I had the call to setup() inside it just like the tutorial recommends. However, it looks like it will not work anyway.

aisyesm avatar Mar 17 '21 08:03 aisyesm

That's weird. It should be quite valid (and personally, every package I work with has it, since I use editable installs for developing, and last I checked a setup.py with a setup call was the only way to get an editable install. (Supposed to be fixed at some point).

henryiii avatar Mar 17 '21 14:03 henryiii

(To be precise, there is no standard for develop/editable installs so that you can use an install tool (PEP 517 frontend) to develop install your project, but build tools (backends) can and do implement the feature, for example python setup.py develop or flit install --symlink, and there is always manual measures like creating a pth file or settting PYTHONPATH that have existed for decades)

(2023 edit: there is a standard way now, PEP 660, implemented in pip and many backends, so check the tracker for yours)

merwok avatar Mar 17 '21 14:03 merwok

It looks like setuptools attempted to run bdist_wheel twice, the second time after the wheel build directory had been deleted. It's hard to tell what might've caused that without looking at the source code.

layday avatar Mar 17 '21 14:03 layday

pip install -e . doesn't work because it calls python setup.py develop, and with no setup.py, that doesn't work. Manual path setting wouldn't allow you to use perfectly valid modern tooling, like importlib.metadata, setuptools_scm, etc.

Anyway, can you point at any source? Did you list your own package in your dependencies, or something like that?

henryiii avatar Mar 17 '21 14:03 henryiii

I had exactly the same problem, and removing the file setup.py solved the issue.

viktak avatar Mar 31 '21 11:03 viktak

What was in your setup.py?

layday avatar Mar 31 '21 12:03 layday

Nothing. I just created it, but did not use it as instructed on the page.

viktak avatar Mar 31 '21 13:03 viktak

Sorry to summon you @jaraco, but can you think of a condition that might have caused this with an empty setup.py?

layday avatar Apr 01 '21 12:04 layday

It's not the error we normally see with an empty setup.py, which is an opaque one about x, = thing not having enough values to unpack. It's a common enough mistake I'd really like to get a nice error message from setuptools.

henryiii avatar Apr 01 '21 12:04 henryiii

That was done in https://github.com/pypa/setuptools/pull/2608.

layday avatar Apr 01 '21 12:04 layday

The comment from @henryiii Resolved another issue for me that was the result of having a pyprject.toml file and a setup.py file in the same directory.

I was getting errors where folders and files didn't exist in the build/bdist directory, and I couldn't figure out what was removing them or not creating them. It does appear that having a setup.py file that gets called twice will result in this error.

error: could not create 'build/bdist.macosx-10.9-x86_64/wheel/example_pkg/__init__.py': No such file or directory

Xenology avatar Jan 31 '23 01:01 Xenology