Commit d00cc3c3 authored by Louis's avatar Louis
Browse files

Écriture d'un paquet Pypi

Résolution partielle de #21
parent 904dae36
Pipeline #61133 failed with stage
in 24 seconds
......@@ -8,9 +8,6 @@
build/
dist/
# Last package manifest used
/MANIFEST.in
# Eclipse files
/.metadata/
/.project
......
......@@ -20,7 +20,7 @@ sys.path.insert(0, os.path.abspath('../../'))
import gettext
gettext.install('pyromaths')
from pyromaths.Values import VERSION, COPYRIGHT_YEAR
from pyromaths.version import VERSION, COPYRIGHT_YEAR
# -- General configuration -----------------------------------------------------
......
include AUTHORS COPYING NEWS README.md
exclude MANIFEST.in
# Documentation
graft Doc/source
include Doc/Makefile
# Données
graft pyromaths/data
......@@ -26,43 +26,6 @@ APP := $(DIST)/Pyromaths.app/Contents
# Project files
FILES := AUTHORS COPYING NEWS pyromaths README setup.py MANIFEST.in src data
### MANIFESTS
#
# Base manifest (README, src/ and test/ auto-included):
MANIFEST := \
include AUTHORS COPYING NEWS \n\
exclude MANIFEST.in \n\
graft data \n
# Minimal install (i.e. without test/ dir):
MANIFEST-min := $(MANIFEST) \
prune test \n
# Full project sources:
MANIFEST-all := $(MANIFEST) \
graft debian \n\
graft utils \n\
graft Doc/source \n\
include Doc/Makefile \n\
include Makefile \n
# Unix:
MANIFEST-unix := $(MANIFEST-min) \
prune data/windows \n\
exclude data/qtmac_fr.qm \n\
exclude data/qtmac_fr.ts \n\
exclude data/images/pyromaths.icns \n\
exclude data/images/pyromaths.ico \n
# Mac app:
MANIFEST-mac := $(MANIFEST-min) \
prune data/linux \n\
prune data/windows \n\
exclude data/images/pyromaths.ico \n\
exclude data/images/pyromaths-banniere.png \n
# Win app:
MANIFEST-win := $(MANIFEST-min) \
prune data/linux \n\
exclude data/qtmac_fr.qm \n\
exclude data/qtmac_fr.ts \n\
exclude data/images/pyromaths.icns \n
### SHORTCUTS & COMPATIBILITY
#
ifeq ($(OS),Windows_NT)
......@@ -85,7 +48,7 @@ setup := $(PYTHON) setup.py
### MACROS
#
# Remove manifest file, egg-info dir and target build dir, clean-up sources.
clean = rm -f MANIFEST.in && rm -rf *.egg-info && rm -rf $(BUILDIR) &&\
clean = rm -rf *.egg-info && rm -rf $(BUILDIR) &&\
find . -name '*~' | xargs rm -f && find . -iname '*.pyc' | xargs rm -f
......@@ -134,26 +97,22 @@ version:
src: version
# Make full-source archive(s) (formats=$(FORMATS))
$(clean)
echo "$(MANIFEST-all)" > MANIFEST.in
$(setup) sdist --formats=$(FORMATS) -d $(DIST) $(OUT)
egg: version
# Make python egg
$(clean)
echo "$(MANIFEST-unix)" > MANIFEST.in
$(setup) bdist_egg -d $(DIST) $(OUT)
rpm: version
# Make RPM package
$(clean)
echo "$(MANIFEST-unix)" > MANIFEST.in
$(setup) bdist --formats=rpm -b $(BUILD) -d $(DIST) $(OUT)
rm $(DIST)/pyromaths-$(VERSION).tar.gz
min: version
# Make minimalist .tar.bz source archive in $(BUILD)
$(clean)
echo "$(MANIFEST-unix)" > MANIFEST.in
$(setup) sdist --formats=bztar -d $(BUILD) $(OUT)
deb: min
......
Metadata-Version: 1.1
Name: pyromaths
Version: 15.02
Summary: Create maths exercises in LaTeX and PDF format
Home-page: http://www.pyromaths.org
Author: Jérôme Ortais
Author-email: jerome.ortais@pyromaths.org
License: GPL
Download-URL: http://pyromaths.org/telecharger/
Description: Pyromaths est un programme qui a pour but de créer des exercices type de mathématiques niveau collège et lycée ainsi que leur corrigé. C'est ce qu'on appelle parfois un exerciseur. Contrairement à de nombreux autres projets, Pyromaths a pour objectif de proposer une correction véritablement détaillée des exercices proposés et pas seulement une solution.
Il permet par exemple de proposer des devoirs maison aux élèves et de leur distribuer ensuite la correction. Il peut aussi servir à des familles afin qu'un élève puisse travailler un point du programme et se corriger ensuite.
Platform: unix
Provides: pyromaths
[Desktop Entry]
Icon=/usr/share/pixmaps/pyromaths.png
Version=1.0
Name=Pyromaths
Comment=Generator for math worksheets for french college
Comment[fr]=Générateur d'exercices de maths
Comment[pl]=Generator zadań matematycznych
Exec=/usr/bin/pyromaths
Terminal=false
Type=Application
Categories=GNOME;Education;
StartupNotify=true
@echo off
REM Cre l'installateur Windows
C:
REM A effectuer la 1re fois, aprs avoir install Python-3.6.5
REM cd "C:\Users\%username%\"
REM C:\Python36-32\python -m venv C:\Users\%username%\BUILD-pyromaths-py3
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade pip
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade lxml
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade PyQt5
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade jinja2
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade markupsafe
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade sip
REM C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade pypiwin32
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\python -m pip install --upgrade pynsist
cd "C:\Users\%username%\BUILD-pyromaths-py3"
copy e:\dist\pyromaths-*.zip . /y /B
"c:\Program Files\7-Zip\7z.exe" x pyromaths-*.zip
del pyromaths-*.zip
cd pyromaths-*
for %%I in (.) do set version=%%~nxI
set version=%version:~10%
copy data\windows\installer.cfg .
C:\Users\%username%\BUILD-pyromaths-py3\Scripts\pynsist.exe installer.cfg
copy build\nsis\pyromaths_%version%.exe e:\dist /Y
cd "C:\Users\%username%\BUILD-pyromaths-py3"
rmdir /Q /S pyromaths-%version%
\ No newline at end of file
[Application]
name=Pyromaths
version=18.6.2
# How to launch the app - this calls the 'main' function from the 'myapp' package:
entry_point=pyromaths.qt.__main__:main
icon=data/images/pyromaths.ico
license_file=COPYING
publisher=pyromaths.org
#console=True
[Python]
version=3.6.5
[Include]
# Packages from PyPI that your application requires, one per line
# These must have wheels on PyPI:
#pypi_wheels = markupsafe==1.0
# MarkupSafe==1.0
# jinja2==2.10
# lxml==4.2.3
# PyQt5==5.10.1
# sip==4.19.8
Packages = pyromaths
jinja2
lxml
markupsafe
PyQt5
#sip
# Other files and folders that should be installed
files = data/
#README
#AUTHORS
#COPYING
#NEWS
exclude = data/linux
data/qtmac_fr.qm
data/qtmac_fr.ts
pkgs/lxml/objectify.cp36-win32.pyd
pkgs/lxml/html
pkgs/lxml/includes
pkgs/lxml/usedoctest.py
pkgs/lxml/sax.py
pkgs/lxml/__init__.py
pkgs/lxml/doctestcompare.py
pkgs/lxml/builder.py
pkgs/lxml/cssselect.py
pkgs/lxml/isoschematron
pkgs/lxml/pyclasslookup.py
pkgs/lxml/ElementInclude.py
pkgs/lxml/builder.cp36-win32.pyd
pkgs/PyQt5/__pycache__/pylupdate_main.cpython-36.pyc
pkgs/PyQt5/__pycache__/pyrcc_main.cpython-36.pyc
pkgs/PyQt5/__pycache__/__init__.cpython-36.pyc
pkgs/PyQt5/pylupdate.pyd
pkgs/PyQt5/QtDBus.pyd
pkgs/PyQt5/QtPositioning.pyd
pkgs/PyQt5/Qt/translations
pkgs/PyQt5/Qt/bin/Qt5Test.dll
pkgs/PyQt5/Qt/bin/Qt5Help.dll
pkgs/PyQt5/Qt/bin/Qt5QuickParticles.dll
pkgs/PyQt5/Qt/bin/ssleay32.dll
pkgs/PyQt5/Qt/bin/libeay32.dll
pkgs/PyQt5/Qt/bin/Qt5DBus.dll
pkgs/PyQt5/Qt/bin/Qt5OpenGL.dll
pkgs/PyQt5/Qt/bin/concrt140.dll
pkgs/PyQt5/Qt/bin/libEGL.dll
pkgs/PyQt5/Qt/bin/Qt5Sensors.dll
pkgs/PyQt5/Qt/bin/Qt5Multimedia.dll
pkgs/PyQt5/Qt/bin/opengl32sw.dll
pkgs/PyQt5/Qt/bin/Qt5Positioning.dll
pkgs/PyQt5/Qt/bin/Qt5WebSockets.dll
pkgs/PyQt5/Qt/bin/Qt5PrintSupport.dll
pkgs/PyQt5/Qt/bin/Qt5Network.dll
pkgs/PyQt5/Qt/bin/Qt5SerialPort.dll
pkgs/PyQt5/Qt/bin/Qt5QuickControls2.dll
pkgs/PyQt5/Qt/bin/Qt5WebChannel.dll
pkgs/PyQt5/Qt/bin/Qt5MultimediaWidgets.dll
pkgs/PyQt5/Qt/bin/Qt5WinExtras.dll
pkgs/PyQt5/Qt/bin/Qt5NetworkAuth.dll
pkgs/PyQt5/Qt/bin/Qt5Designer.dll
pkgs/PyQt5/Qt/bin/Qt5QuickTemplates2.dll
pkgs/PyQt5/Qt/bin/Qt5XmlPatterns.dll
pkgs/PyQt5/Qt/bin/Qt5Bluetooth.dll
pkgs/PyQt5/Qt/bin/Qt5Quick.dll
pkgs/PyQt5/Qt/bin/d3dcompiler_47.dll
pkgs/PyQt5/Qt/bin/vcruntime140.dll
pkgs/PyQt5/Qt/bin/Qt5QuickWidgets.dll
pkgs/PyQt5/Qt/bin/Qt5Sql.dll
pkgs/PyQt5/Qt/bin/Qt5Nfc.dll
pkgs/PyQt5/Qt/bin/Qt5Location.dll
pkgs/PyQt5/Qt/bin/Qt5Xml.dll
pkgs/PyQt5/Qt/bin/Qt5Qml.dll
pkgs/PyQt5/Qt/bin/libGLESv2.dll
pkgs/PyQt5/Qt/bin/Qt5Svg.dll
pkgs/PyQt5/Qt/bin/Qt5QuickTest.dll
pkgs/PyQt5/Qt/qml
pkgs/PyQt5/Qt/plugins/position
pkgs/PyQt5/Qt/plugins/playlistformats
pkgs/PyQt5/Qt/plugins/mediaservice
pkgs/PyQt5/Qt/plugins/imageformats
pkgs/PyQt5/Qt/plugins/styles
pkgs/PyQt5/Qt/plugins/platforms/qwebgl.dll
pkgs/PyQt5/Qt/plugins/platforms/qoffscreen.dll
pkgs/PyQt5/Qt/plugins/geometryloaders
pkgs/PyQt5/Qt/plugins/geoservices
pkgs/PyQt5/Qt/plugins/texttospeech
pkgs/PyQt5/Qt/plugins/iconengines
pkgs/PyQt5/Qt/plugins/sqldrivers
pkgs/PyQt5/Qt/plugins/bearer
pkgs/PyQt5/Qt/plugins/generic
pkgs/PyQt5/Qt/plugins/sensorgestures
pkgs/PyQt5/Qt/plugins/platformthemes
pkgs/PyQt5/Qt/plugins/printsupport
pkgs/PyQt5/Qt/plugins/audio
pkgs/PyQt5/Qt/plugins/sceneparsers
pkgs/PyQt5/Qt/plugins/sensors
pkgs/PyQt5/pyrcc.pyd
pkgs/PyQt5/QtPrintSupport.pyd
pkgs/PyQt5/QtTest.pyd
pkgs/PyQt5/QtSerialPort.pyd
pkgs/PyQt5/QtNetwork.pyd
pkgs/PyQt5/pyrcc_main.py
pkgs/PyQt5/QtOpenGL.pyd
pkgs/PyQt5/QtNetworkAuth.pyd
pkgs/PyQt5/QtLocation.pyd
pkgs/PyQt5/QtMultimediaWidgets.pyd
pkgs/PyQt5/QtSvg.pyd
pkgs/PyQt5/uic
pkgs/PyQt5/pylupdate_main.py
pkgs/PyQt5/QtBluetooth.pyd
pkgs/PyQt5/QtQml.pyd
pkgs/PyQt5/QtDesigner.pyd
pkgs/PyQt5/_QOpenGLFunctions_2_0.pyd
pkgs/PyQt5/QtSql.pyd
pkgs/PyQt5/QtHelp.pyd
pkgs/PyQt5/QtWinExtras.pyd
pkgs/PyQt5/QtWebSockets.pyd
pkgs/PyQt5/QtQuick.pyd
pkgs/PyQt5/QtXmlPatterns.pyd
pkgs/PyQt5/QtXml.pyd
pkgs/PyQt5/QtSensors.pyd
pkgs/PyQt5/QtWebChannel.pyd
pkgs/PyQt5/QtMultimedia.pyd
pkgs/PyQt5/_QOpenGLFunctions_4_1_Core.pyd
pkgs/PyQt5/QAxContainer.pyd
pkgs/PyQt5/_QOpenGLFunctions_2_1.pyd
pkgs/PyQt5/QtQuickWidgets.pyd
pkgs/PyQt5/QtNfc.pyd
[Build]
nsi_template = data/windows/nsi_template.nsi
!define PRODUCT_NAME "[[ib.appname]]"
!define PRODUCT_VERSION "[[ib.version]]"
!define PY_VERSION "[[ib.py_version]]"
!define PY_MAJOR_VERSION "[[ib.py_major_version]]"
!define BITNESS "[[ib.py_bitness]]"
!define ARCH_TAG "[[arch_tag]]"
!define INSTALLER_NAME "[[ib.installer_name]]"
!define PRODUCT_ICON "[[icon]]"
; Marker file to tell the uninstaller that it's a user installation
!define USER_INSTALL_MARKER _user_install_marker
SetCompressor /SOLID lzma
SetCompressorDictSize 32
!define MULTIUSER_EXECUTIONLEVEL Highest
!define MULTIUSER_INSTALLMODE_DEFAULT_CURRENTUSER
!define MULTIUSER_MUI
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!define MULTIUSER_INSTALLMODE_INSTDIR "[[ib.appname]]"
[% if ib.py_bitness == 64 %]
!define MULTIUSER_INSTALLMODE_FUNCTION correct_prog_files
[% endif %]
!include MultiUser.nsh
[% block modernui %]
; Modern UI installer stuff
!include "MUI2.nsh"
!define MUI_ABORTWARNING
!define MUI_ICON "[[icon]]"
!define MUI_UNICON "[[icon]]"
; UI pages
[% block ui_pages %]
!insertmacro MUI_PAGE_WELCOME
[% if license_file %]
!insertmacro MUI_PAGE_LICENSE [[license_file]]
[% endif %]
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
[% endblock ui_pages %]
!insertmacro MUI_LANGUAGE "English"
[% endblock modernui %]
Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "${INSTALLER_NAME}"
ShowInstDetails show
Section -SETTINGS
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
SectionEnd
[% block sections %]
Section "!${PRODUCT_NAME}" sec_app
SetRegView [[ib.py_bitness]]
SectionIn RO
File ${PRODUCT_ICON}
SetOutPath "$INSTDIR\pkgs"
File /r "pkgs\*.*"
SetOutPath "$INSTDIR"
; Marker file for per-user install
StrCmp $MultiUser.InstallMode CurrentUser 0 +3
FileOpen $0 "$INSTDIR\${USER_INSTALL_MARKER}" w
FileClose $0
SetFileAttributes "$INSTDIR\${USER_INSTALL_MARKER}" HIDDEN
[% block install_files %]
; Install files
[% for destination, group in grouped_files %]
SetOutPath "[[destination]]"
[% for file in group %]
File "[[ file ]]"
[% endfor %]
[% endfor %]
; Install directories
[% for dir, destination in ib.install_dirs %]
SetOutPath "[[ pjoin(destination, dir) ]]"
File /r "[[dir]]\*.*"
[% endfor %]
[% endblock install_files %]
[% block install_shortcuts %]
; Install shortcuts
; The output path becomes the working directory for shortcuts
SetOutPath "%HOMEDRIVE%\%HOMEPATH%"
[% if single_shortcut %]
[% for scname, sc in ib.shortcuts.items() %]
CreateShortCut "$SMPROGRAMS\[[scname]].lnk" "[[sc['target'] ]]" \
'[[ sc['parameters'] ]]' "$INSTDIR\[[ sc['icon'] ]]"
[% endfor %]
[% else %]
[# Multiple shortcuts: create a directory for them #]
CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
[% for scname, sc in ib.shortcuts.items() %]
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\[[scname]].lnk" "[[sc['target'] ]]" \
'[[ sc['parameters'] ]]' "$INSTDIR\[[ sc['icon'] ]]"
[% endfor %]
[% endif %]
SetOutPath "$INSTDIR"
[% endblock install_shortcuts %]
[% block install_commands %]
[% if has_commands %]
nsExec::ExecToLog '[[ python ]] -Es "$INSTDIR\_rewrite_shebangs.py" "$INSTDIR\bin"'
nsExec::ExecToLog '[[ python ]] -Es "$INSTDIR\_system_path.py" add "$INSTDIR\bin"'
[% endif %]
[% endblock install_commands %]
; Byte-compile Python files.
DetailPrint "Byte-compiling Python modules..."
nsExec::ExecToLog '[[ python ]] -m compileall -q "$INSTDIR\pkgs"'
WriteUninstaller $INSTDIR\uninstall.exe
; Add ourselves to Add/remove programs
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"DisplayName" "${PRODUCT_NAME}"
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"InstallLocation" "$INSTDIR"
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"DisplayIcon" "$INSTDIR\${PRODUCT_ICON}"
[% if ib.publisher is not none %]
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"Publisher" "[[ib.publisher]]"
[% endif %]
WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"DisplayVersion" "${PRODUCT_VERSION}"
WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"NoModify" 1
WriteRegDWORD SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}" \
"NoRepair" 1
; Check if we need to reboot
IfRebootFlag 0 noreboot
MessageBox MB_YESNO "A reboot is required to finish the installation. Do you wish to reboot now?" \
/SD IDNO IDNO noreboot
Reboot
noreboot:
SectionEnd
Section "Uninstall"
SetRegView [[ib.py_bitness]]
SetShellVarContext all
IfFileExists "$INSTDIR\${USER_INSTALL_MARKER}" 0 +3
SetShellVarContext current
Delete "$INSTDIR\${USER_INSTALL_MARKER}"
Delete $INSTDIR\uninstall.exe
Delete "$INSTDIR\${PRODUCT_ICON}"
RMDir /r "$INSTDIR\pkgs"
; Remove ourselves from %PATH%
[% block uninstall_commands %]
[% if has_commands %]
nsExec::ExecToLog '[[ python ]] -Es "$INSTDIR\_system_path.py" remove "$INSTDIR\bin"'
[% endif %]
[% endblock uninstall_commands %]
[% block uninstall_files %]
; Uninstall files
[% for file, destination in ib.install_files %]
Delete "[[pjoin(destination, file)]]"
[% endfor %]
; Uninstall directories
[% for dir, destination in ib.install_dirs %]
RMDir /r "[[pjoin(destination, dir)]]"
[% endfor %]
[% endblock uninstall_files %]
[% block uninstall_shortcuts %]
; Uninstall shortcuts
[% if single_shortcut %]
[% for scname in ib.shortcuts %]
Delete "$SMPROGRAMS\[[scname]].lnk"
[% endfor %]
[% else %]
RMDir /r "$SMPROGRAMS\${PRODUCT_NAME}"
[% endif %]
[% endblock uninstall_shortcuts %]
RMDir $INSTDIR
DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
SectionEnd
[% endblock sections %]
; Functions
Function .onMouseOverSection
; Find which section the mouse is over, and set the corresponding description.
FindWindow $R0 "#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1043 ; description item (must be added to the UI)
[% block mouseover_messages %]
StrCmp $0 ${sec_app} "" +2
SendMessage $R0 ${WM_SETTEXT} 0 "STR:${PRODUCT_NAME}"
[% endblock mouseover_messages %]
FunctionEnd
Function .onInit
!insertmacro MULTIUSER_INIT
FunctionEnd
Function un.onInit
!insertmacro MULTIUSER_UNINIT
FunctionEnd
[% if ib.py_bitness == 64 %]
Function correct_prog_files
; The multiuser machinery doesn't know about the different Program files
; folder for 64-bit applications. Override the install dir it set.
StrCmp $MultiUser.InstallMode AllUsers 0 +2
StrCpy $INSTDIR "$PROGRAMFILES64\${MULTIUSER_INSTALLMODE_INSTDIR}"
FunctionEnd
[% endif %]
#! /usr/bin/env python3
from time import strftime
import operator
from os.path import normpath, dirname, exists, abspath, join
from os import environ, name
from sys import executable, getfilesystemencoding
import sys
# import pkgutil, types
from . import ex
def we_are_frozen():
"""Returns whether we are frozen via py2exe.
This will affect how we find out where we are located."""
return hasattr(sys, "frozen")
def data_dir():
"""Renvoie le dossier data, selon qu'on utilise pyromaths à partir des
sources, de l'exécutable win32 ou du paquet deb"""
if we_are_frozen():
if sys.platform == 'win32':
path = 'data'
elif sys.platform == 'darwin':
path = '../Resources/data'
return join(normpath(dirname(str(executable,
getfilesystemencoding()))), path)
# We're alive
# Are we running from the sources?
data = join(abspath(dirname(__file__)), '..' , 'data')
if exists(data): return normpath(data)
# Are we running from the pynsist win32 version?
data = join(abspath(dirname(__file__)), '..' , '..', 'data')
if exists(data): return normpath(data)
# Are we running from an egg?
data = join(abspath(dirname(__file__)), '..', 'share', 'pyromaths')
if exists(data): return normpath(data)
# Assume we're installed system-wide
return '/usr/share/pyromaths/'
def icon_dir():
"""Renvoie le dossier où se trouve l'icône, selon qu'on utilise pyromaths à
partir des sources, de l'exécutable win32 ou du paquet deb"""
if we_are_frozen() or exists(join(abspath(dirname(__file__)), '../data/')):
return join(DATADIR, 'images', 'pyromaths.png')
return join('/usr/share/pixmaps', 'pyromaths.png')
if name == 'nt':
def home():
return environ['USERPROFILE']
def configdir():
return join(environ['APPDATA'], "pyromaths")
elif sys.platform == "darwin": # Cas de Mac OS X.
def home():
return environ['HOME']
def configdir():
return join(home(), "Library", "Application Support", "Pyromaths")
else:
def home():
try:
return environ['HOME']
except KeyError:
# Pyromaths en ligne, l'user apache n'a pas de $HOME
return ""
def configdir():
return join(home(), ".config", "pyromaths")
VERSION = '18.6.2'
COPYRIGHT_YEAR = strftime('%Y')
COPYRIGHTS = (u'© 2006 – %s Jérôme Ortais<br/>\n' \
u'<span style=" font-size:small;">Pyromaths est distribué sous ' \
u'licence GPL.</span>') % (COPYRIGHT_YEAR)
WEBSITE = 'http://www.pyromaths.org/'
DATADIR = data_dir()
ICONDIR = icon_dir()
HOME = home()
CONFIGDIR = configdir()
def lesfiches():
"""Charge et renvoie les fiches d'exercices"""
# TODO Deprecated: Supprimer cette fonction (toujours utilisée par le client Django ?). Utiliser la classe ExerciseBag à la place.
fiches = []