1

Is there any way to get working directory when I call global python script, created by entry_points in setuptools?

doge.py:

import sys

def da():
    print("Doge greets you!\n")
    print(sys.argv)

setup.py:

from setuptools import setup
setup(
    name='doge-script',
    version='0.1',
    description='Bla',
    author='Me',
    author_email='',
    url='',
    scripts=["doge.py"],
    entry_points={
        'console_scripts': ['rundoge = doge:da'],
    }
)

So I would like to get directory whence I call this script via "doge" command

2
  • 2
    possible duplicate of Find current directory and file's directory Commented May 3, 2015 at 19:33
  • I'm not familiar with setuptools and how it'll configure doge.py to run, but does os.getcwd() work? Or does the working directory change? Commented May 3, 2015 at 19:34

1 Answer 1

3

I believe this will help you out. See https://docs.python.org/2/library/os.html

 import os
 os.getcwd()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.