diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9491db393..2f73fdfef 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -44,15 +44,18 @@ jobs: if: ${{ contains(github.event.pull_request.labels.*.name, 'need-patch-apply-tests') && matrix.os == 'windows-latest' }} run: Add-Content $env:GITHUB_PATH "C:\Program Files\Git\usr\bin" - uses: prefix-dev/setup-pixi@v0.9.1 - if: ${{ contains(github.event.pull_request.labels.*.name, 'need-patch-apply-tests') && matrix.os == 'macos-latest' }} + if: ${{ matrix.os == 'macos-latest' }} with: cache: true - name: Set up GNU patch on MacOS # Needed to use GNU patch instead of whatever is builtin on macos (1 test fails) if: ${{ contains(github.event.pull_request.labels.*.name, 'need-patch-apply-tests') && matrix.os == 'macos-latest' }} run: pixi global install patch=2.7.6 + - name: Set up patchelf on MacOS + if: ${{ matrix.os == 'macos-latest' }} + run: pixi global install patchelf - name: Run tests - run: cargo test --features=tui,recipe-generation --verbose -- --nocapture + run: cargo test --all --features=tui,recipe-generation --verbose -- --nocapture - name: Run patch apply tests # https://github.com/orgs/community/discussions/26261#discussioncomment-3251039 if: ${{ contains(github.event.pull_request.labels.*.name, 'need-patch-apply-tests') }} diff --git a/crates/rattler_build_recipe_generator/src/snapshots/rattler_build_recipe_generator__pypi__tests__flask_noarch_recipe_generation.snap b/crates/rattler_build_recipe_generator/src/snapshots/rattler_build_recipe_generator__pypi__tests__flask_noarch_recipe_generation.snap new file mode 100644 index 000000000..61be0b53e --- /dev/null +++ b/crates/rattler_build_recipe_generator/src/snapshots/rattler_build_recipe_generator__pypi__tests__flask_noarch_recipe_generation.snap @@ -0,0 +1,42 @@ +--- +source: crates/rattler_build_recipe_generator/src/pypi.rs +expression: recipe +--- +context: + version: 3.1.0 +package: + name: flask + version: "${{ version }}" +source: + - url: "https://pypi.org/packages/source/f/flask/flask-${{ version }}.tar.gz" + sha256: 5f873c5184c897c8d9d1b05df1e3d01b14910ce69607a117bd3277098a5836ac +build: + script: "${{ PYTHON }} -m pip install ." + python: + entry_points: + - "flask = flask.cli:main" + noarch: python +requirements: + host: + - python >=3.9 + - flit_core<4 + - pip + run: + - python >=3.9 + - werkzeug >=3.1 + - jinja2 >=3.1.2 + - itsdangerous >=2.2 + - click >=8.1.3 + - blinker >=1.9 + - "importlib-metadata >=3.6 ;MARKER; python_version < \"3.10\"" + - "asgiref >=3.2 ;MARKER; extra == \"async\"" + - "python-dotenv ;MARKER; extra == \"dotenv\"" +tests: + - python: + imports: + - Flask + pip_check: true +about: + summary: A simple framework for building complex web applications. + description: "# Flask\n\nFlask is a lightweight [WSGI][] web application framework. It is designed\nto make getting started quick and easy, with the ability to scale up to\ncomplex applications. It began as a simple wrapper around [Werkzeug][]\nand [Jinja][], and has become one of the most popular Python web\napplication frameworks.\n\nFlask offers suggestions, but doesn't enforce any dependencies or\nproject layout. It is up to the developer to choose the tools and\nlibraries they want to use. There are many extensions provided by the\ncommunity that make adding new functionality easy.\n\n[WSGI]: https://wsgi.readthedocs.io/\n[Werkzeug]: https://werkzeug.palletsprojects.com/\n[Jinja]: https://jinja.palletsprojects.com/\n\n\n## A Simple Example\n\n```python\n# save this as app.py\nfrom flask import Flask\n\napp = Flask(__name__)\n\n@app.route(\"/\")\ndef hello():\n return \"Hello, World!\"\n```\n\n```\n$ flask run\n * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)\n```\n\n\n## Donate\n\nThe Pallets organization develops and supports Flask and the libraries\nit uses. In order to grow the community of contributors and users, and\nallow the maintainers to devote more time to the projects, [please\ndonate today][].\n\n[please donate today]: https://palletsprojects.com/donate\n\n" + documentation: "https://flask.palletsprojects.com/" diff --git a/crates/rattler_build_recipe_generator/src/snapshots/rattler_build_recipe_generator__pypi__tests__recipe_generation.snap b/crates/rattler_build_recipe_generator/src/snapshots/rattler_build_recipe_generator__pypi__tests__recipe_generation.snap new file mode 100644 index 000000000..34e43fe80 --- /dev/null +++ b/crates/rattler_build_recipe_generator/src/snapshots/rattler_build_recipe_generator__pypi__tests__recipe_generation.snap @@ -0,0 +1,40 @@ +--- +source: crates/rattler_build_recipe_generator/src/pypi.rs +expression: recipe +--- +context: + version: 1.24.0 +package: + name: numpy + version: "${{ version }}" +source: + - url: "https://pypi.org/packages/source/n/numpy/numpy-${{ version }}.tar.gz" + sha256: c4ab7c9711fe6b235e86487ca74c1b092a6dd59a3cb45b63241ea0a148501853 +build: + script: "${{ PYTHON }} -m pip install ." + python: + entry_points: + - "f2py = numpy.f2py.f2py2e:main" + - "f2py3 = numpy.f2py.f2py2e:main" + - "f2py3.10 = numpy.f2py.f2py2e:main" +requirements: + host: + - python >=3.8 + - setuptools==59.2.0 + - wheel==0.37.0 + - "Cython>=0.29.30,<3.0" + - pip + run: + - python >=3.8 +tests: + - python: + imports: + - numpy + pip_check: true +about: + homepage: "https://www.numpy.org" + summary: Fundamental package for array computing in Python + description: "

