How to develop existing packages? If I want to develop Example.jl
, should I use pkg and
pkg> develop --local Example
or fork the repo and then clone to desktop? If so, how do I load my local copy of package to Julia? How do I run tests?
Right now I think I would do the following:
- Fork the repo on GitHub.
- Clone the forked repo to my desktop.
- Somehow make my Julia REPL recognize the clone of the forked repo on desktop as the correct package to run.
- Code in Juno and test in REPL.
- Push to my forked repo.
- Open pull request.
Past 3 is a complete mystery to me.
2 Likes
If you have already git cloned the package, you can avoid develop
and directly activate the package.
Assuming you just did $ git clone https://github.com/MyUser/SomePackage.jl
, you can either use the --project
startup flag:
$ cd SomePackage.jl
$ julia --project
julia> import SomePackage
Or use activate
:
$ julia
pkg> activate ./SomePackage.jl
julia> import SomePackage
3 Likes
How would one use pkg> dev
for creating forks and making pull requests?
I don’t think the order of 1 and 2 matters.
-
pkg> develop Example
(Example package is in dir ~/.julia/dev)
-
fork repo on github
-
- go to ~/.julia/dev/Example and use git:
git remote -v
(origin should be pointing to where the package is from)
add a new remote pointing to your fork:
git remote add myfork https://github.com/yourname/reponame
-
myfork can be any name
-
git push myfork
10 Likes
You can
pkg> dev SomeRegisteredPackage
but then you need to fork, and add the forked repository as a remote:
https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
Alternatively, you can
pkg> dev forked-repository-url
2 Likes
I do an example start to finish in this video:
First developing a new package, then making a PR to an existing package.
16 Likes
This is what I did in the end:
- Use
pkg > dev Example
- Fork on GitHub (steps 1 and 2 can be exchanged)
- Go to the folder that looks like
~/.julia/dev/Example
and open a git terminal there, and add my GitHub fork repo as its “remote origin”.Optionally add the original GitHub repo as “remote upstream”.
- Develop on my desktop.
- Push to my GitHub repo
- Open pull request on original GitHub repo
3 Likes