Skip to content

Commit 6864d8a

Browse files
committed
Improve handling of various install situations
- Dont initialize git components if repo missing - Update node_modules path for watchers - Correct version generation to use working path - Correct path to README
1 parent 72c300a commit 6864d8a

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131

3232
from distutils import log
3333
from distutils.core import Command
34-
from setuptools.command.install import install
3534
from setuptools.command.develop import develop
35+
from setuptools.command.install import install
3636
from setuptools.command.sdist import sdist
3737
from setuptools import setup, find_packages
3838
from subprocess import check_output
@@ -158,7 +158,7 @@ def _get_package_version(self):
158158
"""
159159
Attempt to get the most correct current version of Sentry.
160160
"""
161-
pkg_path = os.path.join(ROOT, 'src')
161+
pkg_path = os.path.join(self.work_path, 'src')
162162

163163
sys.path.insert(0, pkg_path)
164164
try:
@@ -237,9 +237,10 @@ def run(self):
237237
def _build_static(self):
238238
work_path = self.work_path
239239

240-
log.info("initializing git submodules")
241-
check_output(['git', 'submodule', 'init'], cwd=work_path)
242-
check_output(['git', 'submodule', 'update'], cwd=work_path)
240+
if os.path.exists(os.path.join(work_path, '.git')):
241+
log.info("initializing git submodules")
242+
check_output(['git', 'submodule', 'init'], cwd=work_path)
243+
check_output(['git', 'submodule', 'update'], cwd=work_path)
243244

244245
log.info("running [npm install --quiet]")
245246
check_output(['npm', 'install', '--quiet'], cwd=work_path)
@@ -284,7 +285,7 @@ def run(self):
284285
author_email='[email protected]',
285286
url='https://www.getsentry.com',
286287
description='A realtime logging and aggregation server.',
287-
long_description=open('README.rst').read(),
288+
long_description=open(os.path.join(ROOT, 'README.rst')).read(),
288289
package_dir={'': 'src'},
289290
packages=find_packages('src'),
290291
zip_safe=False,

src/sentry/conf/server.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@
4141

4242
PROJECT_ROOT = os.path.normpath(os.path.join(os.path.dirname(__file__), os.pardir))
4343

44-
NODE_MODULES_ROOT = os.path.join(PROJECT_ROOT, os.pardir, os.pardir, 'node_modules')
44+
# XXX(dcramer): handle case when we've installed from source vs just running
45+
# this straight out of the repository
46+
if 'site-packages' in __file__:
47+
NODE_MODULES_ROOT = os.path.join(PROJECT_ROOT, 'node_modules')
48+
else:
49+
NODE_MODULES_ROOT = os.path.join(PROJECT_ROOT, os.pardir, os.pardir, 'node_modules')
4550

4651
sys.path.insert(0, os.path.normpath(os.path.join(PROJECT_ROOT, os.pardir)))
4752

@@ -908,6 +913,8 @@ def create_partitioned_queues(name):
908913
SENTRY_API_RESPONSE_DELAY = 0
909914

910915
# Watchers for various application purposes (such as compiling static media)
916+
# XXX(dcramer): this doesn't work outside of a source distribution as the
917+
# webpack.config.js is not part of Sentry's datafiles
911918
SENTRY_WATCHERS = (
912919
[os.path.join(NODE_MODULES_ROOT, '.bin', 'webpack'), '-d', '--watch',
913920
"--config={}".format(os.path.join(PROJECT_ROOT, os.pardir, os.pardir, "webpack.config.js"))],

0 commit comments

Comments
 (0)