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

Trouble following packaging libraries tutorial - build module does not work when using a virtualenv #505

Closed
Zeebrow opened this issue May 1, 2021 · 3 comments

Comments

@Zeebrow
Copy link

Zeebrow commented May 1, 2021

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?

CentOS Linux release 8.3.2011
Linux -hostname- 4.18.0-240.15.1.el8_3.x86_64 #1 SMP Mon Mar 1 17:16:16 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

  1. What is your Python version?

system python3:
Python 3.6.8

virtualenv:
Python 3.6.8

  1. What version of pip do you have?

system pip3:
pip 21.1.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

virtualenv:
pip 21.1.1 from /home/mike/bin/dcabot-minimal/venv-build/lib/python3.6/site-packages/pip (python 3.6)

  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/#generating-distribution-archives

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

I followed the tutorial up to the link above, and python3 -m build ran successfully. I got to the next step, which requires twine. I tried installing, but it conflicted with a dependency. No problem, I'll make a virtualenv and start the section over (python and pip versions given above are from virtualenv). I then ran source venv/bin/activate, python3 -m pip install --upgrade build (no --user options when using virtualenv) and python3 -m build. This gives the following Traceback: (apologies in advance for formatting)

(venv-build) [mike@homelab dcabot-minimal]$ python3 -m build
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/mike/bin/dcabot-minimal/venv-build/lib/python3.6/site-packages/build/__main__.py", line 214, in <module>
    main(sys.argv[1:], 'python -m build')
  File "/home/mike/bin/dcabot-minimal/venv-build/lib/python3.6/site-packages/build/__main__.py", line 206, in main
    build_package(args.srcdir, outdir, distributions, config_settings, not args.no_isolation, args.skip_dependencies)
  File "/home/mike/bin/dcabot-minimal/venv-build/lib/python3.6/site-packages/build/__main__.py", line 94, in build_package
    _build_in_isolated_env(builder, outdir, distributions, config_settings)
  File "/home/mike/bin/dcabot-minimal/venv-build/lib/python3.6/site-packages/build/__main__.py", line 52, in _build_in_isolated_env
    with IsolatedEnvBuilder() as env:
  File "/home/mike/bin/dcabot-minimal/venv-build/lib/python3.6/site-packages/build/env.py", line 91, in __enter__
    executable, scripts_dir = _create_isolated_env_venv(self._path)
  File "/home/mike/bin/dcabot-minimal/venv-build/lib/python3.6/site-packages/build/env.py", line 203, in _create_isolated_env_venv
    pip_distribution = next(iter(metadata.distributions(name='pip', path=[purelib])))

Deactivating virtualenv and using the system's python/pip still works. Both virtualenv and system use build==0.3.1.post1

@Zeebrow
Copy link
Author

Zeebrow commented May 1, 2021

P.S. I was able to complete the tutorial by putting twine in a virtualenv. Thanks a bunch!

@layday
Copy link
Member

layday commented May 5, 2021

This is probably pypa/build#266. Please install build with the virtualenv extra: python3 -m pip install -U build[virtualenv].

@layday
Copy link
Member

layday commented Jun 29, 2021

I'll close this one now. Please comment below if you're still facing an issue.

@layday layday closed this as completed Jun 29, 2021
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