Skip to content

Commit b7a85cf

Browse files
committed
Cleanup
1 parent 737ba52 commit b7a85cf

File tree

7 files changed

+42
-51
lines changed

7 files changed

+42
-51
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# patched
44
libparse.h
5-
libparse.cc
5+
libparse.cpp
66

77
# swig
88
libparse.py
@@ -11,6 +11,7 @@ libparse_wrap.*
1111
# python
1212
__pycache__
1313
/venv
14+
/dist
1415
*.egg-info
1516

1617
# binaries

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CXXFLAGS += -g -std=c++17 -I$(shell python3 -c "import sysconfig; print(sysconfi
1010

1111

1212
all: _libparse.so
13+
patch: $(SRC_DIR)/libparse.cpp $(SRC_DIR)/libparse.h
1314
swig_out: $(SWIG_OUT)
1415

1516
_libparse.so: $(OBJECTS)
@@ -39,4 +40,5 @@ clean:
3940
rm -f $(SRC_DIR)/*.cpp $(SRC_DIR)/*.o $(SRC_DIR)/libparse.py $(SRC_DIR)/libparse.h
4041
rm -f *.so *.o *.dylib *.dll
4142
rm -rf build/
42-
rm -rf libparse.egg-info/
43+
rm -rf libparse.egg-info/
44+
rm -rf dist/

Readme.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ A SWIG-based Python wrapper around [Yosys](https://github.com/yosyshq/yosys)'s
44
`libparse`, for all your lib file parsing needs.
55

66
# Requirements
7-
* Python 3.2+
8-
* A C++17 compiler
7+
* Python 3.6+
8+
* A C++11 compiler
99
* GNU Make
1010

1111
# License
@@ -33,25 +33,25 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3333
`stdio_filebuf` from [Android Frameworks](https://android.googlesource.com/platform/frameworks/native/+/refs/heads/main/services/vr/performanced) used under the following conditions:
3434

3535
```
36-
// Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
37-
// Copyright (c) 2016 Google, Inc.
38-
//
39-
// Permission is hereby granted, free of charge, to any person obtaining a copy
40-
// of this software and associated documentation files (the "Software"), to deal
41-
// in the Software without restriction, including without limitation the rights
42-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43-
// copies of the Software, and to permit persons to whom the Software is
44-
// furnished to do so, subject to the following conditions:
45-
//
46-
// The above copyright notice and this permission notice shall be included in
47-
// all copies or substantial portions of the Software.
48-
//
49-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
55-
// THE SOFTWARE.
36+
Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
37+
Copyright (c) 2016 Google, Inc.
38+
39+
Permission is hereby granted, free of charge, to any person obtaining a copy
40+
of this software and associated documentation files (the "Software"), to deal
41+
in the Software without restriction, including without limitation the rights
42+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
43+
copies of the Software, and to permit persons to whom the Software is
44+
furnished to do so, subject to the following conditions:
45+
46+
The above copyright notice and this permission notice shall be included in
47+
all copies or substantial portions of the Software.
48+
49+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
50+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
51+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
52+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
53+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
54+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
55+
THE SOFTWARE.
5656
```
57-
> The `CREDITS.TXT` in question could not be located at press time.
57+
> The `CREDITS.TXT` in question could not be located.

libparse/libparse.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
%{
88
#define SWIG_FILE_WITH_INIT
9+
#define Py_LIMITED_API 0x030600F0
910
#include <iostream>
1011
#include <memory>
1112
#include "libparse.h"

libparse/py_iostream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define Py_LIMITED_API 0x030600F0
12
#include "Python.h"
23
#include <cstdio>
34
#include <iostream>

setup.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,25 @@
22
import os
33
import subprocess
44
from setuptools import setup, find_packages, Extension
5-
from setuptools.command.build_py import build_py
65

76
module_name = "libparse"
8-
__dir__ = os.path.dirname(__file__)
7+
__dir__ = os.path.dirname(os.path.abspath(__file__))
8+
9+
subprocess.check_call(["make", "patch"], cwd=__dir__)
910

1011
ext = Extension(
11-
name='_libparse',
12-
swig_opts=['-c++'],
12+
name="_libparse",
13+
swig_opts=["-c++"],
1314
sources=[
14-
'libparse/libparse.cpp',
15-
'libparse/libparse.i',
15+
"libparse/libparse.cpp",
16+
"libparse/libparse.i",
1617
],
1718
include_dirs=[
18-
'libparse',
19+
"libparse",
1920
],
20-
extra_compile_args=[
21-
'-std=c++17',
22-
"-DFILTERLIB"
23-
]
21+
extra_compile_args=["-std=c++17", "-DFILTERLIB"],
2422
)
2523

26-
class BuildPy(build_py):
27-
def run(self):
28-
subprocess.check_call([
29-
"make",
30-
"swig_out"
31-
])
32-
self.run_command('build_ext')
33-
super(build_py, self).run()
34-
3524
setup(
3625
name=module_name,
3726
packages=find_packages(),
@@ -41,7 +30,7 @@ def run(self):
4130
long_description_content_type="text/markdown",
4231
author="Efabless Corporation and Contributors",
4332
author_email="[email protected]",
44-
install_requires=[],
33+
install_requires=["wheel"],
4534
classifiers=[
4635
"License :: OSI Approved :: Apache Software License",
4736
"Programming Language :: Python :: 3",
@@ -51,7 +40,4 @@ def run(self):
5140
],
5241
python_requires=">3.6",
5342
ext_modules=[ext],
54-
cmdclass={
55-
'build_py': BuildPy,
56-
},
57-
)
43+
)

test/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
exit(-1)
2626
default_operating_conditions = operating_conditions_raw.values()[0]
2727

28-
print(default_operating_conditions.id, default_operating_conditions.value)
28+
print(default_operating_conditions.id, default_operating_conditions.value)

0 commit comments

Comments
 (0)