Fix the distribution from sources.

pull/493/head
KmolYuan 2019-09-27 09:19:43 +08:00
parent 4f034441c2
commit 989008e3e9
11 changed files with 174 additions and 144 deletions

132
cython/.gitignore vendored
View File

@ -1,117 +1,17 @@
# cython /CMakeCache.txt
/build*/
/test/**/*.diff.*
/test/**/*.curr.*
*.trace
/debian/tmp/
/debian/*.log
/debian/*.substvars
/debian/*.debhelper
/debian/files
/debian/solvespace/
/debian/libslvs1/
/debian/libslvs1-dev/
/obj-*/
/*.slvs
.idea/*
python_solvespace/*.cpp python_solvespace/*.cpp
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
*.o*
*.cxx
*.def
*.lib
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
AppImageAssistant
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
out/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
#PyCharm cache
.idea/
# Others
.DS_Store
*/.DS_Store

View File

@ -1,2 +1,3 @@
include requirements.txt include requirements.txt
include README.md include README.md
recursive-include . *.h

Binary file not shown.

3
cython/platform/config.h Normal file
View File

@ -0,0 +1,3 @@
#ifndef SOLVESPACE_CONFIG_H
#define SOLVESPACE_CONFIG_H
#endif

View File

@ -0,0 +1,57 @@
Metadata-Version: 2.1
Name: python-solvespace
Version: 3.0.0.post2
Summary: Python library of Solvespace
Home-page: https://github.com/KmolYuan/solvespace
Author: Yuan Chang
Author-email: pyslvs@gmail.com
License: UNKNOWN
Description: [![Version](https://img.shields.io/badge/version-3.0.0-yellow.svg)](https://github.com/KmolYuan/solvespace/releases/latest)
[![Build status](https://ci.appveyor.com/api/projects/status/b2o8jw7xnfqghqr5?svg=true)](https://ci.appveyor.com/project/KmolYuan/solvespace)
[![Build status](https://img.shields.io/travis/KmolYuan/solvespace.svg?logo=travis)](https://travis-ci.org/KmolYuan/solvespace)
[![PyPI](https://img.shields.io/pypi/v/python-solvespace.svg)](https://pypi.org/project/python-solvespace/)
[![GitHub license](https://img.shields.io/badge/license-GPLv3+-blue.svg)](https://raw.githubusercontent.com/KmolYuan/solvespace/master/LICENSE)
# python-solvespace
Python library from solver of SolveSpace.
+ [Python API](https://pyslvs-ui.readthedocs.io/en/stable/python-solvespace-api/)
+ [C API](https://github.com/solvespace/solvespace/blob/master/exposed/DOC.txt)
# Install
```bash
pip install python-solvespace
```
# Build and Test (Repository)
Build and install the module:
```bash
python setup.py install
```
Run unit test:
```bash
python tests
```
Uninstall the module:
```bash
pip uninstall python-solvespace
```
[GNU Make]: https://sourceforge.net/projects/mingw-w64/files/latest/download?source=files
[Cython]: https://cython.org/
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Cython
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown

View File

@ -0,0 +1,53 @@
MANIFEST.in
README.md
requirements.txt
setup.py
./platform/config.h
./python_solvespace/include/slvs.h
./python_solvespace/src/dsc.h
./python_solvespace/src/expr.h
./python_solvespace/src/polygon.h
./python_solvespace/src/resource.h
./python_solvespace/src/sketch.h
./python_solvespace/src/solvespace.h
./python_solvespace/src/ttf.h
./python_solvespace/src/ui.h
./python_solvespace/src/platform/gui.h
./python_solvespace/src/platform/platform.h
./python_solvespace/src/render/gl3shader.h
./python_solvespace/src/render/render.h
./python_solvespace/src/srf/surface.h
platform/config.h
python_solvespace/__init__.pxd
python_solvespace/__init__.py
python_solvespace/slvs.pxd
python_solvespace/slvs.pyi
python_solvespace/slvs.pyx
python_solvespace.egg-info/PKG-INFO
python_solvespace.egg-info/SOURCES.txt
python_solvespace.egg-info/dependency_links.txt
python_solvespace.egg-info/requires.txt
python_solvespace.egg-info/top_level.txt
python_solvespace/include/slvs.h
python_solvespace/src/constraint.cpp
python_solvespace/src/constrainteq.cpp
python_solvespace/src/dsc.h
python_solvespace/src/entity.cpp
python_solvespace/src/expr.cpp
python_solvespace/src/expr.h
python_solvespace/src/lib.cpp
python_solvespace/src/polygon.h
python_solvespace/src/resource.h
python_solvespace/src/sketch.h
python_solvespace/src/solvespace.h
python_solvespace/src/system.cpp
python_solvespace/src/ttf.h
python_solvespace/src/ui.h
python_solvespace/src/util.cpp
python_solvespace/src/platform/gui.h
python_solvespace/src/platform/platform.cpp
python_solvespace/src/platform/platform.h
python_solvespace/src/platform/utilwin.cpp
python_solvespace/src/render/gl3shader.h
python_solvespace/src/render/render.h
python_solvespace/src/srf/surface.h

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,3 @@
setuptools
wheel
cython

View File

@ -0,0 +1 @@
python_solvespace

View File

@ -8,7 +8,7 @@ __author__ = "Yuan Chang"
__copyright__ = "Copyright (C) 2016-2019" __copyright__ = "Copyright (C) 2016-2019"
__license__ = "GPLv3+" __license__ = "GPLv3+"
__email__ = "pyslvs@gmail.com" __email__ = "pyslvs@gmail.com"
__version__ = "3.0.0.post2" __version__ = "3.0.0.post3"
from .slvs import ( from .slvs import (
quaternion_u, quaternion_u,

View File

@ -7,24 +7,26 @@ __copyright__ = "Copyright (C) 2016-2019"
__license__ = "GPLv3+" __license__ = "GPLv3+"
__email__ = "pyslvs@gmail.com" __email__ = "pyslvs@gmail.com"
import os
from os.path import ( from os.path import (
abspath, abspath,
dirname, dirname,
isdir,
join as pth_join, join as pth_join,
) )
import re import re
import codecs import codecs
from textwrap import dedent
from setuptools import setup, Extension, find_packages from setuptools import setup, Extension, find_packages
from setuptools.command.build_ext import build_ext from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist
from distutils import dir_util
from platform import system from platform import system
from distutils import sysconfig from distutils import sysconfig
here = abspath(dirname(__file__)) here = abspath(dirname(__file__))
include_path = '../include/' include_path = pth_join('python_solvespace', 'include')
src_path = '../src/' src_path = pth_join('python_solvespace', 'src')
platform_path = src_path + 'platform/' platform_path = pth_join(src_path, 'platform')
extra_path = pth_join(here, 'platform')
ver = sysconfig.get_config_var('VERSION') ver = sysconfig.get_config_var('VERSION')
lib = sysconfig.get_config_var('BINDIR') lib = sysconfig.get_config_var('BINDIR')
@ -66,14 +68,14 @@ compile_args = [
] ]
sources = [ sources = [
'python_solvespace/' + 'slvs.pyx', pth_join('python_solvespace', 'slvs.pyx'),
src_path + 'util.cpp', pth_join(src_path, 'util.cpp'),
src_path + 'entity.cpp', pth_join(src_path, 'entity.cpp'),
src_path + 'expr.cpp', pth_join(src_path, 'expr.cpp'),
src_path + 'constrainteq.cpp', pth_join(src_path, 'constrainteq.cpp'),
src_path + 'constraint.cpp', pth_join(src_path, 'constraint.cpp'),
src_path + 'system.cpp', pth_join(src_path, 'system.cpp'),
src_path + 'lib.cpp', pth_join(src_path, 'lib.cpp'),
] ]
if system() == 'Windows': if system() == 'Windows':
@ -87,23 +89,32 @@ if system() == 'Windows':
macros.append(('WIN32', None)) macros.append(('WIN32', None))
# Platform sources # Platform sources
sources.append(platform_path + 'utilwin.cpp') sources.append(pth_join(platform_path, 'utilwin.cpp'))
sources.append(platform_path + 'platform.cpp') sources.append(pth_join(platform_path, 'platform.cpp'))
else: else:
sources.append(platform_path + 'utilunix.cpp') sources.append(pth_join(platform_path, 'utilunix.cpp'))
class Build(build_ext): class Build(build_ext):
def run(self): def run(self):
# Generate "config.h", actually not used. has_src = isdir(include_path) and isdir(src_path)
config_h = src_path + "config.h" if not has_src:
write(dedent(f"""\ dir_util.copy_tree(pth_join('..', 'include'), include_path)
#ifndef SOLVESPACE_CONFIG_H dir_util.copy_tree(pth_join('..', 'src'), src_path)
#define SOLVESPACE_CONFIG_H
#endif
"""), config_h)
super(Build, self).run() super(Build, self).run()
os.remove(config_h) if not has_src:
dir_util.remove_tree(include_path, dry_run=self.dry_run)
dir_util.remove_tree(src_path, dry_run=self.dry_run)
class PackSource(sdist):
def run(self):
dir_util.copy_tree(pth_join('..', 'include'), include_path)
dir_util.copy_tree(pth_join('..', 'src'), src_path)
super(PackSource, self).run()
if not self.keep_temp:
dir_util.remove_tree(include_path, dry_run=self.dry_run)
dir_util.remove_tree(src_path, dry_run=self.dry_run)
setup( setup(
@ -116,16 +127,16 @@ setup(
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
url="https://github.com/KmolYuan/solvespace", url="https://github.com/KmolYuan/solvespace",
packages=find_packages(exclude=('tests',)), packages=find_packages(exclude=('tests',)),
package_data={'': ["*.pyi"]}, package_data={'': ["*.pyi", "*.pxd"]},
ext_modules=[Extension( ext_modules=[Extension(
"python_solvespace.slvs", "python_solvespace.slvs",
sources, sources,
language="c++", language="c++",
include_dirs=[include_path, src_path, platform_path], include_dirs=[include_path, src_path, platform_path, extra_path],
define_macros=macros, define_macros=macros,
extra_compile_args=compile_args extra_compile_args=compile_args
)], )],
cmdclass={'build_ext': Build}, cmdclass={'build_ext': Build, 'sdist': PackSource},
python_requires=">=3.6", python_requires=">=3.6",
install_requires=read('requirements.txt').splitlines(), install_requires=read('requirements.txt').splitlines(),
test_suite="tests", test_suite="tests",