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

NameError with wrapped setup.py (pdm.installers._editable_install) #407

Closed
1 task done
blueyed opened this issue Apr 23, 2021 · 3 comments · Fixed by #419
Closed
1 task done

NameError with wrapped setup.py (pdm.installers._editable_install) #407

blueyed opened this issue Apr 23, 2021 · 3 comments · Fixed by #419
Labels
🐛 bug Something isn't working

Comments

@blueyed
Copy link
Contributor

blueyed commented Apr 23, 2021

  • I have searched the issue tracker and believe that this is not a duplicate.

When trying to add mkdocs in editable mode it fails with a NameError due to re not being known when execing the code in pdm.installers._editable_install:

with getattr(tokenize, "open", open)(__file__) as f:
code = f.read().replace("\\r\\n", "\n")
if os.path.exists(os.path.join(lib_dir, "site.py")):
# Remove the custom site.py for editable install.
# It will be added back after installation is done.
os.remove(os.path.join(lib_dir, "site.py"))
sys.argv[1:] = [
"develop",
"--install-dir={0}".format(lib_dir),
"--no-deps",
"--prefix={0}".format(prefix),
"--script-dir={0}".format(bin_dir),
"--site-dirs={0}".format(lib_dir),
]
sys.path.append(lib_dir)
exec(compile(code, __file__, "exec"))

% .venv/bin/pdm add -e ~/Vcs/mkdocs -s doc -d
Adding packages to doc dev-dependencies: mkdocs
✔ 🔒 Lock successful
Changes are written to pdm.lock.
Changes are written to pyproject.toml.
Synchronizing working set with lock file: 18 to add, 0 to update, 0 to remove

  ✖ Install mkdocs 1.2.dev1 failed
  See /tmp/pdm-install-2rcus8kw.log for detailed debug log.
  [BuildError]: Call command ['/usr/bin/python', '-u', '/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/_editable_install.py', '/home/daniel/Vcs/mkdocs/setup.py', '/tmp/pdm-test/__pypackages__/3.9', '/tmp/pdm-test/__pypackages__/3.9/lib', '/tmp/pdm-test/__pypackages__/3.9/bin'] return non-zero status.
  Add '-v' to see the detailed traceback
.venv/bin/pdm add -e ~/Vcs/mkdocs -s doc -d  16.46s user 1.49s system 41% cpu 43.665 total

Note: this uses the 1.1.2 tag of mkdocs, with pdb 1.5.1.

Log:

Preparing isolated env for PEP 517 build...
running egg_info
writing mkdocs.egg-info/PKG-INFO
writing dependency_links to mkdocs.egg-info/dependency_links.txt
writing entry points to mkdocs.egg-info/entry_points.txt
writing requirements to mkdocs.egg-info/requires.txt
writing top-level names to mkdocs.egg-info/top_level.txt
warning: the 'license_file' option is deprecated, use 'license_files' instead
adding license file 'LICENSE' (matched pattern 'LICENSE')
reading manifest file 'mkdocs.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.mustache' under directory 'mkdocs'
warning: no previously-included files matching '__pycache__' found under directory '*'
warning: no previously-included files matching '*.py[co]' found under directory '*'
writing manifest file 'mkdocs.egg-info/SOURCES.txt'
Preparing isolated env for PEP 517 build...
Traceback (most recent call last):
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/_editable_install.py", line 31, in <module>
    install(setup_py, prefix, lib_dir, bin_dir)
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/_editable_install.py", line 26, in install
    exec(compile(code, __file__, "exec"))
  File "…/Vcs/mkdocs/setup.py", line 43, in <module>
    version=get_version("mkdocs"),
  File "…/Vcs/mkdocs/setup.py", line 16, in get_version
    return re.search("__version__ = ['\"]([^'\"]+)['\"]", init_py).group(1)
NameError: name 're' is not defined
Error occurs
Traceback (most recent call last):
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/builders/base.py", line 80, in log_subprocessor
    subprocess.check_call(
  File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python', '-u', '/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/_editable_install.py', '…/Vcs/mkdocs/setup.py', '/tmp/pdm-test/__pypackages__/3.9', '/tmp/pdm-test/__pypackages__/3.9/lib', '/tmp/pdm-test/__pypackages__/3.9/bin']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/termui.py", line 189, in logging
    yield logger
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/synchronizers.py", line 305, in synchronize
    handlers[kind](key)
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/synchronizers.py", line 148, in install_candidate
    installer.install(can)
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/installers.py", line 45, in install
    self.install_editable(candidate.ireq)
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/installers.py", line 78, in install_editable
    builder.subprocess_runner(install_args, ireq.unpacked_source_directory)
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/builders/base.py", line 197, in subprocess_runner
    return log_subprocessor(cmd, cwd, extra_environ=env)
  File "/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/builders/base.py", line 88, in log_subprocessor
    raise BuildError(f"Call command {cmd} return non-zero status.")
pdm.exceptions.BuildError: Call command ['/usr/bin/python', '-u', '/tmp/pdm-test/.venv/lib/python3.9/site-packages/pdm/installers/_editable_install.py', '…/Vcs/mkdocs/setup.py', '/tmp/pdm-test/__pypackages__/3.9', '/tmp/pdm-test/__pypackages__/3.9/lib', '/tmp/pdm-test/__pypackages__/3.9/bin'] return non-zero status.
@blueyed blueyed added the 🐛 bug Something isn't working label Apr 23, 2021
blueyed added a commit to blueyed/pdm that referenced this issue Apr 23, 2021
@frostming frostming linked a pull request Apr 27, 2021 that will close this issue
2 tasks
@frostming
Copy link
Collaborator

Can you help to verify if this issue is fixed by #419 ?

@blueyed
Copy link
Contributor Author

blueyed commented Apr 27, 2021

Can you help to verify if this issue is fixed by #419 ?

Yes, tested it (cc04428), and it fixed the issue.

@frostming
Copy link
Collaborator

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
2 participants