Comments (2)
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 withos.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.
Thanks a lot
FIxed using os.path.expanduser("~")
from python-packaging.
Related Issues (20)
- Note any significant distinctions between distutils and setuptools HOT 9
- Non-code-files guidance requires unnecessary repetition
- Publishing on PyPi register and upload methods deprecated/not-recommended HOT 5
- Installing nose fails in `python setup.py test`, works second time through HOT 1
- ensuring submodules work
- Git repo name incorrect in setup.py
- `.pypirc` file not mentioned
- Install the package from github
- Test not detected HOT 1
- Needs updating for Python 3.x HOT 1
- Is this guide outdated?
- `test_require` is deprecated. HOT 1
- Top level tests directory HOT 2
- minimal.rst doesn't work HOT 1
- I think this project brings more confusion than benefit.
- Please, do not recommend nose
- Please drop the reference to 'dependency_links' - it is no longer supported
- Please change basestring to str
- Delete project because out of date HOT 1
- requirements.txt HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-packaging.