Skip to content

Make targets for a virtualenv #1280

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

Merged
merged 3 commits into from
Oct 13, 2022
Merged

Conversation

handrews
Copy link
Contributor

It's common to make a virtualenv inside of your cloned repo
to ensure that you have the right enviornment for that repository,
and .venv is a common convention for that virtualenv.

This adds targets to create and clean a .venv virtual env using
the checked-in requirements.txt file. It also adds the .venv
to the .gitignore, and updates the README.

README.md Outdated
The Makefile can create the necessary Python virtual environment for you:

```sh
make venv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make requirements.txt a dependency of .venv, you can then make .venv a dependency of the default target. If so, users would only need to run make instead of make venv followed by make.

Given that and @webknjaz suggestion about the activation script, this could become just make as it was originally documented

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@handrews I think this comment still applies. The venv is now part of the all target, so users can just run make

@handrews
Copy link
Contributor Author

handrews commented Oct 8, 2022

Sorry for the delay on this, and thanks for the valuable input @webknjaz and @jviotti . My understanding of make is extremely basic.

I made a "clean" target that gets rid of the venv as well, and a "spec-clean" target that does not. Does that seem correct, or should "clean" just remove the built specs, and then we have a "clean-all" or "clean-venv" or something that either removes everything or just removes the venv?

@webknjaz
Copy link

webknjaz commented Oct 8, 2022

FWIW many Python projects just use tox or nox and not Makefile which is not really native to the Python ecosystem.

Also, you may want to make use of git clean, it's a powerful tool.

@handrews
Copy link
Contributor Author

handrews commented Oct 8, 2022

@webknjaz for now I just want something that works at all. I don't have time to delve into additional tools, although if someone wants to pick that up they're more than welcome to.

It's common to make a virtualenv inside of your cloned repo
to ensure that you have the right enviornment for that repository,
and .venv is a common convention for that virtualenv.

This adds targets to create and clean a .venv virtual env using
the checked-in requirements.txt file.  It also adds the .venv
to the .gitignore, and updates the README.
Much better usage of make, incorporate venv into default target
and clean target, add a spec-clean target to avoid having
to always rebuild the venv.
Makefile Outdated
$(VENV): requirements.txt
python -m venv $@
$@/bin/python -m pip install --upgrade pip
$@/bin/python -m pip install -r requirements.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to refer to requirements.txt as $<

README.md Outdated
The Makefile can create the necessary Python virtual environment for you:

```sh
make venv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@handrews I think this comment still applies. The venv is now part of the all target, so users can just run make

@handrews handrews merged commit 4468327 into json-schema-org:main Oct 13, 2022
@handrews handrews deleted the ignore-venv branch October 15, 2022 23:23
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.

4 participants