properly changing internal modules such Arch

A forum dedicated to the Draft, Arch and BIM workbenches development.
User avatar
teobo
Posts: 405
Joined: Fri Feb 21, 2014 11:23 am

properly changing internal modules such Arch

Postby teobo » Fri Jul 25, 2014 11:14 pm

Hello,
(do not know if I am right, though.)
I am interested in analysing maybe modifying some modules. Already managed it to import some external modules by copying the files to ~/.FreeCAD/Mod/.

Now I am interest lets say the Arch module. How should I handle this properly?
Should I move the folder /git/freecad/src/Mod/Arch/ to ~/.FreeCAD/Mod/ and restart after modifying the sources
- or should I modify the /git/freecad/src/Mod/Arch/ directly and then recompile and restart freecad? Do I need to change something in the make settings for it?
Tia
User avatar
teobo
Posts: 405
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such as Arch

Postby teobo » Sat Jul 26, 2014 2:32 pm

Hi,
after some trying I got something solved:
I moved the Arch folder
mv src/Mod/Arch/ /home/user/.FreeCAD/Mod/

and then after each change restarted Freecad. Would be fine if Freecad reread the sources, though.
Would it be better to test the code firstly as macros? :?
User avatar
yorik
Site Admin
Posts: 10848
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: properly changing internal modules such Arch

Postby yorik » Sat Jul 26, 2014 4:24 pm

Note that you don't need to move the folder, you can simply copy it. If there is a folder with the same name in .FreeCAD/Mod and /installed/path/to/FreeCAD/Mod, the first one is used and overrides the installed one.

If you plan to just play, you can do like you say (you can always compare your changes with the original one with tools liek diff), but if you plan to make more permanent changes, then you should consider using a tool like git, which helps you much to keep track of the changes you do...
User avatar
teobo
Posts: 405
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Postby teobo » Sat Jul 26, 2014 5:22 pm

thanks.
What would be the way to reload the code for testing let us say changes with the survey command. I did it that way,
.

Code: Select all

>>> import sys
>>> sys.path.append('~/.FreeCAD/Mod/Arch')
>>> reload(ArchCommands)
>>> Arch.survey()
proper?
User avatar
teobo
Posts: 405
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Postby teobo » Sat Jul 26, 2014 5:31 pm

yorik wrote:Note that you don't need to move the folder, you can simply copy it. If there is a folder with the same name in .FreeCAD/Mod and /installed/path/to/FreeCAD/Mod, the first one is used and overrides the installed one.

If you plan to just play, you can do like you say (you can always compare your changes with the original one with tools liek diff), but if you plan to make more permanent changes, then you should consider using a tool like git, which helps you much to keep track of the changes you do...
Where should I preferably put this git directory?

at .FreeCAD/Mod/
at .FreeCAD/
at .FreeCAD/Mod/Arch/
at the source tree?
at a ../Dir/Arch sym-linked to .FreeCAD/Mod/

tia
User avatar
yorik
Site Admin
Posts: 10848
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: properly changing internal modules such Arch

Postby yorik » Sat Jul 26, 2014 7:32 pm

It depends. If you are mainly planning things for yourself, start the git repo anywhere you like. If you are planning to do changes that you will propose for inclusion in FreeCAD (remember that there is no guarantee that you changes get accepted out of the box, okay?) then it's better to use the freecad source folder itself, so your changes are easy to merge later. You can then create a new branch, do all your work there, and keep the master branch intact so you can sync with the official freecad repo, then push your branch on a public repo like github.
User avatar
teobo
Posts: 405
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Postby teobo » Sat Jul 26, 2014 11:02 pm

yorik wrote: so you can sync with the official freecad repo, then push your branch on a public repo like github.
you mean a personal separate github repo? Just for interest: How gets it then "accepted" and into the official tree?
User avatar
yorik
Site Admin
Posts: 10848
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: properly changing internal modules such Arch

Postby yorik » Sun Jul 27, 2014 1:28 am

Basically you put your work in a separate branch (so it can be compared with the master code), you upload that branch somewhere (github or any other), and, when you are ready, you post the link to that branch here in the "pull requests" section of the forum. Someone (Jürgen, Werner or me) will review it. If you do something small, that is easy to review, and that clearly benefits freecad, for example you fix a bug, it will be easy for us to review and we'll probably be able to merge it quickly.

If you do something bigger, and especially if you are going to modify some existing functionality, causing current users to need to change their behaviour, then it is safer to discuss your work before submitting a feature request, and let other people test your code. If people like what you have done, then there will be no problems merging it.
User avatar
teobo
Posts: 405
Joined: Fri Feb 21, 2014 11:23 am

Re: properly changing internal modules such Arch

Postby teobo » Sun Jul 27, 2014 2:24 pm

yorik wrote: and let other people test your code. If people like what you have done, then there will be no problems merging it.
How the testing is organized? Should I send a testing request of let us say a certain module to a forum? Together with installing or/and compiling instructions?
User avatar
yorik
Site Admin
Posts: 10848
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: properly changing internal modules such Arch

Postby yorik » Sun Jul 27, 2014 2:37 pm

Just open a new thread in the "open discussion" section, and explain what your changes do, give the link to your branch, and tell people you want feedback!