I'm investigating migrating a source code repository currently kept under SCCS on an aging Digital UNIX box to Subversion on a Windows box. My initial searching has led me to a python script, sccs2svn, which looks like it would do the job - with some restrictions. A du -sk on the SCCS directory shows it to be about 550MB in size.
From what I can tell, the script runs on a local machine and operates on both SCCS and SVN locally: SCCS through executing SCCS commands directly; SVN through a python module, but also calls svnadmin to create a local directory.
Unfortunately, I need to create the repo on a different server; from what I read in the SVN mailing lists etc, a SVN repo can't simply be copied between servers if the platform is different: an svnadmin dump and restore is required.
The only way I think I can see this working is as a two-stage migration: firstly, to install SVN and python on the existing server, run the script there, then secondly dump the repo out and load it into the Windows SVN - which should work, just slightly more time consuming and requiring a little more disk.
Is anyone aware of a way I could do this without doing it in two stages? Could the python script be modified to act upon a remote repository if the lines to create the repo are commented out? I'll be doing some reading into the Python SVN module, but Python isn't a scripting language I've played with before.
If you use FSFS backend, you can just move the repository to your target platform. FSFS Repositories are truely platform indipendent. They are also standard setup since svn 1.3 so you should not have any problems by creating the repository and then copy it to your final server via any file transfer.
If sccs2svn really must work locally and you want to end up with the SVN repository on a Windows box, then use the Cygwin version of GNU CSSC to run sccs2svn on the Windows box itself. CSSC is an SCCS workalike: see http://www.gnu.org/software/cssc/
Another alternative if you have more flexibility is to use both CSSC and SVN on a GNU/Linux system.
Related
I've made this question because I had to go through the whole process of creating my own application using Apple's somewhat lacking documentation, and without the use of py2app. I wanted to create the whole application structure so I know exactly what was inside, as well as create an installer for it. The latter of these is still a mystery, so any additional answers with information on making a custom installer would be appreciated. As far as the actual "bundle" structure goes, however, I think I've managed to get the basics down. See the answer below.
Edit: A tutorial has been linked at the end of this answer on using PyInstaller; I don't know how much it helps as I haven't used it yet, but I have yet to figure out how to make a standalone Python application without the use of a tool like this and it may just be what you're looking for if you wish to distribute your application without relying on users knowing how to navigate their Python installations.
A generic application is really just a directory with a .app extension. So, in order to build your application, just make the folder without the extension first. You can rename it later when you're finished putting it all together. Inside this main folder will be a Contents folder, which will hold everything your application needs. Finally, inside Contents, you will place a few things:
Info.plist
MacOS
Resources
Frameworks
Here you can find some information on how to write your Info.plist file. Basically, this is where you detail information about your application.
Inside the MacOS you want to place your main executable. I'm not sure that it matters how you write it; at first, I just had a shell script that called python3 ./../Resources/MyApp.py. I didn't think this was very neat though, so eventually I called the GUI from a Python script which became my executable (I used Tkinter to build my application's GUI, and I wrote several modules which I will get to later). So now, my executable was a Python script with a shebang pointing to the Python framework in my application's Frameworks folder, and this script just created an instance of my custom Tk() subclass and ran the mainloop. Both methods worked, though, so unless someone points out a reason to choose one method over the other, feel free to pick. The one thing that I believe is necessary, is that you name your executable the SAME as your application (before adding the .app). That, I believe, is the only way that MacOS knows to use that file as your application's executable. Here is a source that describes the bundle structure in more detail; it's not a necessary read unless you really want to get into it.
In order to make your executable run smoothly, you want to make sure you know where your Python installation is. If you're like me, the first thing you tried doing on your new Mac was open up Terminal and type in python3. If this is the case, this prompted you to install the Xcode Command Line tools, which include an installation of Python 3.8.2 (most recent on Xcode 12). Then, this Python installation would be located at /usr/bin/python3, although it's actually using the Python framework located at
/Applications/Xcode.app/Developer/Library/Frameworks/Python3.framework/Versions/3.8/bin/python3
I believe, but am NOT CERTAIN, that you could simply make a copy of this framework and add it to your Frameworks folder in order to make the app portable. Make a copy of the Python3.framework folder, and add it to your app's Frameworks folder. A quick side note to be wary of; Xcode comes packaged with a lot of useful tools. In my current progress, the tool I am most hurting for is the Fortran compiler (that I believe comes as a part of GCC), which comes with Xcode. I need this to build SciPy with pip install scipy. I'm sure this is not the only package that would require tools that Xcode provides, but SciPy is a pretty popular package and I am currently facing this limitation. I think by copying the Python framework you still lose some of the symlinks that point to Xcode tools, so any additional input on this would be great.
In any case, locate the Python framework that you use to develop your programs, and copy it into the Frameworks folder.
Finally, the Resources folder. Here, place any modules that you wrote for your Python app. You also want to put your application's icon file here. Just make sure you indicate the name of the icon file, with extension, in the Info.plist file. Also, make sure that your executable knows how to access any modules you place in here. You can achieve this with
import os
os.chdir('./../Resources')
import MyModules
Finally, make sure that any dependencies your application requires are located in the Python framework site-packages. These will be located in Frameworks/Python3.framework/Versions/3.X.Y/lib/python3.x.y/site-packages/. If you call this specific installation of Python from the command line, you can use path/to/application/python3 -m pip install package and it should place the packages in the correct folder.
P.S. As far as building the installer for this application, there are a few more steps needed before your application is readily downloaded. For instance, I believe you need to use the codesign tool in order to approve your application for MacOS Gatekeeper. This requires having a developer license and manipulating certificates, which I'm not familiar with. You can still distribute the app, but anyone who downloads it will have to bypass the security features manually and it will seem a bit sketchy. If you're ready to build the installer (.pkg) file, take a look at the docs for productbuild; I used it and it works, but I don't yet know how to create custom steps and descriptions in the installer.
Additional resources:
A somewhat more detailed guide to the anatomy of a macOS app
A guide I found, but didn't use, on using codesign to get your app past Gatekeeper
A RealPython tutorial I found on using PyInstaller to build Python-based applications for all platforms
Q: In creating a python distribution using setup.py, how can I define Python code that will be run by pip at installation time (NOT at build time!) and runs on the installation target machine (NOT on the build machine!)
I have spent the past seek searching the web for answers, reading contradictory documentation pages, and viewing multiple videos about setup.py. But in all this research can't find even one working example of how install time tasks can be specified.
Can someone point me at a complete working example?
Background: I am writing Python code for an application that is controlling a specialized USB peripheral my company is making, the processor where this will be installed is embedded/bundled with the peripheral and control software.
What's Needed: During the installation of the controlling application, I need the installing program (pip?) to write a configuration file on the install target machine. This file needs to include machine specific information about the target machine acquired using calls to functions imported from Lib/platform.py.
What I tried: Everything I've tried so far either runs at build time on the build machine (when setup.py runs and thus picks up the WRONG information for the target machine), or it merely installs the code I want to run on the target, but does not run it. It thus requires manual intervention by the user after the pip installation but prior to attempting to run the program they think they just installed, to run the auxiliary program that creates the installation config file. Only after this 2 step process can the user actually run the installed (and now properly configured) application.
Source code: Sorry. All my failed attempts to put functions in setup.py (which only run on the build machine, at build time) would only further confuse any readers and encourage more misleading wild goose chases down pointless rat holes.
If my users were sophisticated python developers who are comfortable with command line error messages, the link that #sinoroc has provided in the previous comment would have been an interesting solution.
Given that my users are barely comfortable installing packages from the App Store or Google Play store, the referenced work around is probably not right for me.
But given that install time functions are regarded as bad practice, my workaround is to alter the installed program so that its first action is to check for the presence of the necessary configuration file every time the program runs.
While this checking is seemingly unnecessary after the first run, it consumes only minimal CPU resources and would be more robust if the configuration file is ever accidentally deleted.
I've downloaded the python 3.6.6 source from here...
https://www.python.org/downloads/release/python-366/
...and followed the instruction on how to build on Windows (run ../PCbuild/build.bat). Python compiles and seems to be working (funny and scary: while fetching externals, it actually downloads python-3.7.0 as a dependency... :/ ). However, it looks like the build is somehow 'in place', and the binaries end up in some sub-folder of the source (../PCbuild/amd64/python.exe). This means I'm left with source and compiled code mixed up instead of some clean/lean and deployable package.
can I somehow provide '--prefix=/target/build/path' to define a target location to build to, like I would on linux?
is there a way of removing all src files/folders and leave only the required files/folders (../lib, ../include, etc...).
Or in general, is there a way of making the build process more behave like on linux?
Thanks for your help,
Max
The build.bat from PCBuild is intended for developers, that is, for testing purposes. What you want is under \Tools\msi\buildrelease.bat. This creates a subdirectory under \PCBuild\ that places all msi, cab and exe files ready for later installation. According to the readme, there doesn't seem to be an option to pack all those files in a single .exe file, like all installers eventually do, but another option is under \Tools\msi\build.bat which does have an option for packing (namely build.bat --pack). "But", the readme does state that the buildrelease.bat should be used for an official release. The advantage of doing so is that Pyhton would be optimized using PGO to your own hardware. I am also trying to compile from source using this method but I am having an issue with a recurring error (and other ones):
PGO run did not succeed (no python36!*.pgc files) and there is no data to merge [E:\RepoGiT\3.6\PCbuild\pythoncore.vcxproj]
so, if you do go this route, and find this, or other errors, please send the bug report to python's bug tracker webpage. And better yet, if you find errors and their solution, please report back here!
I am working on a small django project at home. I would like to install and use a small version control system for personal use for free. I don't want to use a web service like github because I am not always connected. I would like to have the VCS server/daemon installed and use it at my home pc (windows 7).
I would also like it to be compatible with eclipse+pydev which I use for programming.
Any help would be greatly appreciated!
Thanks,
Chris
GIT is built in a way that you can use it 'offline': doing commit, reverting change, browsing history.
I don't see any advantage in your case to use SVN instead of GIT (you can host your own GIT server, no need to use github.com)
http://book.git-scm.com/4_setting_up_a_public_repository.html
There are also GIT alternatives for distributed SCM:
Mercurial
Bazaar
BTW, for my personal prototype DropBox is sufficient ;)
I suggest using mercurial with a Bitbucket private repository. Mercurial will work just fine when you're offline, and you can push your changes to Bitbucket to access your code elsewhere (your laptop, server, etc.) later.
There's also mercurial plugins for eclipse. (see Mercurial Eclipse Plugin)
I would recommend to use Mercurial together with DropBox in order to make sure that you don't lose everything in case of crash.
See http://www.h4ck3r.net/2010/05/11/mercurial-hg-with-dropbox/
I hope it helps
For personal version control, I would recomend the following:
FileHamster
Oops! Backup
FolderTrack
Note: I am an author of FolderTrack. I recomend it for use with programming because it will treat a group of source files as one "work product". If you want to rewind your code to yesterday and that requires deleting 2 files, renameing 1 file, and chaning 15 more then foldertrack will do it.
The free license for Foldertrack is: BOS
SVN has Eclipse plugins (Subclipse, Subversive), I don't know for pydev though. But it is one of the most used version control system and it is free.
If it is for personal use, thus you probably don't have to go with distributed vcs, I would definitely go with subversion (svn). It has nice plugin for eclipse: subversive. I'm using it for years.
http://subversion.apache.org/
for eclipse:
http://www.polarion.com/products/svn/subversive.php
I tried several Python IDEs (on Windows platform) but finally I found only Eclipse + PyDev meeting my needs. This set of tools is really comfortable and easy to use. I'm currently working on a quite bigger project. I'd like to have a possibility to use CVS or any other version control system which would be installed on my local harddrive (I recently moved my house and don't have yet an access to internet.)
It doesn't matter for me if it'd be CVS - can also be any other version control system. It'd be great if it will be not too hard to configure with Eclipse. Can anyone give me some possible solution? Any hints?
Regards and thanks in advance for any clues. Please forgive my English ;)
Last time I tried this, Eclipse did not support direct access to local repositories in the same way that command line cvs does because command line cvs has both client and server functionality whereas Eclipse only has client functionality and needs to go through (e.g.) pserver, so you would probably need to have a cvs server running.
Turns out that I didn't really need it anyway as Eclipse keeps its own history of all changes so I only needed to do an occasional manual update to cvs at major milestones.
[Eventually I decided not to use cvs at all with Eclipse under Linux as it got confused by symlinks and started deleting my include files when it "synchronised" with the repository.]
If you don't mind a switch to Subversion, Eclipse has its SubClipse plugin.
As others have indicated, there are plugins available for Eclipse for SVN, Bazar, Mercurial and Git.
Even so, despite their presence, I find using the command line the most comfortable.
svn commit -m 'now committing'
Assuming you are not committing for more than several times a day, this should work well enough. Is there anything specific that is preventing you from using the command line?
I tried Eclipse+Subclipse and Eclipse+Bazaar plugin. Both work very well, but I have found that Tortoise versions of those version source control tools are so good that I resigned from Eclipse plugins. On Windows Tortoise XXX are my choice. They integrate with shell (Explorer or TotalCommander), changes icon overlay if file is changed, shows log, compare revisions etc. etc.
I would definitely recommend switching over to a different VCS—I prefer Mercurial, along with a lot of the Python community. That way, you'll be able to work locally, but still have the ability to publish your changes to the world later.
You can install TortoiseHg for Windows Explorer, and the MercurialEclipse plugin for Eclipse.
There's even a Mercurial for CVS users document to help you change over, and a list of mostly-equivalent commands.
I believe Eclipse does have CVS support built in - or at least it did have when I last used it a couple of years ago.
For further information on how to use CVS with Eclipse see the Eclipse CVS FAQ
I recently moved my house and don't have yet an access to internet.
CVS and SVN are the Centralized Version control systems. Rather than having to install them on your local system just for single version control, you could use DVCS like Mercurial or Git.
When you clone a Mercurial Repository, you have literally all versions of all the repo files available locally.
I use Eclipse with a local CVS repository without issue. The only catch is that you cannot use the ":local:" CVS protocol. Since you're on Windows, I recommend installing TortoiseCVS and then configuring the included CVSNT server as follows:
Control Panel: CVSNT
Repository configuration: create a repository and publish it
Note the Server Name and make sure it matches your hostname
Eclipse: Create a new repository location using the :pserver: connection type and point it to your local hostname
This (or any actual source control system) has the advantage over the Eclipse Local History of being able to associate checkin comments with changes, group changes into change sets, etc. You can use the Eclipse Local History to recover from minor mistakes, but it's no replacement for source control (and expires as well: see Window->Preferences General->Workspace->Local History).