| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d3ef0b5 commit d77cc68
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,16 +1,5 @@ | |||
| 1 | 1 | import sys | |
| 2 | - from os.path import abspath, dirname, exists, join | ||
| 3 | - from glob import glob | ||
| 4 | - | ||
| 5 | - try: | ||
| 6 | - import _plotdevice # make sure the c-extensions are accessible | ||
| 7 | - except ImportError: | ||
| 8 | - setup_py = join(dirname(__file__), '../../setup.py') | ||
| 9 | - if exists(setup_py): | ||
| 10 | - from subprocess import call | ||
| 11 | - # call('{py} {setup} build_ext --inplace'.format(py=sys.executable, setup=setup_py)) | ||
| 12 | - call([sys.executable, setup_py, 'build_ext', '--inplace']) | ||
| 13 | - import _plotdevice | ||
| 2 | + import _plotdevice # make sure the c-extensions are accessible for the submodules | ||
| 14 | 3 | ||
| 15 | 4 | # allow Libraries to request a _ctx reference | |
| 16 | 5 | def register(module): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,6 @@ | |||
| 10 | 10 | from ..util import numlike | |
| 11 | 11 | ||
| 12 | 12 | from plotdevice import DeviceError | |
| 13 | - import _plotdevice | ||
| 14 | 13 | ||
| 15 | 14 | __all__ = ["font_family", "font_encoding", "font_face", "best_face", | |
| 16 | 15 | "family_names", "family_members", "family_name", "standardized", "sanitized", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,4 @@ | |||
| 1 | 1 | import objc, os, re | |
| 2 | - import _plotdevice | ||
| 3 | 2 | ||
| 4 | 3 | for cls in ["AnimatedGif", "Pages", "SysAdmin", "Video"]: | |
| 5 | 4 | globals()[cls] = objc.lookUpClass(cls) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,16 +1,20 @@ | |||
| 1 | 1 | import sys, site | |
| 2 | + import platform | ||
| 2 | 3 | from os.path import abspath, dirname, exists, join | |
| 3 | - from subprocess import call, getoutput | ||
| 4 | + from subprocess import call | ||
| 4 | 5 | ||
| 5 | 6 | try: | |
| 6 | 7 | # test the sys.path by attempting to load a PyObjC submodule... | |
| 7 | 8 | from Foundation import * | |
| 8 | 9 | except ImportError: | |
| 9 | - setup_py = join(dirname(__file__), '../../setup.py') | ||
| 10 | + # detect whether we're being run from the repository and set up a local env if so | ||
| 11 | + repo = abspath(join(dirname(__file__), '../..')) | ||
| 12 | + setup_py = '%s/setup.py' % repo | ||
| 10 | 13 | if exists(setup_py): | |
| 11 | - # if run from the sdist, install pyobjc et al. in a venv at app/deps/local | ||
| 12 | - site_path = getoutput('{py} {setup} -q env'.format(py=sys.executable, setup=setup_py)) | ||
| 13 | - site.addsitedir(site_path) | ||
| 14 | + local_libs = '%s/app/deps/local/%s/libs' % (repo, platform.python_version()) | ||
| 15 | + if not exists(local_libs): | ||
| 16 | + call([sys.executable, setup_py, 'dev']) | ||
| 17 | + site.addsitedir(local_libs) | ||
| 14 | 18 | from Foundation import * | |
| 15 | 19 | else: | |
| 16 | 20 | from pprint import pformat | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -318,7 +318,7 @@ def rsrc_path(resource=None): | |||
| 318 | 318 | rsrc_root = abspath(pth) | |
| 319 | 319 | break | |
| 320 | 320 | else: | |
| 321 | - notfound = "Couldn't locate resources directory (try running `python setup.py build` before running from the source dist)." | ||
| 321 | + notfound = "Couldn't locate resources directory (try running `python setup.py dev` before running from the source dist)." | ||
| 322 | 322 | raise RuntimeError(notfound) | |
| 323 | 323 | if resource: | |
| 324 | 324 | return join(rsrc_root, resource) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -190,20 +190,13 @@ def csv_dialect(fd): | |||
| 190 | 190 | ||
| 191 | 191 | ### HTTP utils ### | |
| 192 | 192 | ||
| 193 | - try: | ||
| 194 | - import requests | ||
| 195 | - from cachecontrol import CacheControl, CacheControlAdapter | ||
| 196 | - from cachecontrol.caches import FileCache | ||
| 197 | - from cachecontrol.heuristics import LastModified | ||
| 198 | - | ||
| 199 | - cache_dir = '%s/Library/Caches/PlotDevice'%os.environ['HOME'] | ||
| 200 | - HTTP = CacheControl(requests.Session(), cache=FileCache(cache_dir), heuristic=LastModified()) | ||
| 201 | - except ImportError: | ||
| 202 | - class Decoy(object): | ||
| 203 | - def get(self, url): | ||
| 204 | - unsupported = 'could not find the "requests" library (try running "python setup.py build" first)' | ||
| 205 | - raise RuntimeError(unsupported) | ||
| 206 | - HTTP = Decoy() | ||
| 193 | + import requests | ||
| 194 | + from cachecontrol import CacheControl, CacheControlAdapter | ||
| 195 | + from cachecontrol.caches import FileCache | ||
| 196 | + from cachecontrol.heuristics import LastModified | ||
| 197 | + | ||
| 198 | + cache_dir = '%s/Library/Caches/PlotDevice'%os.environ['HOME'] | ||
| 199 | + HTTP = CacheControl(requests.Session(), cache=FileCache(cache_dir), heuristic=LastModified()) | ||
| 207 | 200 | ||
| 208 | 201 | def binaryish(content, format): | |
| 209 | 202 | bin_types = ('pdf','eps','png','jpg','jpeg','heic','gif','tiff','tif','zip','tar','gz') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,8 +19,10 @@ | |||
| 19 | 19 | # - cFoundry, cPathmatics, cIO, & PyObjC (included in the "app/deps" folder) | |
| 20 | 20 | # - Sparkle.framework (auto-downloaded only for `dist` builds) | |
| 21 | 21 | ||
| 22 | - import os, sys, json, re | ||
| 22 | + import os, sys, json, re, platform | ||
| 23 | + from glob import glob | ||
| 23 | 24 | from setuptools import setup, find_packages | |
| 25 | + from setuptools.extension import Extension | ||
| 24 | 26 | from distutils.dir_util import remove_tree | |
| 25 | 27 | from distutils.command.build_py import build_py | |
| 26 | 28 | from pkg_resources import DistributionNotFound | |
@@ -47,10 +49,8 @@ | |||
| 47 | 49 | "Intended Audience :: End Users/Desktop", | |
| 48 | 50 | "License :: OSI Approved :: MIT License", | |
| 49 | 51 | "Operating System :: MacOS :: MacOS X", | |
| 50 | - "Programming Language :: Python :: 2", | ||
| 51 | - "Programming Language :: Python :: 2.7", | ||
| 52 | 52 | "Programming Language :: Python :: 3", | |
| 53 | - "Programming Language :: Python :: 3.4", | ||
| 53 | + "Programming Language :: Python :: 3.8", | ||
| 54 | 54 | "Topic :: Artistic Software", | |
| 55 | 55 | "Topic :: Multimedia :: Graphics", | |
| 56 | 56 | "Topic :: Multimedia :: Graphics :: Editors :: Vector-Based", | |
@@ -96,12 +96,10 @@ | |||
| 96 | 96 | ||
| 97 | 97 | Requirements: | |
| 98 | 98 | ||
| 99 | - * Mac OS X 10.9+ | ||
| 100 | - * Python 2.7 or 3.4+ | ||
| 101 | - * the requests, cachecontrol, and lockfile modules | ||
| 99 | + * Mac OS X 11+ | ||
| 100 | + * Python 3.8+ | ||
| 102 | 101 | """ | |
| 103 | 102 | ||
| 104 | - | ||
| 105 | 103 | ## Basic Utils ## | |
| 106 | 104 | ||
| 107 | 105 | # the sparkle updater framework will be fetched as needed | |
@@ -162,41 +160,48 @@ def stale(dst, src): | |||
| 162 | 160 | ||
| 163 | 161 | from distutils.core import Command | |
| 164 | 162 | class CleanCommand(Command): | |
| 165 | - description = "wipe out the ./build ./dist and app/deps/.../build dirs" | ||
| 163 | + description = "wipe out the ./build ./dist and app/deps/local dirs" | ||
| 166 | 164 | user_options = [] | |
| 167 | 165 | def initialize_options(self): | |
| 168 | 166 | pass | |
| 169 | 167 | def finalize_options(self): | |
| 170 | 168 | pass | |
| 171 | 169 | def run(self): | |
| 172 | 170 | os.system('rm -rf ./build ./dist') | |
| 173 | - os.system('rm -rf ./app/deps/*/build') | ||
| 171 | + os.system('rm -rf ./app/deps/local') | ||
| 174 | 172 | os.system('rm -rf plotdevice.egg-info MANIFEST.in PKG') | |
| 175 | 173 | os.system('rm -rf ./tests/_out ./tests/_diff ./details.html') | |
| 174 | + os.system('rm -f ./_plotdevice.*.so') | ||
| 176 | 175 | os.system('find plotdevice -name .DS_Store -exec rm {} \;') | |
| 177 | 176 | os.system('find plotdevice -name \*.pyc -exec rm {} \;') | |
| 178 | 177 | os.system('find plotdevice -name __pycache__ -type d -prune -exec rmdir {} \;') | |
| 179 | 178 | ||
| 180 | - class LocalEnvCommand(Command): | ||
| 181 | - description = "set up app/deps/local env to allow for running from the sdist" | ||
| 179 | + class LocalDevCommand(Command): | ||
| 180 | + description = "set up environment to allow for running `python -m plotdevice` within the repo" | ||
| 182 | 181 | user_options = [] | |
| 183 | 182 | def initialize_options(self): | |
| 184 | 183 | pass | |
| 185 | 184 | def finalize_options(self): | |
| 186 | 185 | pass | |
| 187 | 186 | def run(self): | |
| 187 | + # install pyobjc, requests and the other pypi dependencies in app/deps/local | ||
| 188 | 188 | import platform | |
| 189 | 189 | venv_dir = join('app/deps/local', platform.python_version()) | |
| 190 | 190 | if not exists(venv_dir): | |
| 191 | 191 | import venv | |
| 192 | 192 | venv.create(venv_dir, symlinks=True, with_pip=True) | |
| 193 | 193 | PIP = '%s/bin/pip3' % venv_dir | |
| 194 | 194 | call([PIP, 'install', '-q', '--upgrade', 'pip']) | |
| 195 | - call([PIP, '--isolated', 'install', '-q', *config['install_requires']]) | ||
| 195 | + call([PIP, '--isolated', 'install', '--target', join(venv_dir, 'libs'), *config['install_requires']]) | ||
| 196 | + | ||
| 197 | + # place the compiled c-extensions in the main repo dir | ||
| 198 | + build_ext = self.distribution.get_command_obj('build_ext') | ||
| 199 | + build_ext.inplace = 1 | ||
| 200 | + self.run_command('build_ext') | ||
| 201 | + | ||
| 202 | + # build the sdist (primarily for access to its rsrc subdir) | ||
| 203 | + self.run_command('build_py') | ||
| 196 | 204 | ||
| 197 | - # use the venv's site directory | ||
| 198 | - site_path = getoutput('%s/bin/python3 -c "import site; print(site.getsitepackages()[0])"' % venv_dir) | ||
| 199 | - print(site_path) | ||
| 200 | 205 | ||
| 201 | 206 | ||
| 202 | 207 | from setuptools.command.sdist import sdist | |
@@ -367,13 +372,6 @@ def run(self): | |||
| 367 | 372 | ||
| 368 | 373 | print("\nBuilt PlotDevice.app, %s, and release.json in ./dist" % basename(ZIP)) | |
| 369 | 374 | ||
| 370 | - from glob import glob | ||
| 371 | - from setuptools.extension import Extension | ||
| 372 | - sources = ['app/deps/extensions/module.m', *glob('app/deps/extensions/*/*.[cm]')] | ||
| 373 | - frameworks = ['AppKit', 'Foundation', 'Quartz', 'Security', 'AVFoundation', 'CoreMedia', 'CoreVideo', 'CoreText'] | ||
| 374 | - flags = sum((['-framework', fmwk] for fmwk in frameworks), []) | ||
| 375 | - _plotdevice = Extension('_plotdevice', sources=sources, extra_link_args=flags) | ||
| 376 | - | ||
| 377 | 375 | # common config between module and app builds | |
| 378 | 376 | config = dict( | |
| 379 | 377 | name = MODULE, | |
@@ -386,7 +384,13 @@ def run(self): | |||
| 386 | 384 | license = LICENSE, | |
| 387 | 385 | classifiers = CLASSIFIERS, | |
| 388 | 386 | packages = find_packages(exclude=['tests']), | |
| 389 | - ext_modules = [_plotdevice], | ||
| 387 | + ext_modules = [Extension( | ||
| 388 | + '_plotdevice', | ||
| 389 | + sources = ['app/deps/extensions/module.m', *glob('app/deps/extensions/*/*.[cm]')], | ||
| 390 | + extra_link_args=sum((['-framework', fmwk] for fmwk in | ||
| 391 | + ['AppKit', 'Foundation', 'Quartz', 'Security', 'AVFoundation', 'CoreMedia', 'CoreVideo', 'CoreText'] | ||
| 392 | + ), []) | ||
| 393 | + )], | ||
| 390 | 394 | install_requires = [ | |
| 391 | 395 | 'requests', | |
| 392 | 396 | 'cachecontrol', | |
@@ -406,7 +410,7 @@ def run(self): | |||
| 406 | 410 | 'dist': DistCommand, | |
| 407 | 411 | 'sdist': BuildDistCommand, | |
| 408 | 412 | 'test': TestCommand, | |
| 409 | - 'env': LocalEnvCommand, | ||
| 413 | + 'dev': LocalDevCommand, | ||
| 410 | 414 | }, | |
| 411 | 415 | ) | |
| 412 | 416 | ||
@@ -417,7 +421,6 @@ def run(self): | |||
| 417 | 421 | # (this means the various commands don't have to play path games) | |
| 418 | 422 | os.chdir(dirname(abspath(__file__))) | |
| 419 | 423 | ||
| 420 | - | ||
| 421 | 424 | # py2app-specific config | |
| 422 | 425 | if 'py2app' in sys.argv: | |
| 423 | 426 | config.update(dict( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments