How does package installation function? I'm trying...
# plugins-general
m
How does package installation function? I'm trying to us the package manager Poetry with a custom tap, and it works fine with only the
setup.py
file, but the added
poetry.lock
and
pyproject.toml
break the installation.
d
@michael_cooper Meltano creates a Python virtual env for the plugin and then runs
pip install <pip_url>
inside it; nothing more, nothing less. Does that work correctly if you run it manually without Meltano? A package using Poetry for package management and publishing should still be a valid pip package, so I'm not sure why installation would break. Were you seeing any error messages or other specific symptoms of breakage you can share?
m
Installing locally without the poetry files, i.e. with
-e
, installs fine. If I have those two files within the tap
extract
directory, I get this error:
Copy code
Installing extractor 'tap-gmail'...
    ERROR: Command errored out with exit status 1:
     command: /projects/.meltano/extractors/tap-gmail/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/projects/extract/tap-gmail/setup.py'"'"'; __file__='"'"'/projects/extract/tap-gmail/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /projects/extract/tap-gmail/
    Complete output (3 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'setuptools'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /projects/.meltano/extractors/tap-gmail/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/projects/extract/tap-gmail/setup.py'"'"'; __file__='"'"'/projects/extract/tap-gmail/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

Extractor 'tap-gmail' could not be installed: failed to install plugin 'tap-gmail'.
d
@michael_cooper
ModuleNotFoundError: No module named 'setuptools'
is weird, because
setuptools
is automatically installed in a new venv, and we actually upgrade it to the latest version explicitly: https://gitlab.com/meltano/meltano/-/blob/master/src/meltano/core/venv_service.py#L96 What versions of Python and Meltano are you using?
m
I'm using
meltano:latest-python3.8
docker image.
And I don't get that error if I'm using just the
setup.py
, which has setuptools in it.
d
Are you installing from pypi or a Git repo? And you're saying that just deleting
poetry.lock
 and 
pyproject.toml
resolves the failure?
What happens when you run
/projects/.meltano/extractors/tap-gmail/venv/bin/pip install <tap-gmail pip_url>
?
m
Yeah, renaming the files (to effectively delete them) fixes the issue.
When I use a
git+<url>
as the
pip_url
, the installation fails silently (with the poetry files present) and throws a
can't find executable
error. If I don't have the files while using the remote repo, it also works fine.
d
And what happens when you directly run
pip install extract/tap-gmail
or
pip install git+url
?
m
It works fine with
pip install extract/tap-gmail
pip install git+<https://github.com/Mashey/tap-gmail.git>
also works fine.
d
@michael_cooper That's the weirdest thing 😕 I'd love to figure out what makes the way Meltano runs
pip install
different from you running it directly, and how this specifically trips over those poetry files, with a seemingly unrelated error about
setuptools
.
Seems like you're not the first on to run into something like this, though: https://github.com/python-poetry/poetry/issues/3153#issuecomment-725687315
Copy code
ERROR: Command errored out with exit status 1:
     command: /Users/kristofferb/Library/Caches/pypoetry/virtualenvs/reproduce-issue-QXZ_ZScA-py3.7/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/kristofferb/Code/temp/gist-reproduce-3153/setup.py'"'"'; __file__='"'"'/Users/kristofferb/Code/temp/gist-reproduce-3153/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /Users/kristofferb/Code/temp/gist-reproduce-3153/
    Complete output (3 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ModuleNotFoundError: No module named 'setuptools'
Looks like the issue is specifically with installing from source (in a dir or Git repo), not when installing a published package from PyPI: https://github.com/chaoss/grimoirelab-perceval/issues/696#issuecomment-725220105
Does this workaround work for you? https://github.com/pypa/setuptools/issues/2353#issuecomment-684452550
Copy code
SETUPTOOLS_USE_DISTUTILS=stdlib meltano install extractor tap-gmail
It's fixed in setuptools 50.1, presumably: https://github.com/pypa/setuptools/issues/2353#issuecomment-688277225 As of a few versions ago, Meltano automatically upgrades pip and setuptools: https://gitlab.com/meltano/meltano/-/merge_requests/1894, so you should be getting the latest version already
Can you find out the versions of pip and setuptools installed inside
/projects/.meltano/extractors/tap-gmail/venv
?
m
So the
SETUPTOOLS_USE_DISTUTILS=stdlib
workaround got me past the issue for
setuptools
though now I'm getting the same error for another package used. So it seems like there's still some sort of conflict with pip and the poetry files.
Also, I'm using
setuptools 50.3.2
and
pip 20.2.4
d
Hmm yeah, seems like poetry is still messing things up.
I'm not sure if you're "allowed" to manage your own
setup.py
if you're also using poetry, doesn't it built if for you?
I'm not very familiar with poetry though
m
It does. A team member like's poetry, and he built out the tap using it, but I've had to have a
setup.py
with other taps, so I ended up just adding one.
Apparently
pip
will install from a remote repo without
setup.py
, but when I try to remove
setup.py
and point the meltano
pip_url
to the repo, it doesn't build it with an executable.
d
Interesting, so perhaps we don't need a
setup.py
at all, and need to find Poetry's way of specifying an executable?
m
I saw that too. Just so I'm not crazy, I can point the
pip_url
to a branch, right? Like
git+https://<url>#my_branch
d
Yep, if that's the syntax that should work 🙂
I think you need
@refname
m
So I followed the link you sent on Poetry packages, but for some reason it's still not building the executable.
d
Is the executable missing just when installing using Meltano, or also when running
pip install
the usual way?
m
I got it to finally work. Turns out I needed to define the executable plugin within the
pyproject.toml
file.
d
@michael_cooper All right! Glad you figured it out