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

Remove duplicate dbt script entry #5304

Merged
merged 3 commits into from
Jun 8, 2022

Conversation

groodt
Copy link
Contributor

@groodt groodt commented May 28, 2022

Description

Resolves: #5314

There is a duplicate dbt script entry in setup.py

When installing the wheel, the console_script is overwriting the hand-written code in scripts/dbt. pip should not be overwriting files during installation and will begin to log warnings at some point in future. See: pypa/pip#4625 (comment)

You can confirm this by installing dbt-core into a venv. The contents of the dbt script is an autogenerated console_script defined in entry_points and not the handwritten script.

/tmp
myvenv ❯ cat myvenv/bin/dbt
#!/private/tmp/myvenv/bin/python3.9
# -*- coding: utf-8 -*-
import re
import sys
from dbt.main import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

This also results in errors when using pypa/installer which is stricter than pip.

/tmp
❯ python3 -m venv dbt_venv

/tmp
❯ source dbt_venv/bin/activate.fish

/tmp
dbt_venv ❯ python -m pip install installer
Collecting installer
  Using cached installer-0.5.1-py3-none-any.whl (452 kB)
Installing collected packages: installer
Successfully installed installer-0.5.1
WARNING: You are using pip version 22.0.4; however, version 22.1.1 is available.
You should consider upgrading via the '/private/tmp/dbt_venv/bin/python -m pip install --upgrade pip' command.

/tmp
dbt_venv ❯ python -m installer --destdir /tmp/example ~/Downloads/dbt_core-1.1.0-py3-none-any.whl
Traceback (most recent call last):
  File "/usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/[email protected]/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/private/tmp/dbt_venv/lib/python3.9/site-packages/installer/__main__.py", line 85, in <module>
    _main(sys.argv[1:], "python -m installer")
  File "/private/tmp/dbt_venv/lib/python3.9/site-packages/installer/__main__.py", line 81, in _main
    installer.install(source, destination, {})
  File "/private/tmp/dbt_venv/lib/python3.9/site-packages/installer/_core.py", line 109, in install
    record = destination.write_file(
  File "/private/tmp/dbt_venv/lib/python3.9/site-packages/installer/destinations.py", line 203, in write_file
    return self.write_to_fs(
  File "/private/tmp/dbt_venv/lib/python3.9/site-packages/installer/destinations.py", line 167, in write_to_fs
    raise FileExistsError(message)
FileExistsError: File already exists: /tmp/example/private/tmp/dbt_venv/bin/dbt

Checklist

@groodt groodt requested a review from a team as a code owner May 28, 2022 13:18
@cla-bot
Copy link

cla-bot bot commented May 28, 2022

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin.

CLA has not been signed by users: @groodt

@cla-bot cla-bot bot added the cla:yes label May 31, 2022
@ChenyuLInx ChenyuLInx merged commit 72b6a80 into dbt-labs:main Jun 8, 2022
@ChenyuLInx
Copy link
Contributor

@groodt Thanks for the help getting this into dbt-core!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-702] [Bug] Duplicate dbt script entry
4 participants