-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #173 from SylvainCorlay/pythonhome-dynamic
Setup python home dynamically
- Loading branch information
Showing
11 changed files
with
185 additions
and
64 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
This file was deleted.
Oops, something went wrong.
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,96 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2018, Martin Renou, Johan Mabille, Sylvain Corlay and * | ||
* Wolf Vollprecht * | ||
* * | ||
* Distributed under the terms of the BSD 3-Clause License. * | ||
* * | ||
* The full license is in the file LICENSE, distributed with this software. * | ||
****************************************************************************/ | ||
|
||
#include "xpaths.hpp" | ||
|
||
#include <string> | ||
#include <cstring> | ||
|
||
#if defined(__linux__) | ||
# include <unistd.h> | ||
#endif | ||
#if defined(_WIN32) | ||
# if defined(NOMINMAX) | ||
# include <windows.h> | ||
# else | ||
# define NOMINMAX | ||
# include <windows.h> | ||
# undef NOMINMAX | ||
# endif | ||
#endif | ||
#ifdef __APPLE__ | ||
# include <cstdint> | ||
# include <mach-o/dyld.h> | ||
#endif | ||
#if defined(__sun) | ||
# include <stdlib.h> | ||
#endif | ||
|
||
namespace xpyt | ||
{ | ||
std::string executable_path() | ||
{ | ||
std::string path; | ||
char buffer[1024]; | ||
std::memset(buffer, '\0', sizeof(buffer)); | ||
#if defined(__linux__) | ||
if (readlink("/proc/self/exe", buffer, sizeof(buffer)) != -1) | ||
{ | ||
path = buffer; | ||
} | ||
else | ||
{ | ||
// failed to determine run path | ||
} | ||
#elif defined (_WIN32) | ||
if (GetModuleFileName(nullptr, buffer, sizeof(buffer)) != 0) | ||
{ | ||
path = buffer; | ||
} | ||
else | ||
{ | ||
// failed to determine run path | ||
} | ||
#elif defined (__APPLE__) | ||
std::uint32_t size = sizeof(buffer); | ||
if(_NSGetExecutablePath(buffer, &size) == 0) | ||
{ | ||
path = buffer; | ||
} | ||
else | ||
{ | ||
// failed to determine run path | ||
} | ||
#elif defined (__FreeBSD__) | ||
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; | ||
if (sysctl(mib, 4, buffer, sizeof(buffer), NULL, 0) != -1) | ||
{ | ||
path = buffer; | ||
} | ||
else | ||
{ | ||
// failed to determine run path | ||
} | ||
#elif defined(__sun) | ||
path = getexecname(); | ||
#endif | ||
return path; | ||
} | ||
|
||
std::string prefix_path() | ||
{ | ||
std::string path = executable_path(); | ||
#if defined (_WIN32) | ||
char separator = '\\'; | ||
#else | ||
char separator = '/'; | ||
#endif | ||
return path.substr(0, path.find_last_of("/\\")) + separator + ".." + separator; | ||
} | ||
} |
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,29 @@ | ||
/*************************************************************************** | ||
* Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht * | ||
* Copyright (c) QuantStack * | ||
* * | ||
* Distributed under the terms of the BSD 3-Clause License. * | ||
* * | ||
* The full license is in the file LICENSE, distributed with this software. * | ||
****************************************************************************/ | ||
|
||
#ifndef XPYT_PATHS_HPP | ||
#define XPYT_PATHS_HPP | ||
|
||
#include <string> | ||
|
||
namespace xpyt | ||
{ | ||
/******************* | ||
* executable_path * | ||
*******************/ | ||
|
||
std::string executable_path(); | ||
|
||
/******************* | ||
* prefix_path * | ||
*******************/ | ||
|
||
std::string prefix_path(); | ||
} | ||
#endif |
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,18 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2018, Martin Renou, Johan Mabille, Sylvain Corlay and * | ||
* Wolf Vollprecht * | ||
* * | ||
* Distributed under the terms of the BSD 3-Clause License. * | ||
* * | ||
* The full license is in the file LICENSE, distributed with this software. * | ||
****************************************************************************/ | ||
|
||
#ifndef XEUS_PYTHONHOME_HPP | ||
#define XEUS_PYTHONHOME_HPP | ||
|
||
namespace xpyt | ||
{ | ||
void set_pythonhome(); | ||
} | ||
#endif | ||
|
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