-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api): Write .env with absolute path for conf on make install
The old checked-in .env had a relative path into tests/ for the development index.json file that drives settings. This makes it impossible to import opentrons from outside the api directory. One way to fix this would be to add correct, sane, and not duplicated logic to the way we load settings; another is to write the .env and the index.json with absolute paths when you run make install. Also, this fixes an issue where ‘make local-install’ worked on appveyor (because appveyor uses mingw make) but doesn’t work on other dev setups that install make using e.g. chocolatey into the windows shell or powershell, which do not do wildcard expansion. Closes #2495
- Loading branch information
Showing
6 changed files
with
71 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
""" Tools to bridge the Makefile and the python build environment | ||
(or provide utilities) | ||
""" | ||
|
||
import argparse | ||
import json | ||
import os | ||
|
||
# Pipenv requires setuptools >= 36.2.1. Since 36.2.1, setuptools changed | ||
# the way they vendor dependencies, like the packaging module that | ||
# provides the way to normalize version numbers for wheel file names. So | ||
# we try all the possible ways to find it. | ||
try: | ||
# new way | ||
from setuptools.extern import packaging | ||
except ImportError: | ||
# old way | ||
from pkg_resources.extern import packaging | ||
|
||
|
||
def normalize_version(): | ||
pkg_json_path = os.path.join('src', 'opentrons', 'package.json') | ||
old_ver = json.load(open(pkg_json_path))['version'] | ||
vers_obj = packaging.version.Version(old_ver) | ||
return str(vers_obj) | ||
|
||
|
||
def write_local_env(): | ||
|
||
here = os.getcwd() | ||
|
||
with open('./.env', 'w') as dotenv: | ||
dotenv.write('OVERRIDE_SETTINGS_DIR={}'.format(here)) | ||
|
||
shared_data = os.path.join(here, os.pardir, 'shared-data') | ||
test_data = os.path.join(here, 'tests', 'opentrons', 'data') | ||
local_index = { | ||
"labware": { | ||
"baseDefinitionDir": os.path.join(shared_data, 'definitions'), | ||
"userDefinitionDir": os.path.join(test_data, 'labware-def', | ||
'definitions'), | ||
"offsetDir": os.path.join(test_data, 'labware-def', 'offsets') | ||
}, | ||
"pipetteConfigFile": os.path.join(shared_data, 'robot-data', | ||
'pipette-config.json'), | ||
"featureFlagFile": os.path.join(shared_data, 'settings.json'), | ||
"deckCalibrationFile": os.path.join(test_data, | ||
'configs', | ||
'deckCalibration.json'), | ||
"robotSettingsFile": os.path.join(test_data, 'configs', | ||
'robotSettings.json') | ||
} | ||
|
||
with open('./index.json', 'w') as index: | ||
index.write(json.dumps(local_index)) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser( | ||
description='Perform one of several build-time tasks') | ||
parser.add_argument(dest='task', metavar='TASK', type=str, | ||
choices=['normalize_version', 'write_local_env']) | ||
args = parser.parse_args() | ||
print(locals()[args.task]()) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.