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

Support for conda as a language #1232

Merged
merged 1 commit into from Dec 21, 2019
Merged

Conversation

@xhochy
Copy link
Contributor

@xhochy xhochy commented Dec 2, 2019

Fixes #1204

Example usage

.pre-commit-hooks.yaml:

- id: black-conda
  name: black-conda
  description: "Black: The uncompromising Python code formatter"
  entry: black
  language: conda
  require_serial: true
  types: [python]

environment.yml:

channels:
  - conda-forge
  - defaults
dependencies:
  - black=19.10b0
@xhochy
Copy link
Contributor Author

@xhochy xhochy commented Dec 2, 2019

This is lacking sufficient tests, I'm unsure what should be tested and am open for suggestions.

@xhochy xhochy force-pushed the xhochy:conda-language branch 2 times, most recently from 30ed0d1 to 79779be Dec 2, 2019
pre_commit/languages/conda.py Outdated Show resolved Hide resolved
pre_commit/languages/conda.py Show resolved Hide resolved
pre_commit/languages/conda.py Show resolved Hide resolved
tests/repository_test.py Show resolved Hide resolved
pre_commit/languages/conda.py Outdated Show resolved Hide resolved
tests/repository_test.py Outdated Show resolved Hide resolved
@xhochy
Copy link
Contributor Author

@xhochy xhochy commented Dec 3, 2019

This has now all review comments incorporated and tests are passing except for Windows. There we need to download a lightweight conda (take an exe from https://repo.anaconda.com/pkgs/misc/conda-execs/) to get the tests passing. This needs an modification of the Azure template like https://github.com/asottile/azure-pipeline-templates/blob/f8721c757e218487ca0bb38af0201b2a04e9ed52/job--python-tox.yml#L63-L68 @asottile Should I modify the template to always install a conda.exe on Windows or make this conditional on some parameter?

@asottile
Copy link
Member

@asottile asottile commented Dec 3, 2019

there's a pre_test list where you can install whatever you need 👍

for example, here's what it does to install ruby / swift on linux:

pre_test:
- task: UseRubyVersion@0
- bash: |
testing/get-swift.sh
echo '##vso[task.prependpath]/tmp/swift/usr/bin'
displayName: install swift

@xhochy xhochy force-pushed the xhochy:conda-language branch 10 times, most recently from 5aba042 to f7144ad Dec 3, 2019
Copy link
Member

@asottile asottile left a comment

seems good!

pre_commit/languages/conda.py Show resolved Hide resolved
pre_commit/languages/conda.py Show resolved Hide resolved
@xhochy
Copy link
Contributor Author

@xhochy xhochy commented Dec 4, 2019

@asottile Adjusted all things and CI is still green. :)


@contextlib.contextmanager
def in_env(prefix, language_version):
helpers.assert_version_default('conda', language_version)

This comment has been minimized.

@asottile

asottile Dec 4, 2019
Member

this should be part of install_environment I believe

This comment has been minimized.

@xhochy

xhochy Dec 6, 2019
Author Contributor

Should these be removed here then?

This comment has been minimized.

@asottile

asottile Dec 6, 2019
Member

yes -- you can take precedent from the other languages that use this function

@xhochy xhochy force-pushed the xhochy:conda-language branch from ebdac73 to 4682d03 Dec 6, 2019
@xhochy
Copy link
Contributor Author

@xhochy xhochy commented Dec 6, 2019

@asottile Azure is failing with missing files in the template repo but these actually exist. Do you have an idea what is going wrong here?

@asottile
Copy link
Member

@asottile asottile commented Dec 6, 2019

@asottile Azure is failing with missing files in the template repo but these actually exist. Do you have an idea what is going wrong here?

huh they must have changed the inclusion rules :/

@asottile
Copy link
Member

@asottile asottile commented Dec 6, 2019

I'm trying to fix that in #1234 -- we'll see!

@asottile
Copy link
Member

@asottile asottile commented Dec 6, 2019

ok if you rebase on master it should fix the CI

@xhochy xhochy force-pushed the xhochy:conda-language branch from 4682d03 to ba021aa Dec 9, 2019
Copy link
Member

@asottile asottile left a comment

looks good! can probably squash the commits (if you want, don't need to though and don't feel obligated to)

I'm going to take this for a spin locally and then probably merge (so probably within a few days)!

thanks again for the work on this 🎉

@asottile asottile force-pushed the xhochy:conda-language branch from ba021aa to 4ff23b4 Dec 21, 2019
@asottile asottile merged commit 0ecd50b into pre-commit:master Dec 21, 2019
1 check passed
1 check passed
pre-commit.pre-commit #20191221.1 succeeded
Details
@xhochy xhochy deleted the xhochy:conda-language branch Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants
You can’t perform that action at this time.