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

Can't find local modules #6

Open
TomerGodinger opened this issue Mar 31, 2022 · 1 comment
Open

Can't find local modules #6

TomerGodinger opened this issue Mar 31, 2022 · 1 comment

Comments

@TomerGodinger
Copy link

The tool doesn't find modules in the current working directory when it's installed from pip, which is what I would expect it to be used for.
Example of local file:

$ cat lucli.py 
import click

@click.group()
def cli():
    """Your standard, everyday lunch CLI."""
    pass


@cli.command()
@click.option('-dish', metavar='thing', envvar='DISH', default='burger',
                show_default=True, help='The meat dish to order')
def order_meat(dish: str):
    """Orders a meat dish."""
    click.echo(f'Meat is neat! One {dish} please!')


@cli.command()
@click.option('-dish', metavar='<thang>', envvar='DISH', default='penne',
              show_default=True, help='The type of pastas to order')
@click.option('-quantity', metavar='<quantity>', default=5,
              show_default=True, help='The amount of pasta dishes to order')
def order_pastas(dish: str, quantity: int):
    """Orders a bunch of pasta dishes."""
    click.echo(f'Pasta is a musta! {quantity} serving(s) of {dish} please!')

And when running the tool:

$ mdclick dumps --baseModule=lucli --baseCommand=cli --docsPath=docs/_build/md-click/
Creating a new documents from lucli.cli into docs/_build/md-click/
Could not find module: lucli. Error: No module named 'lucli'

If I add the current working directory to the Python path at the beginning of main.py:

import sys
import os
sys.path.insert(0, os.getcwd())

then it works:

$ mdclick dumps --baseModule=lucli --baseCommand=cli --docsPath=docs/_build/md-click/
Creating a new documents from lucli.cli into docs/_build/md-click/
Created docs under docs/_build/md-click/

but I'm not sure that's a good solution.

@marci4
Copy link

marci4 commented Dec 13, 2023

Running into the same problem.

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