Skip to content
This repository has been archived by the owner on Jan 31, 2022. It is now read-only.

Updates to packaging #108

Merged
merged 6 commits into from
Jun 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ default:
.PHONY: clean preprpm
_rpmprep: preprpm
preprpm: default
@cp -rf config/scriptlets/installrpm.sh pkg/
@if ! [ -e pkg/installrpm.sh ]; then \
cp -rf config/scriptlets/installrpm.sh pkg/; \
fi
$(MakeDir) $(ScriptDir)
@cp -rf anaUltra*.py $(ScriptDir)
@cp -rf anaSBit*.py $(ScriptDir)
@cp -rf anaXDAQ*.py $(ScriptDir)
@cp -rf ana_scans.py $(ScriptDir)
@cp -rf anaXDAQLatency.py $(ScriptDir)
@cp -rf packageFiles4Docker.py $(ScriptDir)
-cp -rf README.md LICENSE CHANGELOG.md MANIFEST.in requirements.txt $(PackageDir)
-cp -rf README.md LICENSE CHANGELOG.md MANIFEST.in requirements.txt pkg

Expand All @@ -65,7 +68,6 @@ clean:
-rm -f pkg/MANIFEST.in
-rm -f pkg/CHANGELOG.md
-rm -f pkg/requirements.txt
-rm -f pkg/installrpm.sh

print-env:
@echo BUILD_HOME $(BUILD_HOME)
Expand Down
10 changes: 5 additions & 5 deletions anautilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def getDirByAnaType(anaType, cName, ztrim=4):
pass

# Check Paths
from gempython.utils.wrappers import envCheck
from ..utils.wrappers import envCheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably my ignorance here but I don't really follow what this (change to line 69) does; or the motivation for it?

I guess it's related to the discussion:

Update imports syntax in anautilities

Update to anautilities has not been, but is a semantic change only, a proof-of-principle of proper relative imports that will be extended to other package specific modules (where appropriate, e.g., not in tools that utilize a main).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

anautilities.py lives in gempython/gemplotting/
It wants to import from wrappers.py which lives in gempython/utils
Because anautilities.py will never be called standalone (no __main__), it is a "part of the package", so it should reference all imports from the gempython namespace relatively (wrt where it lives) so it imports from ..utils.wrappers (i.e., look in the package structure in the directory above where I am for utils/wrappers.py)
This type of import should (and can) only be done as deep as the package itself is (don't import .....somewhere.outside.of.gempython), and must not be done for anything that will be called either as a standalone, lives-on-the-PATH executable, nor for a module with a __main__ (executable via python -m <modulename>, as those pieces are not a "part" of the package in the same sense (and can be located outside of the package itself)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah so the import ..some.package

Is like calling cd ... I understand.

envCheck('DATA_PATH')
dataPath = os.getenv('DATA_PATH')

Expand Down Expand Up @@ -125,7 +125,7 @@ def getMapping(mappingFileName):
channel - the channel on the ASIC
PanPin - the pin number on the panasonic connector
"""
from gempython.utils.nesteddict import nesteddict
from ..utils.nesteddict import nesteddict

from anaInfo import mappingNames
import ROOT as r
Expand Down Expand Up @@ -301,7 +301,7 @@ def make3x8Canvas(name, initialContent = None, initialDrawOpt = '', secondaryCon
"""

import ROOT as r
from gempython.gemplotting.mapping.chamberInfo import chamber_vfatPos2PadIdx
from ..mapping.chamberInfo import chamber_vfatPos2PadIdx

if canv is None:
canv = r.TCanvas(name,name,500*8,500*3)
Expand Down Expand Up @@ -332,7 +332,7 @@ def makeListOfScanDatesFile(chamberName, anaType, startDate=None, endDate=None,
delim - delimiter to use in output file name
"""

from gempython.utils.wrappers import envCheck, runCommand
from ..utils.wrappers import envCheck, runCommand
envCheck('DATA_PATH')

import datetime
Expand Down Expand Up @@ -559,7 +559,7 @@ def saveSummary(dictSummary, dictSummaryPanPin2=None, name='Summary', trimPt=Non
"""

import ROOT as r
from gempython.gemplotting.mapping.chamberInfo import chamber_vfatPos2PadIdx
from ..mapping.chamberInfo import chamber_vfatPos2PadIdx

legend = r.TLegend(0.75,0.7,0.88,0.88)
r.gStyle.SetOptStat(0)
Expand Down
2 changes: 1 addition & 1 deletion config
Submodule config updated 3 files
+27 −5 mfPythonRPM.mk
+155 −0 mfSphinx.mk
+20 −0 mfZynq.mk
30 changes: 30 additions & 0 deletions pkg/installrpm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# default action
python setup.py install --single-version-externally-managed -O1 --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES

# install 'scripts' to /opt/cmsgemos/bin
mkdir -p %{buildroot}/opt/cmsgemos/bin
cp -rfp gempython/scripts/*.py %{buildroot}/opt/cmsgemos/bin/

# remove the namespace gempython __init__.pyc[o] files from the RPM
find %{buildroot} -wholename "*gempython/__init__.py" -delete
find %{buildroot} -wholename "*gempython/__init__.pyo" -delete
find %{buildroot} -wholename "*gempython/__init__.pyc" -delete
find %{buildroot} -wholename '*site-packages/gempython/__init__.py' -delete
find %{buildroot} -wholename '*site-packages/gempython/__init__.pyc' -delete
find %{buildroot} -wholename '*site-packages/gempython/__init__.pyo' -delete
find %{buildroot} -wholename '*site-packages/gempython/gemplotting/macros/*.py' -print0 -exec chmod a+x {} \;
find %{buildroot} -type f -exec chmod a+r {} \;
find %{buildroot} -type f -iname '*.cfg' -exec chmod a-x {} \;

cp INSTALLED_FILES INSTALLED_FILES.backup
cat INSTALLED_FILES.backup|egrep -v 'gempython/__init__.py*' > INSTALLED_FILES
# set permissions
cat <<EOF >>INSTALLED_FILES
%attr(0755,root,root) /opt/cmsgemos/bin/*.py
%attr(0755,root,root) /usr/lib/python*/site-packages/gempython/scripts/*.py
%attr(0755,root,root) /usr/lib/python*/site-packages/gempython/gemplotting/macros/*.py
EOF
echo "Modified INSTALLED_FILES"
cat INSTALLED_FILES
3 changes: 3 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
importlib
setuptools>25,<=38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used setuptools<38 to get make rpm to work with Python 2.6 (see here). It wasn't working with <39.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know which version got pulled in?

pip>8,<10.1