\n\n


\n\n\n[![Powered by NumFOCUS](https://img.shields.io/badge/powered%20by-NumFOCUS-orange.svg?style=flat&colorA=E1523D&colorB=007D8A)](\nhttps://numfocus.org)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/numpy.svg?label=PyPI%20downloads)](\nhttps://pypi.org/project/numpy/)\n[![Conda Downloads](https://img.shields.io/conda/dn/conda-forge/numpy.svg?label=Conda%20downloads)](\nhttps://anaconda.org/conda-forge/numpy)\n[![Stack Overflow](https://img.shields.io/badge/stackoverflow-Ask%20questions-blue.svg)](\nhttps://stackoverflow.com/questions/tagged/numpy)\n[![Nature Paper](https://img.shields.io/badge/DOI-10.1038%2Fs41592--019--0686--2-blue)](\nhttps://doi.org/10.1038/s41586-020-2649-2)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/numpy/numpy/badge)](https://api.securityscorecards.dev/projects/github.com/numpy/numpy)\n\n\nNumPy is the fundamental package for scientific computing with Python.\n\n- **Website:** https://www.numpy.org\n- **Documentation:** https://numpy.org/doc\n- **Mailing list:** https://mail.python.org/mailman/listinfo/numpy-discussion\n- **Source code:** https://github.com/numpy/numpy\n- **Contributing:** https://www.numpy.org/devdocs/dev/index.html\n- **Bug reports:** https://github.com/numpy/numpy/issues\n- **Report a security vulnerability:** https://tidelift.com/docs/security\n\nIt provides:\n\n- a powerful N-dimensional array object\n- sophisticated (broadcasting) functions\n- tools for integrating C/C++ and Fortran code\n- useful linear algebra, Fourier transform, and random number capabilities\n\nTesting:\n\nNumPy requires `pytest` and `hypothesis`. Tests can then be run after installation with:\n\n python -c 'import numpy; numpy.test()'\n\nCode of Conduct\n----------------------\n\nNumPy is a community-driven open source project developed by a diverse group of\n[contributors](https://numpy.org/teams/). The NumPy leadership has made a strong\ncommitment to creating an open, inclusive, and positive community. Please read the\n[NumPy Code of Conduct](https://numpy.org/code-of-conduct/) for guidance on how to interact\nwith others in a way that makes our community thrive.\n\nCall for Contributions\n----------------------\n\nThe NumPy project welcomes your expertise and enthusiasm!\n\nSmall improvements or fixes are always appreciated. If you are considering larger contributions\nto the source code, please contact us through the [mailing\nlist](https://mail.python.org/mailman/listinfo/numpy-discussion) first.\n\nWriting code isn’t the only way to contribute to NumPy. You can also:\n- review pull requests\n- help us stay on top of new and old issues\n- develop tutorials, presentations, and other educational materials\n- maintain and improve [our website](https://github.com/numpy/numpy.org)\n- develop graphic design for our brand assets and promotional materials\n- translate website content\n- help with outreach and onboard new contributors\n- write grant proposals and help with other fundraising efforts\n\nFor more information about the ways you can contribute to NumPy, visit [our website](https://numpy.org/contribute/). \nIf you’re unsure where to start or how your skills fit in, reach out! You can\nask on the mailing list or here, on GitHub, by opening a new issue or leaving a\ncomment on a relevant issue that is already open.\n\nOur preferred channels of communication are all public, but if you’d like to\nspeak to us in private first, contact our community coordinators at\nnumpy-team@googlegroups.com or on Slack (write numpy-team@googlegroups.com for\nan invitation).\n\nWe also have a biweekly community call, details of which are announced on the\nmailing list. You are very welcome to join.\n\nIf you are new to contributing to open source, [this\nguide](https://opensource.guide/how-to-contribute/) helps explain why, what,\nand how to successfully get involved.\n\n\n" + license: BSD-3-Clause + repository: "https://github.com/numpy/numpy" + documentation: "https://numpy.org/doc/1.24" diff --git a/test-data/recipes/binary_prefix_test/recipe.yaml b/test-data/recipes/binary_prefix_test/recipe.yaml index ce8482edf..03a6201d4 100644 --- a/test-data/recipes/binary_prefix_test/recipe.yaml +++ b/test-data/recipes/binary_prefix_test/recipe.yaml @@ -33,13 +33,16 @@ build: - | setlocal enabledelayedexpansion set "PREFIX_ESC=%PREFIX:\=\\%" - echo #include ^ > test_binary.c - echo int main() { >> test_binary.c - echo const char* prefix = "!PREFIX_ESC!"; >> test_binary.c - echo printf("Prefix is: %%s\\n", prefix); >> test_binary.c - echo return 0; >> test_binary.c - echo } >> test_binary.c + ( + echo #include ^ + echo int main() { + echo const char* prefix = "!PREFIX_ESC!"; + echo printf("Prefix is: %%s\\n", prefix^); + echo return 0; + echo } + ) > test_binary.c gcc test_binary.c -o "%PREFIX%\Library\bin\test_binary.exe" + if %errorlevel% neq 0 exit /b %errorlevel% requirements: build: diff --git a/test/end-to-end/helpers.py b/test/end-to-end/helpers.py index df1c615df..dd9d19a02 100644 --- a/test/end-to-end/helpers.py +++ b/test/end-to-end/helpers.py @@ -28,9 +28,19 @@ def __call__(self, *args: Any, **kwds: Any) -> Any: return result else: try: - output = check_output([str(self.path), *args], **kwds) - if "text" not in kwds: - return output.decode("utf-8") + # Explicitly handle encoding for UTF-8 output on all platforms + kwds_copy = dict(kwds) + # Check if we need to add encoding + needs_encoding = "text" not in kwds_copy and "encoding" not in kwds_copy + if needs_encoding: + kwds_copy["encoding"] = "utf-8" + kwds_copy["errors"] = "replace" + + output = check_output([str(self.path), *args], **kwds_copy) + + # If we added encoding, output is already a string + # If text was in kwds, output is also a string + # Otherwise, it's bytes and needs decoding (but we added encoding, so this won't happen) return output except CalledProcessError as e: if kwds.get("stderr") is None: diff --git a/test/end-to-end/test_simple.py b/test/end-to-end/test_simple.py index 00122db20..9264a41b9 100644 --- a/test/end-to-end/test_simple.py +++ b/test/end-to-end/test_simple.py @@ -1464,7 +1464,7 @@ def test_missing_pin_subpackage( tmp_path, stderr=STDOUT, ) - stdout = e.value.output.decode("utf-8") + stdout = e.value.output assert "Missing output: test1 (used in pin_subpackage)" in stdout @@ -1476,7 +1476,7 @@ def test_cycle_detection(rattler_build: RattlerBuild, recipes: Path, tmp_path: P tmp_path, stderr=STDOUT, ) - stdout = e.value.output.decode("utf-8") + stdout = e.value.output assert "Found a cycle in the recipe outputs: bazbus" in stdout @@ -1694,7 +1694,7 @@ def test_python_version_spec( args = rattler_build.build_args(recipes / "python-version-spec", tmp_path) rattler_build(*args, stderr=STDOUT) - error_output = exc_info.value.output.decode("utf-8") + error_output = exc_info.value.output assert ( "failed to parse match spec: unable to parse version spec: =.*" in error_output ) @@ -2048,6 +2048,7 @@ def test_merge_build_and_host( ) +@pytest.mark.skipif(os.name == "nt", reason="Not applicable on Windows") def test_error_on_binary_prefix( rattler_build: RattlerBuild, recipes: Path, tmp_path: Path ): @@ -2071,7 +2072,7 @@ def test_error_on_binary_prefix( rattler_build(*args, stderr=STDOUT) pytest.fail("Expected build to fail with binary prefix error") except CalledProcessError as e: - output = e.output.decode("utf-8") if e.output else "" + output = e.output assert "Binary file" in output and "contains host prefix" in output