Skip to content

Commit

Permalink
Merge branch 'release/3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wolph committed Dec 14, 2022
2 parents dc999b2 + 5711158 commit 30c7818
Show file tree
Hide file tree
Showing 16 changed files with 303 additions and 230 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/codeql.yml
@@ -0,0 +1,64 @@
name: "CodeQL"

on:
push:
branches: [ 'develop' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ 'develop' ]
schedule:
- cron: '26 17 * * 2'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
queries: +security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Expand Up @@ -11,12 +11,12 @@ jobs:
timeout-minutes: 10
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
82 changes: 0 additions & 82 deletions .travis.yml

This file was deleted.

22 changes: 20 additions & 2 deletions README.rst
Expand Up @@ -127,6 +127,24 @@ Plotting using `matplotlib`_ is equally easy:
.. _matplotlib: http://matplotlib.org/
.. _python-utils: https://github.com/WoLpH/python-utils

Experimental support for reading 3MF files
------------------------------------------------------------------------------

.. code-block:: python
import pathlib
import stl
path = pathlib.Path('tests/3mf/Moon.3mf')
# Load the 3MF file
for m in stl.Mesh.from_3mf_file(path):
# Do something with the mesh
print('mesh', m)
Note that this is still experimental and may not work for all 3MF files.
Additionally it only allows reading 3mf files, not writing them.

Modifying Mesh objects
------------------------------------------------------------------------------

Expand Down Expand Up @@ -193,7 +211,7 @@ Modifying Mesh objects
# Create a new plot
figure = pyplot.figure()
axes = mplot3d.Axes3D(figure)
axes = figure.add_subplot(projection='3d')
# Render the cube faces
for m in meshes:
Expand Down Expand Up @@ -264,7 +282,7 @@ Extending Mesh objects
# Create a new plot
figure = pyplot.figure()
axes = mplot3d.Axes3D(figure)
axes = figure.add_subplot(projection='3d')
# Render the cube
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(cube.vectors))
Expand Down
25 changes: 11 additions & 14 deletions appveyor.yml
@@ -1,17 +1,14 @@
environment:
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
# /E:ON and /V:ON options are not enabled in the batch script intepreter
# See: http://stackoverflow.com/a/13751649/163740
# CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\appveyor\\run_with_env.cmd"
image:
- Visual Studio 2019

global:
PYTHON: "C:\\Python38-x64\\python.exe"
environment:
matrix:
- TOXENV: py36
- TOXENV: py37
- TOXENV: py38
# not yet available on appveyor
# Does not work because of str of py.path
# - TOXENV: py39
# - TOXENV: py310

install:
# Download setup scripts and unzip
Expand All @@ -28,20 +25,20 @@ install:
# - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"

# Check that we have the expected version and architecture for Python
- "%PYTHON% --version"
- "%PYTHON% -c \"import struct; print(struct.calcsize('P') * 8)\""
- py --version
- py -c "import struct; print(struct.calcsize('P') * 8)"

build: false # Not a C# project, build stuff at the test step instead.

before_test:
- "%PYTHON% -m pip install tox numpy cython wheel"
- py -m pip install tox numpy cython wheel

test_script:
- "%PYTHON% -m tox -e %TOXENV%"
- "py -m tox -e %TOXENV%"

after_test:
- "%PYTHON% setup.py build_ext --inplace"
- "%PYTHON% setup.py sdist bdist_wheel"
- py setup.py build_ext --inplace
- py setup.py sdist bdist_wheel
- ps: "ls dist"

artifacts:
Expand Down
63 changes: 20 additions & 43 deletions setup.py
@@ -1,5 +1,3 @@
from __future__ import print_function

import os
import sys
import warnings
Expand All @@ -26,35 +24,21 @@ def error(*lines):
pass


class PyTest(TestCommand):
def finalize_options(self):
TestCommand.finalize_options(self)
self.test_args = []
self.test_suite = True

def run_tests(self):
# import here, cause outside the eggs aren't loaded
import pytest
errno = pytest.main(self.test_args)
sys.exit(errno)


if sys.version_info.major == 2 or sys.platform.lower() != 'win32':
try:
import numpy
from Cython import Build

setup_kwargs['ext_modules'] = Build.cythonize([
extension.Extension(
'stl._speedups',
['stl/_speedups.pyx'],
include_dirs=[numpy.get_include()],
),
])
except ImportError:
error('WARNING',
'Cython and Numpy is required for building extension.',
'Falling back to pure Python implementation.')
try:
import numpy
from Cython import Build

setup_kwargs['ext_modules'] = Build.cythonize([
extension.Extension(
'stl._speedups',
['stl/_speedups.pyx'],
include_dirs=[numpy.get_include()],
),
])
except ImportError:
error('WARNING',
'Cython and Numpy is required for building extension.',
'Falling back to pure Python implementation.')

# To prevent importing about and thereby breaking the coverage info we use this
# exec hack
Expand All @@ -72,15 +56,9 @@ def run_tests(self):

install_requires = [
'numpy',
'python-utils>=1.6.2',
'python-utils>=3.4.5',
]

try:
import enum
assert enum
except ImportError:
install_requires.append('enum34')


tests_require = ['pytest']

Expand All @@ -100,6 +78,7 @@ def run(self):

if __name__ == '__main__':
setup(
python_requires='>3.6.0',
name=about['__package_name__'],
version=about['__version__'],
author=about['__author__'],
Expand All @@ -125,19 +104,17 @@ def run(self):
'Operating System :: OS Independent',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Topic :: Software Development :: Libraries :: Python Modules',
],
install_requires=install_requires,
cmdclass=dict(
build_ext=BuildExt,
test=PyTest,
),
**setup_kwargs
)
Expand Down
2 changes: 1 addition & 1 deletion stl/__about__.py
@@ -1,6 +1,6 @@
__package_name__ = 'numpy-stl'
__import_name__ = 'stl'
__version__ = '2.17.1'
__version__ = '3.0.0'
__author__ = 'Rick van Hattem'
__author_email__ = 'Wolph@Wol.ph'
__description__ = ' '.join('''
Expand Down
3 changes: 2 additions & 1 deletion stl/_speedups.pyx
Expand Up @@ -130,7 +130,8 @@ def ascii_read(fh, buf):
line = readline(&state)
line = state.line

if strstr(line, 'endsolid') != NULL:
if strstr(line, 'endsolid') != NULL \
or strstr(line, 'end solid') != NULL:
arr.resize(facet - <Facet*>arr.data, refcheck=False)
return (<object>name).strip(), arr

Expand Down

0 comments on commit 30c7818

Please sign in to comment.