Python, distutils, data_files - Yay! I know where my data files are.

After a long and painful research i have finally found usable way to make distutils propagate location of data files to installed application.
Python's distutils allow user to specify location for data_files but there's no standard way to acess them.
Yes sure ,there are few workarounds :
1) distributing data_files as package_data
  - Do you really want to have ie. README.txt in /usr/lib/python/... ?
2) Accessing those data_file using $sys.prefix
- hmm. Here you hardcode $sys.prefix relative path to setup.py like this:
setup(...., data_files=['share/myverycoolpackage/doggie.gif'], ..)
- and access it this way:
os.path.join(sys.prefix, 'share/myverycoolpackage/doggie.gif')
This works fine, but you're making assertions about layout of users $sys.prefix directory. Not talking about possibility to specify --data-dir during installation.
Both are not really usable. Here goes the solution:
Idea: Install additional 'package.ini' file, that will get modified during install and will hold location of data files.
This package.ini will be installed as package_data, so that it will be accessible relatively to sources.
And this is how i did it:
New command to install process:
from os.path import *
import re
class package_ini(Command):
Locate package.ini in all installed packages and patch it as requested
by wildcard references to install process.
user_options = []
def initialize_options(self):
pass
def finalize_options(self):
pass
def visit(self, dirname, names):
packages = self.distribution.get_command_obj(build_py.__name__).packages
if basename(dirname) in packages:
if 'package.ini' in names:
self.patch(join(dirname, 'package.ini'))
def patch(self, ini_file):
print 'patching file' + ini_file
with open(ini_file,'r') as infile:
file_data = infile.readlines()
with open(ini_file,'w') as outfile:
for line in file_data:
_line = self.patch_line(line)
if _line:
line = _line
outfile.write(line)
def patch_line(self, line):
Patch an installed package.ini with setup's variables
match = re.match('(?P<identifier>\w+)\s*=.*##SETUP_PATCH\\((?P<command>.*)\.(?P<variable>.*)\\)', line)
if not match:
return line
print 'Replacing:'+line
line = match.group('identifier')
line += ' = '
data = '(self).distribution.get_command_obj(\''+\
match.group('command')+'\')'+'.'+\
match.group('variable')
line += '\''+eval(data)+'\''
line += '\n'
print 'With:' + line
return line
Apend this package_ini command to install command:
class install(_install):
from distutils.command.install import install as _install
sub_commands = _install.sub_commands + [
(package_ini.__name__, None)
Mention your package.ini in setup():
setup(..., package_data={'myverycoolpackage':['package.ini']}, data_files='myverycoolpackage','doggie.gif',..)
Write your package.ini like this:
__data_dir__ = '../../data' ##SETUP_PATCH(install_data.install_dir)
Package.ini will get patched properly during install, so if i assume that user specified --data-dir=C:/Program Files/ApplicationData/verycoolpackage, package.ini will be:
__data_dir__ = 'C:/Program Files/Application Data/verycoolpackage'
Notice that you can access any property from setup script, so this might be usable for version string or other stuff.
Also notice that in 'develoment environment' location of data files differs from 'installation environment'. Cute, isn't it?.
Now you just have to evaluate package ini (propably in myverycoolpackage/__init__.py):
with open(inipath) as ini:
for line in ini.readlines():
exec(line)
And we're done.

I've just checked several versions of Dreamweaver in Windows 7. They all have dotted lines showing the tree structure in the Files panel.
I also checked Dreamweaver CS3 on Mac OS X 10.6, and CS5.5 and CS6 on Mac OS X 10.7. None of the Mac versions have dotted lines. The files are simply indented.
If you're on a Mac, that's the way it has been for a long time. If you're on Windows, the lines should still be there. There is no special setting in Dreamweaver.

Similar Messages

  • I have Prem. Elements 12.  I am trying to add audio media.  I know where the audio files are located (using GET INFO while in iTunes), and when I try to add certain audio files, some are accepted and some are not.  In one case, when I opened a particular

    I have Prem. Elements 12.  I am trying to add audio media.  I know where the audio files are located (using GET INFO while in iTunes), and when I try to add certain audio files, some are accepted and some are not.  In one case, when I opened a particular folder, the song was not listed, even tho' the song is there when using Windows Explorer.  This happens with mp3 and mp4 and just wav files.  Some audio are accepted, most are not.  I get that codec is not installed error message, too.

    Perhaps it would be helpful for you to view the page source code of this page
    http://www.alanwork.com/
    As you can see, the submenu code links are immediately below the top level code, and are
    wrapped in their own  <UL> </UL> tag pairs.
    Hope that helps

  • I have two HDs. How do I point All My Files in Finder to the second HD where my data files are?

    I have a SSHD that has the OS and all apps. In finder All My Files points to it. How do I change it to look at my big, data HD?
    Thanks.

    As I pointed, and esp. with an SSD, leave the home library on t he boot drive works great.
    The sidebar can have whatever you want, maybe not the default pretty icon for the default folders, but folders, hdd etc that you drag onto the sidebar. Folders, not files.
    Using OS X with an SSD plus HDD setup, by Matt Gemmell
    http://mattgemmell.com/using-os-x-with-an-ssd-plus-hdd-setup/
    How to relocate system and user data to another drive:
    http://reviews.cnet.com/8301-13727_7-57603361-263/how-to-move-a-home-folder-in-o s-x/
    http://chris.pirillo.com/how-to-move-the-home-folder-in-os-x-and-why/
    http://support.apple.com/kb/HT4337
    To successfully relocate your operating system, user accounts and data from one storage device to another, meet the following conditions: 
    The destination storage device (SSD drive or hard drive) you are migrating to should be physically located in the same computer.  Moving operating system files from one computer to another computer using software not specifically designed for that computer can cause issues due to software, hardware, and firmware version mismatches.
    Always back up your storage device with Time Machine or Disk Utility before you start.
    Home  Folders  not  on  a  Startup  volume
    http://pondini.org/OSX/SetupOther.html

  • Does anyone know where the iWeb data files are located or what they are called?  I can't find them.  I looked in Finder for files named the same as my website, but found nothing.  Any help would be appreciated.

    Does anyone know where the iWeb data files are located or what they are called?  I can't find them.  I looked in Finder for files named the same as my website, but found nothing.  Any help would be appreciated.

    If you erased or replaced your hard drive since iWeb was cancelled, then they are gone. Otherwise, if you have maintained backups then check those.
    Usually such files are in the /Home/Library/ folder or a sub-folder.
    Exposing the /Home/Library/ Folder
    Pick one of the following methods:
    A. This method will make the folder visible permanently. Open the Terminal application in your Utilities folder and paste the following at the command prompt:
    chflags nohidden ~/Library
    Press RETURN.
    B. Click on the Desktop, press the OPTION (⌥) button, select Library from the Finder's Go menu.
    C. Select Go To Folder from the Finder's Go menu. Paste the following in the path field:
    ~/Library
    Press the Go button.

  • HT201744 How do you actually know where a Spotlight file is?  I mean all well and good Spotlight identifies it but I want to know which file has been identified and where it is......

    How do you actually know where a Spotlight file is?  I mean all well and good Spotlight identifies it but I want to know which file has been identified and where it is......

    To know where the Spotlight file is, highlight it in Spotlight and hold the Command key, so you will see its location at the bottom of the window

  • My iPod touch has 2 Notes account: 'Gmail' and 'From my Mac'. Now I know where my 'Gmail' notes are synced on my mac but I've no idea where my 'From My Mac' notes are synced on my mac. Mine is a Mac Book Air using Mac OS X Lion 10.7.5

    My iPod touch has 2 Notes account: 'Gmail' and 'From my Mac'.
    Now I know where my 'Gmail' notes are synced on my mac but I've no idea where my 'From My Mac' notes are synced on my mac.
    Mine is a Mac Book Air using Mac OS X Lion 10.7.5.
    Any ideas?

    Go step by step and check.
    1. Start up in Safe Mode.
        http://support.apple.com/kb/PH11212
    2. Backup your computer.
    3. Empty Trash.
       http://support.apple.com/kb/PH13806
    4. Re-index Macintosh HD.
        This will take a while. Wait until it is finished.
        System Preferences > Spotlight > Privacy
        http://support.apple.com/kb/ht2409
    5.Try OmniDiskSweeper. This will show the storage size details of the items.
       https://www.omnigroup.com/more
       Select Macintosh HD and click  “Sweep Selected Drive” at the bottom.
       Be careful. Delete only the files that can be safely  deleted. If you are not sure about any file, don’t touch it.

  • Re: Does anyone know where the data base

    We do maintain a searchable indexed archive at
    http://pinehurst.sagesoln.com/listarchive. Recently because of Sage office
    moves and other IT intensive activities I've been lax about getting it
    updated. I'll try to get it straightened out in the next week or so.
    Jamie Fox
    Systems Administrator
    Sage IT Partners
    [email protected]
    (415) 399-7210
    David Trudell wrote:
    >
    that contains a history of all the messages sent reside? I tried looking on
    sageit.com, but I couldn't find it.
    Thanks
    David Trudell
    There are two major products to come out of Berkeley: LSD and
    UNIX. We don't believe this to be a coincidence.
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    David,
            Try this:
                                <a
    href=
    "http://pinehurst.sageit.com/listarchive/">http://pinehurst.sageit.com/listarchive/</a>
    <http://pinehurst.sageit.com/listarchive/>
    -----Original Message-----
    From: David Trudell [mailto:[email protected]]
    Sent: Wednesday, January 20, 1999 2:18 PM
    To: [email protected]
    Subject: Does anyone know where the data base
    that contains a history of all the messages sent reside?  I tried looking on
    sageit.com, but I couldn't find it.
    Thanks
    David Trudell
    There are two major products to come out of Berkeley: LSD and
    UNIX.  We don't believe this to be a coincidence.
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

  • Backed up Lightroom 2 to a 'backup plus'.  Will be installing Lightroom 5 to a new Win 7 computer and want to move only the photos to a dedicated 1 tb drive in the machine.  Anyone know Where my actual photos are stored on 'backup plus'?  Thank you

    Backed up Lightroom 2 to a Seagate 'backup plus'.  Will be installing Lightroom 5 to a new Win 7 computer and want to move only the photos to a dedicated 1 tb drive in the machine.  Anyone know where my actual photos are stored on 'backup plus'? Thank you

    Thank you for your reply.  I have been backing up my entire computer and when I follow anything having to do with Lightroom I am not finding actual photos.  I hope to find the photos that have been backed up along with updates to them that my wife has been performing during her edits.  Found Lightroom 2 catalog Previews/Lrdata.  Could that be it?

  • HT1725 i recently downloaded an album from itunes but 5 of the songs won't completely play through when i try to listen to them. i don't know if the song files are damaged or what but what action should i take to repair the files or get my money back?

    i recently downloaded an album from itunes and from what it appeared, everything completely downloaded, but 5 of the songs won't completely play through when i want to listen to them. i don't know if the song files are damaged or what. what actions should i take to either repair the files or get my money back from itunes?

    Assuming you are in a region where you are allowed to redownload your past music purchases, delete the corrupt tracks from the music section of your iTunes library, close & then reopen iTunes, go to the iTunes Store home page, click the Purchased link from the Quick Links section in the right-hand column, then select Music and Not on this computer. You should find download links for your tracks there.
    While downloading select Downloads in the left-hand column and make sure Allow Simultaneous Downloads is unchecked.
    If the problem persists, or that facility is not yet available in your region, contact the iTunes Store support staff through the "Report a problem" links in your account history, or via Contact Support.
    See also:
    HT5085 - iTunes in the Cloud and iTunes Match Availability
    HT2519 - Downloading past purchases from the App Store, iBookstore, and iTunes Store
    tt2

  • FMS  - change directory where the log files are located?

    I want to change the logs files directory from:
    C:\Program Files (x86)\Adobe\Flash Media Server 3.5/logs
    to:
    D:\fmsLogs
    Please halp me to understand...
    in adobe in:
    Home / Flash Media Server  3.5 Configuration and Administration Guide / XML configuration files reference
    it says:
    in Logger.xml in Directory
    Specifies the directory where the log files are located.
    By default, the log files are located in the logs directory in the server installation directory.
    Example:
    <Directory>${LOGGER.LOGDIR}</Directory>
    what this meens: ${LOGGER.LOGDIR} ?
    in order to change the logs files directory from:
    C:\Program Files (x86)\Adobe\Flash Media Server 3.5/logs
    to:
    D:\fmsLogs
    do i need to write this:
    <Directory>D:\fmsLogs</Directory>
    or what do i neet to write?
    it is totaly not understandable from this example...
    big thanks for any halp
    cheinan

    You can change LOGGER.LOGDIR in fms.ini to your preferred location i.e. D:\fmsLogs and restart FMS.
    Now if you want to change for individual logs - you can change in Logger.xml - by default logger.xml will use value from fms.ini

  • How to embed a swf in Catalyst. (don't know where to associated files etc.)

    I'm trying to embed a 'canned' swf package on one of my FC states. No problem dropping the swf on the
    page (I did find out AS2 doesnt work, but AS3 does )
    When I run the project I get a message saying it cant find an associated xml file.
    The package has the swf, an image folder, an index.html, a .js file and an xml file. I don't know where to put these to get it to work. Tried it locally and on my server. I'm running panini and burrito.
    Thanks,
    Andy

    You are going to need to recreate the directory structure  that 'canned' swf is looking for beneath the Flash Catalyst output. If I am not mistaken, the swf will be inside an assets directory. Try placing the xml file in there.
    Good luck.

  • Anybody know where the default templates are stored?

    I'd like to access the location where the default templates are stored. I've checked in: "Macintosh HD/Library/Application Support/Logic" but did not find anything.
    I see that user templates are in: "Macintosh HD/Users/PROFILE/Library/Application Support/Logic/Project Templates"
    Thanks in advance!
    Rydah

    alienimplant wrote:
    The assigned solution to this problem is false. The answer is that they are stored here:
    /Users/[username]/Music/Audio Music Apps/Project Templates
    That is not correct.
    User Project templates are stored in the location you stated but the Default Project templates, which is what the OP asked about,  are stored within the app as Blueberry stated....
    Note the path I highlighted......

  • How can I see where the music files are?

    I have imported some of my CDs to the iTunes Library, but can not see them in the folders in finder. How can I do this please. Thanks!\\Someone showed me once but I obviously forgot.
    Floor

    van D wrote:
    I have imported some of my CDs to the iTunes Library...
    When you rip CDs, the files go into the folder designated in Preferences.
    Normally they go into subfolders for the Artist and Album, but depending how things are tagged, that could be "Compilations," "Various Artists," "Unknown Album," etc.
    As JG notes, if the library knows where they are, Show in Finder takes you right to them. If the library has lost them, search in Finder on a word or two of the song title.

  • How do I find where my larger files are all at Once

    Like all I am getting close to having a full HD. Is there a way to tell where all my large files are all at the same time without having to go to each folder, file, application
    Thx Much

    Thx Much, I am aware of all that, just wondering is there is any software freeware, widget that could tell me where all my very large files are at the same time with having to go through all the folders/files/libraries..
    It is amazing that many large files are stored in the strangest places.
    Jack

  • ITunes doesn't know where all my tunes are

    I keep my music on an external HD. WHich crapped out. So I copied the songs from the ipod to a new music folder on my computer's HD (making sure itunes knew where it was via preferences). Then when I got a new external HD I copied it all across and reset itunes preferences. But I still get a lot of those grey exclamation marks and the itunes question 'do you want to locate the file'. It seems the folder structures differ from external HD to internal HD. SO I tried 'consolidate library'. Now all I have is thousands and thousands of duplicates in each folder that I will definitely go bonkers if I have to clean them all out manually.
    1. How to easily get rid of all those duplicates?
    2. How to make the library file look for and find all the tunes that currently escape it?
    HELP! I am going daft! Anyone with any ideas? My music is a mess. Luckily the pod is up to date. Should I just chuck everything away and go with what's on the pod?
    Aidan

    i've had so many of these problems. i now know that the ITunes software just doesn't like changing file addresses, it basically can only 'remember' the original one. so, if you move your file from PC HD to EXT HD it just goes 'BLAAAH wots my name again'.
    i've gotta be honest and say that i can only suggest, resetting all your music from the EXT HD. however, i've been in this situation as have others i've talked to, and although i don't know how, thngs have kinda righted themselves for no reason as i've been messing around......i know that sounds mad but i and others have commented on it.
    now, i have learnt to download/rip automatically to the EXT HD, so that a lot of these problems are alleviated in the future.

Maybe you are looking for

  • Still shots are getting cropped on playback in Premiere or export

    Not sure why, but when I import a bunch of png images they are getting cropped whey I try to play them or export them to a movie.  Any ideas why?

  • NI 488.2 - 3.1.1 installation error (windows 7)

    Hello, I tried to install the NI 488.2 driver to connect an GPIB-USB-HS device on my computer. All my try were unsuccessful (execute as administrator, desactivate my antivirus software,...). The joined messages appeared. Thank you in advance for your

  • E51 poor image quality and speaker tone,any soluti...

    Hi! friends.I have bouht new E51.Its image quality taken from camera is poor.Although image resolution is high but low quality of camera is main problem.Is there any solution to improve image quality or any software to improve? Also ringing tone is s

  • Anybody know anything about Windows 7 joining Samba/NT4 Domains?

    Hello all, I recently failed at getting a computer running Windows 7 to join a Samba server's domain, I was later succesful at joining the machine to the domain after installing Windows 2000 and discovered the solution (adding missing data in the lda

  • I want my horizontal scroll bar!

    It is unbelievably tedious to have to open the custom zoom widget in order to accomplish something as simple as a horizontal scroll in a document -- particularly since the custom zoom widget cannot be moved over to the side where the bookmarks pane i