Merge pull request #35 from RossGammon/8047-resourcepath
8047 - Add new --resourcepath option to setup.py
This commit is contained in:
parent
fde34bb53b
commit
e7ab8b322b
6
INSTALL
6
INSTALL
@ -98,3 +98,9 @@ There is a MANIFEST.in file to indicate the work needed.
|
|||||||
To create a source distribution run:
|
To create a source distribution run:
|
||||||
|
|
||||||
python setup.py sdist
|
python setup.py sdist
|
||||||
|
|
||||||
|
If Gramps is built outside of the source tree in a temporary location (e.g. when
|
||||||
|
packaging for a distribution), the --resourcepath option can be used to specify
|
||||||
|
the path to the installed location of the Gramps resources (e.g. /usr/share):
|
||||||
|
|
||||||
|
python setup.py install --resourcepath=/usr/share
|
||||||
|
19
setup.py
19
setup.py
@ -45,6 +45,7 @@ from stat import ST_MODE
|
|||||||
import io
|
import io
|
||||||
from gramps.version import VERSION
|
from gramps.version import VERSION
|
||||||
import unittest
|
import unittest
|
||||||
|
import argparse
|
||||||
|
|
||||||
# this list MUST be a subset of _LOCALE_NAMES in gen/utils/grampslocale.py
|
# this list MUST be a subset of _LOCALE_NAMES in gen/utils/grampslocale.py
|
||||||
# (that is, if you add a new language here, be sure it's in _LOCALE_NAMES too)
|
# (that is, if you add a new language here, be sure it's in _LOCALE_NAMES too)
|
||||||
@ -60,6 +61,19 @@ if '--server' in sys.argv:
|
|||||||
sys.argv.remove('--server')
|
sys.argv.remove('--server')
|
||||||
server = True
|
server = True
|
||||||
|
|
||||||
|
# check if the resourcepath option is used and store the path
|
||||||
|
# this is for packagers that build out of the source tree
|
||||||
|
# other options to setup.py are passed through
|
||||||
|
resource_path = ''
|
||||||
|
packaging = False
|
||||||
|
argparser = argparse.ArgumentParser(add_help=False)
|
||||||
|
argparser.add_argument("--resourcepath", dest="resource_path")
|
||||||
|
args, passthrough = argparser.parse_known_args()
|
||||||
|
if args.resource_path:
|
||||||
|
resource_path = args.resource_path
|
||||||
|
packaging = True
|
||||||
|
sys.argv = [sys.argv[0]] + passthrough
|
||||||
|
|
||||||
def intltool_version():
|
def intltool_version():
|
||||||
'''
|
'''
|
||||||
Return the version of intltool as a tuple.
|
Return the version of intltool as a tuple.
|
||||||
@ -241,7 +255,10 @@ class install(_install):
|
|||||||
'utils', 'resource-path')
|
'utils', 'resource-path')
|
||||||
with io.open(resource_file, 'w', encoding='utf-8',
|
with io.open(resource_file, 'w', encoding='utf-8',
|
||||||
errors='strict') as fp:
|
errors='strict') as fp:
|
||||||
path = os.path.abspath(os.path.join(self.install_data, 'share'))
|
if packaging:
|
||||||
|
path = resource_path
|
||||||
|
else:
|
||||||
|
path = os.path.abspath(os.path.join(self.install_data, 'share'))
|
||||||
fp.write(path)
|
fp.write(path)
|
||||||
|
|
||||||
_install.run(self)
|
_install.run(self)
|
||||||
|
Loading…
Reference in New Issue
Block a user