12/11/2023 0 Comments Github add submodule to projectWhen you import this module, it will turn NeuralNetworks into a Python package, by creating the _init_.py module. Initf = os.path.join(mydir, 'NeuralNetworks', '_init_.py') Until that happens, you have one of two choices:ġ) Your code could add the subdirectory to sys.path and then access the python modules directly (not as submodules).Ģ) You could add a snippet of code in a module you define that would write the _init_.py into the git submodule: import os Also, it counts it as a commit of your present repository. Since you know git, I would first submit a pull request to get this into the upstream project (it is an innocuous change that doesn't require major reorganization of the project). Step 1: Use the following command: git submodule add Step 2: Run Command: git diff -cached -submodule Note: You will notice that Git sees it as a submodule and doesn’t track its contents when you’re not in that directory. In my specific case, I had git cloned an extension and ran git add. git directory because you wanted to add directory to your main git project. If you want to package things up as a Python package, you will need to add the _init_.py and all that stuff and make sure things still import by yourself.Īlternatively, you can use add the directory containing this stuff to your path, either through sys.path or the environment variables.Įdit: To reflect the updated question, you will need _init_.py in the submodule. Removing the directory from git and adding it again worked for me: git rm -cached directory git add directory This works if you purposefully removed the. THe examples there show how you can just run scripts in the same directory, by importing multilayer_perceptron.py. To obtain the submodules the repo must be Git cloned (not zip downloaded) then once the repo has been cloned a couple of extra steps are required to import the submodules.1) You could use git to clone it onto your local system if it is not available through pypi orĢ) There is a download button at github that will give you a zip or tar file that you can download and place under your project and use locally. Using the later version of Arduino IDE (1.6+) it’s possible to set the sketchbook location to the project repo to import all the required libs into the IDE. Submodules also make it easy for users to clone a project repo including all the sketch source code and the Arduino libs at exactly the correct version all from one place. Using submodules becomes very useful when testing an update to one of the libraries in a development branch, in the development branch the submodule can be fast-forwarded to the latest version leaving the master branch untouched. The visible sub folders contain the required Arduino libs at a specific point in time. The manual way is to simply download the necessary code files, copy them to your project, and commit the new files into your Git repository. Here is the firmware folder of the emonPi GitHub Repo. A step-by-step course for the complete beginner Table of Contents Learn on: Desktop GUI Command Line Submodules Often in a project, you want to include libraries and other resources. Also, you can make changes to the submodule from within a project and push those changes to the submodule’s repository to make them available to other projects. If the submodule gets an update, the submodule will not get updated in the repo until you specifically pull the changes into them. This means you can, for example, keep some common code in a separate repository and use a specific, known-working version of this code in other projects. So, now, as a submodule, we have awesomelibrary. The subfolder stores the submodule repository location and a commit ID. The git submodule add command is capable of taking a URL parameter, which points to the repository. With git submodules a repository can contain a checkout of another repository as a subdirectory. I feel that I have now found the best solution (for now!). However I have always wanted to have all required libs and files for a particular project all in once place. After that, we have successfully added a Submodule to our main project Before we look at a couple of use cases, lets see how you can clone a project that already has Submodules added. Things have improved in recent years with the increased use of GitHub for Arduino libs allowing changes to be tracked easier and the later version of Arduino IDE including a library manager which can auto-update. Git regards adding a Submodule as a modification like any other - and requests you to commit it to the repository. Library management becomes even more important when debugging and supporting a project as libraries get changed and updated. Library management for Arduino has always been a bit of a pain having to go and download and install all the required libraries for various locations on the internet and hope that they are the correct version. Update: PlatformIO does library management much better then git-submodules, we have switched to using PatformIO to manage library dependencies, see blog posts
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |