Skip to content

Commit eb4dd03

Browse files
authored
Merge pull request #58 from oglez/master
Merging latest additions and improvements in preparation for the April'25 CAT Hackathon
2 parents a0a0669 + 24b479e commit eb4dd03

File tree

16 files changed

+1831
-343
lines changed

16 files changed

+1831
-343
lines changed

.github/workflows/cd.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
with:
1818
fetch-depth: 0
1919

20-
- uses: hynek/build-and-inspect-python-package@v1
20+
- uses: hynek/build-and-inspect-python-package@v2
2121

2222
publish:
2323
needs: [dist]
@@ -28,10 +28,9 @@ jobs:
2828
if: github.event_name == 'release' && github.event.action == 'published'
2929

3030
steps:
31-
- uses: actions/download-artifact@v3
31+
- uses: actions/download-artifact@v4
3232
with:
3333
name: Packages
3434
path: dist
3535

3636
- uses: pypa/gh-action-pypi-publish@release/v1
37-

.github/workflows/softwarecheck.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ jobs:
2424
- name: Checking_Cpp_compilation
2525
run: |
2626
cd src
27-
echo '{gROOT->LoadMacro("cmsstyle.C++");}' > hola.C
27+
echo '{gROOT->LoadMacro("cmsstyle.C++");}' > compiling.C
2828
2929
dnf install -y root
3030
echo 'ROOT VERSION='`root-config --version`
31-
root -q hola.C
31+
root -q compiling.C
3232
ls -lh cmsstyle_C.so
3333
#
3434
py2-job:

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,53 @@ Python:
99
```python
1010
pip install cmsstyle
1111
```
12+
Once this is done, the ``import cmsstyle`` should work from any location.
1213

1314
C++:
1415
```bash
1516
git clone https://github.com/cms-cat/cmsstyle.git
1617
cd cmsstyle
17-
source scripts/setup_cmstyle
18+
source scripts/setup_cmstyle
1819
```
1920

21+
For the C++ to work from inside ROOT (and any location), it is recommended to
22+
add something like the following to the rootlogon.C macro (or equivalent):
23+
```if (gSystem->Getenv("CMSSTYLE_DIR")!=nullptr) {
24+
std::string var = string(gROOT->GetMacroPath())+":"+gSystem->Getenv("CMSSTYLE_DIR")+"/src";
25+
gROOT->SetMacroPath(var.c_str());
26+
std::cout<<"Adding the ${CMSSTYLE_DIR}/src to the macro path"<<std::endl;
27+
}
28+
```
29+
In fact a similar configuration may be achieved by modifying the ``${HOME}/.rootrc`` instead.
30+
31+
## Installation inside the CMSSW
32+
33+
If you use a CMSSW that supports the _scram-venv_ you may use that to achieve
34+
the installation of the python package with pip already locally, as described
35+
in [this page](http://cms-sw.github.io/venv.html) using the following instructions:
36+
```scram-venv
37+
cmsenv
38+
39+
pip install cmstyle
40+
```
41+
42+
It should be remarked that after installation of the _venv_ (done by
43+
_scram-venv_) that step is no longer needed, but the working directory should
44+
be used always in the virtual enviroment (that should be already setup when
45+
doing the commonly required _cmsenv_ command.
46+
47+
Remark that if you have a local installacion of cmsstyle, it may collide with
48+
the virtual environment, so you may want to do
49+
```export PYTHONNOUSERSITE=True
50+
```
51+
to prevent the conflicts.
52+
53+
In the case of the C++ code, it is possible to add the code as source code but
54+
downloading the packages as mentioned above. Keep in mind that the repository
55+
does not follows the required structure for CMSSW packages, so you may
56+
encounter difficulties to integrate. _Do not hesitate to contact us for the use
57+
case_.
58+
2059
## Documentation
2160

2261
Documentation for the Python implementation is available at [cmsstyle.readthedocs.io](https://cmsstyle.readthedocs.io/). C++ implementation is analogous.

scripts/check_integrity.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
#
3+
# This bash macro allows to perform some integrity checks, similar to the
4+
# workflows that are run at the GitHub server, but that can be run locally.
5+
#
6+
# Written by O. Gonzalez (2025_03_11)
7+
#
8+
9+
# It should be run from the top of the package/release
10+
11+
if [ ! -d src ] ; then
12+
echo "ERROR: Run this scripts from the head of the local release"
13+
exit 10
14+
fi
15+
#
16+
# First: We are running on a EL9 container some check given by the following
17+
# code:
18+
#
19+
cat <<EOF > tmp$$_integrity_el9.sh
20+
echo
21+
echo "Starting check inside container!"
22+
stat -c %U /root
23+
pwd
24+
# Trying to compile the python version
25+
python3 -V
26+
\rm -rf src/cmsstyle/__pycache__ &> /dev/null
27+
python3 -m py_compile src/cmsstyle/cmsstyle.py
28+
ls -lh src/cmsstyle/__pycache__/
29+
\rm -rf src/cmsstyle/__pycache__ &> /dev/null
30+
31+
# Trying to compile for ROOT
32+
echo 'ROOT VERSION='`root-config --version`
33+
cd src
34+
echo '{gROOT->LoadMacro("cmsstyle.C++");}' > /tmp/compiling.C
35+
root -q /tmp/compiling.C
36+
ls -lh cmsstyle_C.so
37+
\rm -rf cmsstyle_C* &> /dev/null
38+
cd ..
39+
echo
40+
EOF
41+
chmod a+x tmp$$_integrity_el9.sh
42+
43+
# Running in a container
44+
apptainer exec -B /cvmfs /cvmfs/unpacked.cern.ch/registry.hub.docker.com/rootproject/root:6.32.00 ./tmp$$_integrity_el9.sh
45+
\rm -rf tmp$$_integrity_el9.sh &> /dev/null
46+
#
47+
# We also try to compile in python2.7:
48+
#
49+
cat <<EOF > tmp$$_integrity_cc7.sh
50+
echo
51+
echo "Running in a CC7 container for python 2.7"
52+
python -V
53+
\rm -rf src/cmsstyle/cmsstyle.pyc &> /dev/null
54+
python -m py_compile src/cmsstyle/cmsstyle.py
55+
ls -lh src/cmsstyle/cmsstyle.pyc
56+
\rm -rf src/cmsstyle/cmsstyle.pyc &> /dev/null
57+
echo
58+
EOF
59+
chmod a+x tmp$$_integrity_cc7.sh
60+
# Running in a container
61+
apptainer exec -B /cvmfs /cvmfs/unpacked.cern.ch/gitlab-registry.cern.ch/cms-cloud/cmssw-docker/cc7-cms:latest ./tmp$$_integrity_cc7.sh
62+
63+
\rm -rf tmp$$_integrity_cc7.sh &> /dev/null
64+
#

0 commit comments

Comments
 (0)