Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get simple setuptools setup.py working #524

Merged
merged 2 commits into from
Feb 21, 2024
Merged

Conversation

tekknolagi
Copy link
Owner

@tekknolagi tekknolagi commented Feb 21, 2024

Woooo! Let's go!

cedar% ~/Documents/code/skybison/build-relwithdebinfo/bin/python setup.py build_ext --inplace 
running build_ext
building 'signature' extension
creating build
creating build/temp.linux-x86_64-skybison-38
gcc -Wno-unused-result -Wsign-compare -g -Og -Wall -fPIC -I/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8 -I/home/max/Documents/code/skybison/build-relwithdebinfo/include/python3.8 -c signature.c -o build/temp.linux-x86_64-skybison-38/signature.o -std=c99 -Wall -Wextra
In file included from /home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-data.h:5,
                 from /home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/Python.h:15,
                 from signature.c:1:
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:1306:58: warning: ‘struct timespec’ declared inside parameter list will not be visible outside of this definition or declaration
 1306 | PyAPI_FUNC_DECL(int _PyTime_AsTimespec(_PyTime_t, struct timespec*));
      |                                                          ^~~~~~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:16:70: note: in definition of macro ‘PyAPI_FUNC_DECL’
   16 | #define PyAPI_FUNC_DECL(DECL) __attribute__((visibility("default"))) DECL
      |                                                                      ^~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:1307:57: warning: ‘struct timeval’ declared inside parameter list will not be visible outside of this definition or declaration
 1307 | PyAPI_FUNC_DECL(int _PyTime_AsTimeval(_PyTime_t, struct timeval*,
      |                                                         ^~~~~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:16:70: note: in definition of macro ‘PyAPI_FUNC_DECL’
   16 | #define PyAPI_FUNC_DECL(DECL) __attribute__((visibility("default"))) DECL
      |                                                                      ^~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:1311:65: warning: ‘struct timeval’ declared inside parameter list will not be visible outside of this definition or declaration
 1311 | PyAPI_FUNC_DECL(int _PyTime_AsTimeval_noraise(_PyTime_t, struct timeval*,
      |                                                                 ^~~~~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:16:70: note: in definition of macro ‘PyAPI_FUNC_DECL’
   16 | #define PyAPI_FUNC_DECL(DECL) __attribute__((visibility("default"))) DECL
      |                                                                      ^~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:1320:64: warning: ‘struct timespec’ declared inside parameter list will not be visible outside of this definition or declaration
 1320 | PyAPI_FUNC_DECL(int _PyTime_FromTimespec(_PyTime_t* tp, struct timespec* ts));
      |                                                                ^~~~~~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:16:70: note: in definition of macro ‘PyAPI_FUNC_DECL’
   16 | #define PyAPI_FUNC_DECL(DECL) __attribute__((visibility("default"))) DECL
      |                                                                      ^~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:1321:63: warning: ‘struct timeval’ declared inside parameter list will not be visible outside of this definition or declaration
 1321 | PyAPI_FUNC_DECL(int _PyTime_FromTimeval(_PyTime_t* tp, struct timeval* tv));
      |                                                               ^~~~~~~
/home/max/Documents/code/skybison/build-relwithdebinfo/include/skybison3.8/cpython-func.h:16:70: note: in definition of macro ‘PyAPI_FUNC_DECL’
   16 | #define PyAPI_FUNC_DECL(DECL) __attribute__((visibility("default"))) DECL
      |                                                                      ^~~~
creating build/lib.linux-x86_64-skybison-38
gcc -pthread -shared build/temp.linux-x86_64-skybison-38/signature.o -o build/lib.linux-x86_64-skybison-38/signature.pyro.so
copying build/lib.linux-x86_64-skybison-38/signature.pyro.so -> 
cedar%

Subclasses in the wild write `@property` functions that shadow the
attributes. Since they are getter only, the builtin attribute setting
fails with an `AttributeError`:

```
======================================================================
ERROR: test_set_path_attr_on_import_error_subclass_with_property_sets_attr (__main__.ExceptionTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "library/builtins_test.py", line 4968, in test_set_path_attr_on_import_error_subclass_with_property_sets_attr
    c = C("a path")
  File "library/builtins.py", line 1037, in __init__
    self.path = path
AttributeError: can't set attribute
```

If we use `_instance_setattr`, this works.

This may be a more general problem since CPython does all this stuff in
C and our builtins are all in Python, but I am not sure how to approach
that yet.

This comment has been minimized.

This signature should be more like `dict.update`. This is also needed
for setuptools.
Copy link

{
  "django_minimal_requests": {
    "benchmark": "django_minimal_requests",
    "cg_instructions before": 682929,
    "cg_instructions now": 682539,
    "cg_instructions ∆": "-0.1%",
    "interpreter_args": [],
    "interpreter_name": "pyro",
    "version before": "cd9b613ea5d1d9e396dfa7b3fb1a2c6405ce5550",
    "version now": "8bf16353b4a977a88d2504d9c38c1c26fc323e9c"
  }
}

Copy link

Summary

Metric Average Best Worst Notes
cg_instructions -0.0% bench_pickle -0.0% loadproperty 0.0% typically < 0.2% noise
Benchmark details

Base vs. New

benchmark cg_instructions
2to3 0.0%
bench_base64 0.0%
bench_compile -0.0%
bench_pickle -0.0%
deltablue -0.0%
fannkuch 0.0%
go -0.0%
loadproperty 0.0%
nbody 0.0%
nqueens 0.0%
pyflate 0.0%
pystone -0.0%
richards -0.0%

CPython vs New

benchmark cg_instructions
2to3 -10.8%
bench_base64 -40.2%
bench_compile 1076.3%
bench_pickle -28.0%
deltablue -65.3%
fannkuch -3.4%
go -64.6%
loadproperty -75.6%
nbody 20.7%
nqueens 25.5%
pyflate -33.8%
pystone -73.9%
richards -80.1%

Base

benchmark cg_instructions
2to3 2,287,458,721
bench_base64 2,882,302,893
bench_compile 2,905,462,629
bench_pickle 2,986,587,549
deltablue 1,430,244,106
fannkuch 5,397,347,579
go 1,864,290,981
loadproperty 427,303,231
nbody 9,408,463,603
nqueens 2,776,582,729
pyflate 9,583,566,252
pystone 1,038,563,987
richards 957,246,998

New

benchmark cg_instructions
2to3 2,287,473,192
bench_base64 2,882,318,557
bench_compile 2,905,425,415
bench_pickle 2,985,989,081
deltablue 1,430,219,371
fannkuch 5,397,358,838
go 1,864,284,844
loadproperty 427,309,720
nbody 9,408,468,668
nqueens 2,776,583,795
pyflate 9,583,567,357
pystone 1,038,562,457
richards 957,243,467

CPython

benchmark cg_instructions
2to3 2,564,110,441
bench_base64 4,819,165,806
bench_compile 246,988,515
bench_pickle 4,145,073,768
deltablue 4,118,588,518
fannkuch 5,587,453,272
go 5,263,142,446
loadproperty 1,747,793,762
nbody 7,793,860,245
nqueens 2,213,286,845
pyflate 14,472,084,835
pystone 3,981,752,910
richards 4,819,784,160

Copy link

Summary

Metric Average Best Worst Notes
cg_instructions -0.0% bench_pickle -0.0% loadproperty 0.0% typically < 0.2% noise
Benchmark details

Base vs. New

benchmark cg_instructions
2to3 0.0%
bench_base64 0.0%
bench_compile -0.0%
bench_pickle -0.0%
deltablue 0.0%
fannkuch 0.0%
go -0.0%
loadproperty 0.0%
nbody 0.0%
nqueens 0.0%
pyflate 0.0%
pystone 0.0%
richards 0.0%

CPython vs New

benchmark cg_instructions
2to3 -10.8%
bench_base64 -40.2%
bench_compile 1076.3%
bench_pickle -28.0%
deltablue -65.3%
fannkuch -3.4%
go -64.6%
loadproperty -75.6%
nbody 20.7%
nqueens 25.5%
pyflate -33.8%
pystone -73.9%
richards -80.1%

Base

benchmark cg_instructions
2to3 2,287,458,721
bench_base64 2,882,302,893
bench_compile 2,905,462,629
bench_pickle 2,986,587,549
deltablue 1,430,209,376
fannkuch 5,397,347,579
go 1,864,370,014
loadproperty 427,303,231
nbody 9,408,463,603
nqueens 2,776,582,729
pyflate 9,583,566,252
pystone 1,038,563,987
richards 957,246,998

New

benchmark cg_instructions
2to3 2,287,536,410
bench_base64 2,882,329,475
bench_compile 2,905,427,517
bench_pickle 2,985,858,855
deltablue 1,430,231,965
fannkuch 5,397,368,453
go 1,864,290,982
loadproperty 427,319,781
nbody 9,408,478,321
nqueens 2,776,596,279
pyflate 9,583,576,778
pystone 1,038,573,819
richards 957,255,669

CPython

benchmark cg_instructions
2to3 2,564,110,434
bench_base64 4,819,165,806
bench_compile 246,988,515
bench_pickle 4,144,949,538
deltablue 4,118,588,518
fannkuch 5,587,453,265
go 5,263,142,446
loadproperty 1,747,793,755
nbody 7,793,860,245
nqueens 2,213,286,838
pyflate 14,472,084,835
pystone 3,981,752,910
richards 4,819,784,160

@tekknolagi tekknolagi marked this pull request as ready for review February 21, 2024 19:35
@tekknolagi
Copy link
Owner Author

Not sure how to make this an automated test... Ah well.

@tekknolagi tekknolagi merged commit ba3fe61 into trunk Feb 21, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant