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

fix: support another kind of setuptools import #207

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pysrc/setup_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def _save_passed_args(**kwargs):

distutils.core.setup = _save_passed_args
setuptools.setup = _save_passed_args
setup_py_content = setup_py_content.replace("setup(", "passed_arguments = setup(")
setup_py_content = re.sub(r"(setuptools\.)?setup\(", r"passed_arguments = \g<0>", setup_py_content)

# Fetch the arguments that were passed to the setup.py
exec(setup_py_content, globals())
Expand Down
18 changes: 18 additions & 0 deletions test/unit/setup_file.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path = require('path');
import { executeSync } from '../../lib/dependencies/sub-process';

describe('Test setup_file.py', () => {
it.each`
setupPyContent
${'import setuptools;setuptools.setup(name="test")'}
${'from setuptools import setup;setup(name="test")'}
`("parse works for '$setupPyContent'", ({ setupPyContent }) => {
const result = executeSync(
'python',
['-c', `from setup_file import parse; parse('${setupPyContent}')`],
{ cwd: path.resolve(__dirname, '../../pysrc') }
);

expect(result.status).toBe(0);
});
});