From 762810121d1bec4dd07fcdf954be6322c5912ba2 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Tue, 11 Jun 2019 22:44:58 +0300 Subject: [PATCH 1/5] fix(yarn): Fix yarn path in distutils --- src/sentry/utils/distutils/commands/base.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/sentry/utils/distutils/commands/base.py b/src/sentry/utils/distutils/commands/base.py index 40ef636d51ad..1cce1b8a597a 100644 --- a/src/sentry/utils/distutils/commands/base.py +++ b/src/sentry/utils/distutils/commands/base.py @@ -1,5 +1,6 @@ from __future__ import absolute_import +import imp import os import os.path import shutil @@ -35,6 +36,9 @@ def initialize_options(self): def get_root_path(self): return os.path.abspath(os.path.dirname(sys.modules['__main__'].__file__)) + def get_sentry_root_path(self): + return os.path.abspath(os.path.dirname(os.path.dirname(imp.find_module('sentry')[1]))) + def get_dist_paths(self): return [] @@ -132,8 +136,10 @@ def _setup_js_deps(self): if node_version[2] is not None: log.info(u'using node ({0}))'.format(node_version)) + yarn_path = os.path.join(self.get_sentry_root_path(), 'bin', 'yarn') + log.info(u'yarn path: ({0}))'.format(yarn_path)) self._run_command( - ['./bin/yarn', 'install', '--production', '--pure-lockfile', '--quiet'] + [yarn_path, 'install', '--production', '--pure-lockfile', '--quiet'] ) def _run_command(self, cmd, env=None): From 9ffa9179355d28baa93079f00a1efad69dff6125 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Tue, 11 Jun 2019 23:07:56 +0300 Subject: [PATCH 2/5] Cover webpack command too --- src/sentry/utils/distutils/commands/base.py | 13 +++++++++---- src/sentry/utils/distutils/commands/build_assets.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/sentry/utils/distutils/commands/base.py b/src/sentry/utils/distutils/commands/base.py index 1cce1b8a597a..15a9c0e04d5b 100644 --- a/src/sentry/utils/distutils/commands/base.py +++ b/src/sentry/utils/distutils/commands/base.py @@ -136,10 +136,8 @@ def _setup_js_deps(self): if node_version[2] is not None: log.info(u'using node ({0}))'.format(node_version)) - yarn_path = os.path.join(self.get_sentry_root_path(), 'bin', 'yarn') - log.info(u'yarn path: ({0}))'.format(yarn_path)) - self._run_command( - [yarn_path, 'install', '--production', '--pure-lockfile', '--quiet'] + self._run_yarn_command( + ['install', '--production', '--pure-lockfile', '--quiet'] ) def _run_command(self, cmd, env=None): @@ -150,6 +148,13 @@ def _run_command(self, cmd, env=None): log.error('command failed [%s] via [%s]' % (' '.join(cmd), self.work_path, )) raise + def _run_yarn_command(self, cmd, env=None): + yarn_path = os.path.join(self.get_sentry_root_path(), 'bin', 'yarn') + log.debug(u'yarn path: ({0}))'.format(yarn_path)) + self._run_command( + [yarn_path].extend(cmd), env=env + ) + def update_manifests(self): # if we were invoked from sdist, we need to inform sdist about # which files we just generated. Otherwise they will be missing diff --git a/src/sentry/utils/distutils/commands/build_assets.py b/src/sentry/utils/distutils/commands/build_assets.py index bc796357c523..896063259c72 100644 --- a/src/sentry/utils/distutils/commands/build_assets.py +++ b/src/sentry/utils/distutils/commands/build_assets.py @@ -135,7 +135,7 @@ def _build_static(self): env = dict(os.environ) env['SENTRY_STATIC_DIST_PATH'] = self.sentry_static_dist_path env['NODE_ENV'] = 'production' - self._run_command(['./bin/yarn', 'webpack', '--bail'], env=env) + self._run_yarn_command(['webpack', '--bail'], env=env) def _write_version_file(self, version_info): manifest = { From 5c2c8a8e234f1142147b71c7c83615a7e990b0c0 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Tue, 11 Jun 2019 23:37:15 +0300 Subject: [PATCH 3/5] learn python --- src/sentry/utils/distutils/commands/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/utils/distutils/commands/base.py b/src/sentry/utils/distutils/commands/base.py index 15a9c0e04d5b..d06be924fecf 100644 --- a/src/sentry/utils/distutils/commands/base.py +++ b/src/sentry/utils/distutils/commands/base.py @@ -152,7 +152,7 @@ def _run_yarn_command(self, cmd, env=None): yarn_path = os.path.join(self.get_sentry_root_path(), 'bin', 'yarn') log.debug(u'yarn path: ({0}))'.format(yarn_path)) self._run_command( - [yarn_path].extend(cmd), env=env + [yarn_path] + cmd, env=env ) def update_manifests(self): From 01945bff0802ca27392b3ad4795a5b650ef2d5a4 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Wed, 12 Jun 2019 00:17:07 +0300 Subject: [PATCH 4/5] Be less hacky, be a pro --- src/sentry/utils/distutils/commands/base.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/sentry/utils/distutils/commands/base.py b/src/sentry/utils/distutils/commands/base.py index d06be924fecf..a51d456a666d 100644 --- a/src/sentry/utils/distutils/commands/base.py +++ b/src/sentry/utils/distutils/commands/base.py @@ -1,6 +1,5 @@ from __future__ import absolute_import -import imp import os import os.path import shutil @@ -10,6 +9,14 @@ from subprocess import check_output from distutils.core import Command +import sentry # We just need its path via __file__ + + +SENTRY_ROOT_PATH = os.path.abspath(os.path.dirname(os.path.dirname(sentry.__file__))) + + +YARN_PATH = os.path.join(SENTRY_ROOT_PATH, 'bin', 'yarn') + class BaseBuildCommand(Command): user_options = [ @@ -36,9 +43,6 @@ def initialize_options(self): def get_root_path(self): return os.path.abspath(os.path.dirname(sys.modules['__main__'].__file__)) - def get_sentry_root_path(self): - return os.path.abspath(os.path.dirname(os.path.dirname(imp.find_module('sentry')[1]))) - def get_dist_paths(self): return [] @@ -149,10 +153,9 @@ def _run_command(self, cmd, env=None): raise def _run_yarn_command(self, cmd, env=None): - yarn_path = os.path.join(self.get_sentry_root_path(), 'bin', 'yarn') - log.debug(u'yarn path: ({0}))'.format(yarn_path)) + log.debug(u'yarn path: ({0}))'.format(YARN_PATH)) self._run_command( - [yarn_path] + cmd, env=env + [YARN_PATH] + cmd, env=env ) def update_manifests(self): From 731dcaa9f72ec6d6b1af46a5c98f6a9db92fb08d Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Wed, 12 Jun 2019 00:40:21 +0300 Subject: [PATCH 5/5] fix paths too --- src/sentry/utils/distutils/commands/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentry/utils/distutils/commands/base.py b/src/sentry/utils/distutils/commands/base.py index a51d456a666d..4c9da2fd6be7 100644 --- a/src/sentry/utils/distutils/commands/base.py +++ b/src/sentry/utils/distutils/commands/base.py @@ -12,7 +12,7 @@ import sentry # We just need its path via __file__ -SENTRY_ROOT_PATH = os.path.abspath(os.path.dirname(os.path.dirname(sentry.__file__))) +SENTRY_ROOT_PATH = os.path.abspath(os.path.join(sentry.__file__, '..', '..', '..')) YARN_PATH = os.path.join(SENTRY_ROOT_PATH, 'bin', 'yarn')