GithubHelp home page GithubHelp logo

Comments (2)

storborg avatar storborg commented on July 30, 2024

This isn't really something that Python has strong conventions for, but personally I think:

  • It is generally harmful to write to any files inside the installed package itself: sometimes, it will be installed as a zip file (although this can be disabled in setup.py), and it is often not user-writeable.
  • If it's a temporary file, use the tempfile module.
  • If it's user-specific, use a dotfile (e.g. /home/someuser/.mypackagename). This is a location that's both un-surprising to the user and is very likely to succeed without permissions errors. You should get the path to the home directory with os.path.expanduser("~") so that it's cross-platform. If you need multiple files, make .mypackagename a directory instead, and put files inside it.
  • If it's system-wide, you probably have to at least prompt the user before writing, since there isn't a consistent system-wide path that the user is likely to have write permissions for. You may be able to default to something like /usr/local/share/mypackagename on POSIX systems.

Also, those files should not be defined in setup.py at all: your setup.py should only reference read-only files which are included with the package.

from python-packaging.

iCHAIT avatar iCHAIT commented on July 30, 2024

Thanks a lot 👍

FIxed using os.path.expanduser("~")

from python-packaging.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.