Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/smc_pyutil/setup.py
Views: 687
# -*- coding: utf-8 -*-12# This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.3# License: MS-RSL – see LICENSE.md for details45###6# To do development on this, install it locally:7# pip install --user --upgrade smc_pyutil/8###910from __future__ import absolute_import11import os12from os.path import join13from setuptools import findall1415path = os.path.dirname(os.path.realpath(__file__))1617TEMPLATES = join("smc_pyutil", "templates")18# CRITICAL: I don't know any other way to ensure the permissions are19# right on the templates than this.20os.system("chmod a+r -R %s" % join(path, TEMPLATES))21# Next, some of the templates don't get copied over during pip install22# unless we explicitly set the data_files (as suggested by chatgpt):23template_files = findall(TEMPLATES)24template_data = [(f.split(TEMPLATES)[1], [f]) for f in template_files]252627def readme():28with open('README.md') as f:29return f.read()303132# from https://github.com/ninjaaron/fast-entry_points/ issue https://github.com/sagemathinc/cocalc/issues/225933import fastentrypoints34from setuptools import setup, find_packages3536# This checks, if setup.py is run with 'install --user'37# in that case we assume it is installed for development and do NOT change the python executable.38# Therefore we want to load the local library via the site.py mechanism.39# (this mimics http://svn.python.org/projects/python/trunk/Lib/distutils/dist.py, called in setup behind the scenes)40from distutils.core import Distribution4142d = Distribution()43d.parse_command_line()4445# CRITICAL!46# Uses a wrapped python executable to not load the user's "site" packages in ~/.local.47# Otherwise, setuptool's startup scripts do not work, if there is a conflicting48# setuptools version in .local/lib/python-packages (or, any other locally installed python lib)49# setting sys.executable changes the she-bang #!... at the top of these scripts50# credits to http://stackoverflow.com/a/1732949351# NOTE: the logic below does not work right now, because the nosite variant is not available52# during the build process. however, maybe there is a way to use the included53# cocalc-python3-clean script at some point in the future ...54python3_nosite = '/usr/local/bin/python3-nosite'55# don't overwrite for local smc-in-smc development56if 'user' not in list(d.command_options.get("install", {}).keys()):57# check, if python3_nosite exists and is executable58if os.path.isfile(python3_nosite) and os.access(python3_nosite, os.X_OK):59import sys60sys.executable = python3_nosite6162# names for console scripts63# history: "smc" was based on the old name "SageMathCloud".64# Then, we switched to "cc" as a shortcut for CoCalc, but it's similar to the C compiler.65# Using "cocalc-*" is easier to discover and remember.6667cs = [68'open = smc_pyutil.smc_open:main',69'close = smc_pyutil.smc_close:main',70]7172for prefix in ['smc', 'cc', 'cocalc']:73add = cs.append74add('%s-sagews2pdf = smc_pyutil.sagews2pdf:main' % prefix)75add('%s-sws2sagews = smc_pyutil.sws2sagews:main' % prefix)76add('%s-open = smc_pyutil.smc_open:main' % prefix)77add('%s-new-file = smc_pyutil.new_file:main' % prefix)78add('%s-status = smc_pyutil.status:main' % prefix)79add('%s-jupyter-no-output= smc_pyutil.jupyter_delete_output:main' % prefix)80add('%s-ipynb2sagews = smc_pyutil.ipynb2sagews:main' % prefix)81add('%s-start = smc_pyutil.start_smc:main' % prefix)82add('%s-stop = smc_pyutil.stop_smc:main' % prefix)83add('%s-html2sagews = smc_pyutil.html2sagews:main' % prefix)84add('%s-sagews2ipynb = smc_pyutil.sagews2ipynb:main' % prefix)8586# only cc and cocalc prefixes87if prefix != 'smc':88add('%s-first-steps = smc_pyutil.first_steps:main' % prefix)89add('%s-ipynb-to-pdf = smc_pyutil.ipynb_to_pdf:main' % prefix)90add('%s-close = smc_pyutil.smc_close:main' % prefix)91add('%s-jupyter-classic-open = smc_pyutil.jupyter_notebook:prepare_file_for_open'92% prefix)9394setup(95name='smc_pyutil',96version='1.2',97description='CoCalc Python Utilities',98long_description=readme(),99url='https://github.com/sagemathinc/cocalc',100author='SageMath, Inc.',101author_email='[email protected]',102license='GPLv3+',103packages=find_packages(),104install_requires=['markdown2', 'psutil', 'PyYAML', 'ansi2html'],105zip_safe=False,106classifiers=[107'License :: OSI Approved :: GPLv3',108'Programming Language :: Python :: 2.7',109'Programming Language :: Python :: 3.5',110'Topic :: Mathematics :: Server',111],112keywords='server mathematics cloud',113scripts=[114'smc_pyutil/bin/smc-sage-server', 'smc_pyutil/bin/cocalc-python3-clean'115],116entry_points={'console_scripts': cs},117include_package_data=True,118package_data={'smc_pyutil': ['smc_pyutil/templates/*']},119data_files=template_data,120)121122123