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

kirillsulim
  • 62
  • 1
  • 7
  • 2
    possible duplicate of [Find current directory and file's directory](http://stackoverflow.com/questions/5137497/find-current-directory-and-files-directory) – David Greydanus May 03 '15 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? – user2357112 May 03 '15 at 19:34

1 Answers1

3

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

 import os
 os.getcwd()
Karl
  • 315
  • 2
  • 9