Disable /usr/lib/rpm/brp-python-bytecompile in sbt native packager rpm build - rpmbuild

I have few python files which I copy inside rpm using sbt-native-packager
But right now rpm compiles them to pyo and pyc files which I do not want.
How to tell it to not to do that.
Thanks

In the spec file, %build section where you call setup.py, you can use --no-target-compile. In some cases, --no-compile also works.
%build
python setup.py --no-compile

Related

Why use %files directive in RPM spec file and how to automate file listing in that section?

Why does %files needed and why it cannot be created automatically by listing $RPM_BUILD_ROOT directory contents?
For example, in that spec file i have to use some modifications in it in script, that build an RPM package for me. I have to cd into ~/RPM/SOURCES, then find . in it and echo each line into .spec file to setup %files section. It can be done automatically by the tool using the same techniuque i do in the background but from $RPM_BUILD_ROOT directory instead?
%install
mkdir -p $RPM_BUILD_ROOT/opt/MyCompany/MyProduct/
cp -rf -- ~/RPM/SOURCES/* $RPM_BUILD_ROOT/opt/MyCompany/MyProduct/
%files
/opt/MyCompany/MyProduct/file_1
/opt/MyCompany/MyProduct/file_2
/opt/MyCompany/MyProduct/file_3
... - a lot of lines here
/opt/MyCompany/MyProduct/file_100000
UPD:
Yes it is possible to use all copied files automatically (Doc http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html)
In my case %files can be rewritten as that
%files
/opt/MyCompany/MyProduct/*
It will take files from $RPM_BUILD_ROOT/opt/MyCompany/MyProduct, so to use star we need to omit build root which is $RPM_BUILD_ROOT or %{buildroot} (Which is default path where rpm searches for files IIUC)
Why does %files needed and why it cannot be created automatically by listing
$RPM_BUILD_ROOT directory contents?
It is common that one spec file build creates multiple (sub)packages - then also
multiple %files sections are needed.
Even though there exist some automatic %files
section
generators,
nb there's the
%files -f option,
in general it isn't possible to split the files automatically.
Worth saying that most of the package maintainers don't maintain the software
source code, but just package the "upstream" releases. If the %files sections
are rather manually maintained (in contrast with the wildcard patterns), the
package maintainer has everything a bit more under control because he is
notified about the changes in the software installation layout (e.g. when a new
file appears in /usr/bin with a new release, rpmbuild starts complaining that
there's a new "unpackaged" file, see below).
It can be done automatically by the tool using the same techniuque i do in the
background but from $RPM_BUILD_ROOT directory instead?
You don't even have to run find manually. As long as %install creates the
files in $RPM_BUILD_ROOT, if you don't mention them in %files - you get reports
like those:
$ rpmbuild -bb *.spec
...
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/user/rpmbuild/BUILDROOT/test-1-1.x86_64
error: Installed (but unpackaged) file(s) found:
/usr/bin/not-packaged
RPM build errors:
Installed (but unpackaged) file(s) found:
/usr/bin/not-packaged

Creating a pyinstaller executable that uses virtualenv imported modules

So, the title basically covers my question. I've created a project using virtualenv, e.g. I have to
source ./env/bin/activate
to run my script.
When I try creating an executable using:
pyinstaller --onefile <myscript.py>
None of the virtualenv packages are included; just the ones that are installed globally. I have a requirements.txt file that contains all of the modules I need. Is there a way to have pyinstaller point to that for the needed modules, or is there another way?
As Valentino pointed out by looking at How can I create the minimum size executable with pyinstaller?
You have to run PyIntaller from inside the virtual environment:
(venv_test) D:\testenv>pyinstaller
How to solve the not importing modules from the virtual environment
The virtual environment saves modules in a different directory than the global module directory. If you are using Windows like me, you can find the modules directory here:
C:\Users\<your username>\.virtualenvs\<your project name>\Lib\site-packages
When you find your virtualenv directory, run this command instead of this simple command(pyinstaller <script>.py):
pyinstaller --paths "C:\Users\<your username>\.virtualenvs\<your project name>\Lib\site-packages" --hidden-import <module name that should be import> <your script name>.py
To export just one file you can add this: -F or --onefile
As many modules as you can add to be imported by adding more --hidden-import flags and module name
Flag description
--paths: The pyinstaller will search for imports here
--hidden-import: Which modules should be imported by pyinstaller from the path

Powershell build - compiling SASS

I'm hoping to start using SASS in a Visual Studio 2010 project using Web Workbench - but the issue of version control through TFS has me stumped. To avoid overriding someone else's changes I understand that the outputted CSS should be excluded from source control, and that the SCSS should be compiled to CSS server side during the build process. Currently we use a Powershell script for the build, but I can't seem to find any information on how to incorporate SCSS compilation in Powershell. Is there any decent documentation out there on this process?
I think my lack of experience with Powershell/build scripts in general had me overthinking this. I took the following steps:
1) Installed Ruby for Windows from here: https://www.ruby-lang.org/en/documentation/installation/
2) Open Command Prompt -> entered gem install ruby
3) Opened PowerGUI Script Editor (already installed, but can be downloaded here: http://software.dell.com/products/powergui-freeware/)
4) Created a function to execute the following: sass -t compressed "path\sassInput.scss" "path\sassOutput.css"
And presto. I do want to have a way of doing this for each .scss file in the directory that is not a partial, but this is enough to get me started for now.
UPDATE:
This is what I ended up with for a Powershell script: (note $dirpath is set to my project's root directory elsewhere)
$stylesheetPath = $dirpath + "App_Themes\"
$files = Get-ChildItem $stylesheetPath -Filter *.scss
for ($i=0; $i -lt $files.Count; $i++) {
$file = $files[$i]
$fileName = $file.BaseName
$filePath = $file.FullName
if (-not $fileName.StartsWith("_")) {
$newFilePath = "$stylesheetPath$fileName.css"
sass -t compressed $filePath $newFilePath
}
}
You need a SASS compiler and your mileage may vary. The original compiler is written in Ruby, so, if you want to use that, you have to install Ruby, the SASS gem and invoke sass from your Powershell script.
Another option is to use a compatible compiler like SassC or C6 which do not need the Ruby runtime.
I had the same problem. U have this one because powershell have restricted executable policy. U can do next:
0. Install node.js, npm, node-sass
Run PowerShell as Administrator
Chech policy with Get-ExecutionPolicy
U will see Restricted
See all policies Get-ExecutionPolicy -List
Run Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Press "Y"
Use node-sass -w ./input.scss ./output.css
Also, U can read more here
Install Node.JS (https://nodejs.org/download/)
Install Ruby for Windows (http://rubyinstaller.org/)
run npm init in your project directory to create a packages.json file.
install grunt npm install grunt --save-dev (http://gruntjs.com/getting-started)
install grunt-contrib-sass npm install grunt-contrib-sass --save-dev
create an empty Gruntfile.js in your project root
add the following to your gruntfile.js
module.exports = function(grunt) {
// Do grunt-related things in here
};
follow instructions here to create a grunt-sass task: https://github.com/gruntjs/grunt-contrib-sass
Some simple examples are provided near the end of the readme.
run grunt from a powershell window in you project root.
PROFIT!
this snippet might help when adding this to your automated build script:
push-location c:\dev\project
grunt
pop-location

How to let autotools compile a QT module with qmake

In my project I have made configure.ac and Makefile.am files correctly so my components compile and dynamically link to the appropriate libraries. One of these components links to a library that uses QT, so the appropriate Makefile must be generated out of the .pro file prior compilation on the target system.
For this I think that I need to find a way to tell my make scripts, through Makefile.am perhaps, that this library must be compiled on its own by first running qmake and the generated Makefile in that directory.
Is this even possible? If so, how do I do it?
Researching on my own I have found an apparently abandoned project called “AutoTroll” which is supposed to automatically alter files of autotools in order to add compatibility with Qt4. I have tried to make it work with no luck. It lacks a proper documentation also.
Without this tool, compiling Qt4 modules with autotools requires a lot of hacking and interventions, making it really hard and even more for a cross-platform application.
I have switched to CMake. CMake’s setup is far easier than autotools’ and it supports Qt4 modules out of the box.
We do this, its not that difficult. In configure.ac:
QT_QMAKE
[
echo $QMAKE -o Makefile.myapp $(realpath $(dirname $0))/myapp.pro
$QMAKE -o Makefile.myapp $(realpath $(dirname $0))/myapp.pro
]
Then (Assuming your macros are located in the standard m4 directory), make a file called qt_qmake.m4 there.
AC_DEFUN([OTT_QT_QMAKE],[
if test -z "$QMAKE"; then
QMAKE=$(which qmake)
$QMAKE -v > /dev/null 2>&1
if test $? -ne 0; then
AC_MSG_ERROR([qmake executable not found!])
fi
fi
AC_SUBST(QMAKE)
])
Then in Makefile.am:
ACLOCAL_AMFLAGS=-Im4
all-am:
make -f Makefile.myapp all
install-am:
make -f Makefile.myapp install
qmake_all:
make -f Makefile.myapp qmake_all
clean-am:
make -f Makefile.myapp clean
That should align with the targets that QTCreator uses, and allows you to "bootstrap" qmake using autotools to make a config.h for instance, or global qmake include file to make shadow builds easier. Theres a lot I'm leaving out if you want to have version checking,etc... but it should get you started. If you built qt yourself, or have it not in your path, ie redhat (/usr/lib{64}/qt5/bin/qmake), you can just use the QMAKE variable to point to it. QT is smart enough with that to take it from there usually. I know its not the most elegant solution, but its worked for us cross-linux for almost a decade.

CMake + Qt : define the moc/ui output directory

I'm currently transferring a project built with qmake to CMake.
In the version with qmake, in the .pri file, there was
MOC_DIR = .moc/$${PLATFORM_NAME}
that permitted to produce the MOC temporary files in a given directory, keeping the sources clean. How to do the same thing with CMake?
Note: with CMake, I use the FindQt4.cmake package and the command QT4_WRAP_CPP().
As baysmith says, if your goal is to keep your source directory clean, the real solution is to use CMake's "out-of-source" builds feature. If you're on Windows, set "Where to build the binaries" to a new directory, different from the "Where is the source code" directory. If you're on Unix, it goes something like this:
cd <source directory>
mkdir build
cd build
cmake ..
make
By running CMake on a different directory, all of the build files will go into that directory, and your sources will stay clean. (Note: the build directory doesn't have to be inside the source directory. See the CMake wiki for more details.)
If "out-of-source" doesn't work for you, I was able to find one other option. Based on what I can tell from the Qt4Macros.cmake file installed with my CMake 2.8, it isn't accessible as a config parameter. Here's the relevant line:
SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_current_MOC})
The workaround is to change all of your MOC include directives to specify the subfolder you'd like to build to.
#include "moc/mainwindow.moc"
After creating the moc directory inside my build directory, there were no problems building, and my MOC file was in the new directory.

Resources