Quickly Package - Need Help Please

Asked by Aruna Hewapathirane

Hi,

Can someone PLEASE explain the code below to me. And is there a step by step tutorial or how-to on buidling a deb and packaging ?

#============================================================================================
# Check if we are working in the source tree or from the installed package and mangle the python path accordingly
if os.path.dirname(sys.argv[0]) != ".":
    if sys.argv[0][0] == "/":
        fullPath = os.path.dirname(sys.argv[0])
    else:
        fullPath = os.getcwd() + "/" + os.path.dirname(sys.argv[0])
else:
    fullPath = os.getcwd()
sys.path.insert(0, os.path.dirname(fullPath))
============================================================================================

The app I built runs fine under my file system but when I package and then install the deb all my data file paths are no longer there. Quickly package by defualt puts everything under usr/share which is fine but what if I want some files or directories in other locations under my project root ? How can I do this ?

And can "I" specify python disutils to put files where "I" would like them to be ? If so how ? Thank you...

Question information

Language:
English Edit question
Status:
Solved
For:
Quickly Edit question
Assignee:
No assignee Edit question
Solved by:
Aruna Hewapathirane
Solved:
Last query:
Last reply:
Revision history for this message
Rick Spencer (rick-rickspencer3) said :
#1

Hi Aruna,

Are you using the command "quickly package" to create your deb?

1. Your app should run fine if you use "quickly package" and then install from the deb. Unless you changed the directory structure that the quickly template created for you.
2. In terms of specifying where "you" want to put the files, the answer is "no you can't specify where to put files. Quickly isn't really that kind of project. Quickly tries to create sane defaults for you, and if you stick those defaults, Quickly can do some useful things for you, like create packages, release to PPAs, etc... However, if you deviate from those defaults, there is a good chance that Quickly won't be able to help you anymore. Quickly tries to get out of the way and let you focus on coding, and not worry about packaging.

HTH

Cheers, Rick

Revision history for this message
John Lenton (chipaca) said :
#2

Hi,

On Mon, Aug 30, 2010 at 06:45:18PM -0000, Aruna Hewapathirane-අරැණ හේවාපතිරණ wrote:
>
> Can someone PLEASE explain the code below to me.
>
> #============================================================================================
> # Check if we are working in the source tree or from the installed package and mangle the python path accordingly
> if os.path.dirname(sys.argv[0]) != ".":
> if sys.argv[0][0] == "/":
> fullPath = os.path.dirname(sys.argv[0])
> else:
> fullPath = os.getcwd() + "/" + os.path.dirname(sys.argv[0])
> else:
> fullPath = os.getcwd()
> sys.path.insert(0, os.path.dirname(fullPath))
> ============================================================================================

the code seems to be a poor version os.path.abspath(). Not sure where
it's from :)

Revision history for this message
Didier Roche-Tolomelli (didrocks) said :
#3

> the code seems to be a poor version os.path.abspath(). Not sure where
it's from :)

Not at all, just look at the comment, even quoted there:
# Check if we are working in the source tree or from the installed package and mangle the python path accordingly

Of course, you are welcome to improve it.

Revision history for this message
John Lenton (chipaca) said :
#4

On Mon, Aug 30, 2010 at 08:45:50PM -0000, Didier Roche wrote:
> Question #123384 on quickly changed:
> https://answers.edge.launchpad.net/quickly/+question/123384
>
> Didier Roche posted a new comment:
> > the code seems to be a poor version os.path.abspath(). Not sure where
> it's from :)
>
> Not at all, just look at the comment, even quoted there:
> # Check if we are working in the source tree or from the installed package and mangle the python path accordingly

yes, and as I say I'm not sure where it's from, but from looking at
the code the *intent* seems to be the same as abspath. Clearly they
are not the same, but it is unclear to me whether that is by design or
if it simply a bug: given the following inputs, "fullpath" output as
compared to abspath output is (when standing in my home):

path fullpath abspath
                     IndexError /home/john
. /home/john/ /home/john
./ /home/john /home/john
.. /home/john/ /home
../ /home/john/.. /home
/../ /.. /
/foo/bar /foo /foo/bar
/foo/bar/ /foo/bar /foo/bar

granted, some of these are pathological :)

> Of course, you are welcome to improve it.

sure! Please point me at the test cases so I know what to refactor :)

Revision history for this message
Rick Spencer (rick-rickspencer3) said :
#5

There are no tests that I am aware of. Feel free to add some.

AIUI, the intent of the code is to allow the application to find the library under development whether it's in "coding" mode, or "installed" mode. When in coding mode, the library is ../app_name relative to the main file, so python has to know where to find it.

I think that's what is going on there. If there is a better way to do it, we will gladly except a patch.

Cheers, Rick

Revision history for this message
Aruna Hewapathirane (aruna-hewapathirane) said :
#6

Hi Rick, Didier and John,

Thank you all for the clarifications. and Yes I am using Quickly Package Command Rick.

You see the thing is "I" love quickly, simply for two reason. It allows you to develop the GUI rapidly and uses the Model View Controller concept, beautiful the way it separates the code from the UI.

And quickly hides the usually tedious and complex process of packaging and deploying to launchpad. That being said I also understand what the said code does, it identifies if we are in a code/develop branch or if we are running a actual installed deb. then finds the necessary files.

I also understand Quickly uses sane defaults BUT if the defaults are NOT configurable by a developer to suit his/her 'needs' this is a stumbling block and I do NOT want to stop using Quickly simply due to not being able to re-configure the usr/share/<project_name> path that is the default.. :-)

Quickly puts the installed deb under usr/share/<project_name> right ? How do I keep my directory structure under my project root intact ? There MUST be a way...

Another question is WHY does quickly packaging sometimes say some files are not recognised when packaging ? It would be best I feel NOT to hard wire the sane defaults but also try and give the developer the means to specify his/her own ?

I am trying hard to understand where quickly packaging specifies the default paths but am so new to all this so any and all help you can extend would be most welcome.

Revision history for this message
Aruna Hewapathirane (aruna-hewapathirane) said :
#7

See I have a directroy structre that resembles this:

home/aruna/python/shoutcast/

And under shoutcast Quickly generates the default bin,data and project ui shoutcast directory oki ?

Now, I have a imports directory and two other directories at the SAME level as the data and bin directories. And all is fine. But once quickly packages it puts it under usr/share/ thereby changing the file paths. All I need to do is UNDERSTAND this relative file path piece of code and am sure I can hack it to do the needful.

If there are more than the generated file in the bin quickly packaging generates a warning why ?

Revision history for this message
Didier Roche-Tolomelli (didrocks) said :
#8

@John Lenton, Rick:

jml also add the fullpath thing instead of abspath to be able to symlink the executable from another directory too.

Revision history for this message
Didier Roche-Tolomelli (didrocks) said :
#9

@Aruna:
Quickly use what the Debian Policy advice, if you don't follow that, you won't be FHS compliant and your package won't be able to integrate into distributions later.

If you want to break the rule, you have to begin to learn how to package as you are considered then as an advance user. To do that, please see https://wiki.ubuntu.com/PackagingGuide/Complete

Revision history for this message
Aruna Hewapathirane (aruna-hewapathirane) said :
#10

Thank you very much for all the help Didier. That solved my question.